Back to index

plone3  3.1.7
base_zope.py
Go to the documentation of this file.
00001 """some common utilities
00002 """
00003 
00004 FB_REGISTRY = None
00005 
00006 # base class
00007 from ExtensionClass import Base
00008 from Acquisition import aq_base
00009 
00010 # logging function
00011 import logging
00012 
00013 logger = logging.getLogger('PortalTransforms')
00014 
00015 def log(msg, severity=logging.INFO, id='PortalTransforms'):
00016     logger.log(severity, msg)
00017 
00018 # directory where template for the ZMI are located
00019 import os.path
00020 _www = os.path.join(os.path.dirname(__file__), 'www')
00021 skins_dir = os.path.join(os.path.dirname(__file__), 'skins')
00022 
00023 # list and dict classes to use
00024 from Globals import PersistentMapping as DictClass
00025 try:
00026     from ZODB.PersistentList import PersistentList as ListClass
00027 except ImportError:
00028     from persistent.list import PersistentList as ListClass
00029 
00030 from Interface import Interface, Attribute
00031 
00032 def implements(object, interface):
00033     return interface.isImplementedBy(object)
00034 
00035 # getToolByName
00036 from Products.CMFCore.utils import getToolByName as _getToolByName
00037 _marker = []
00038 
00039 def getToolByName(context, name, default=_marker):
00040     global FB_REGISTRY
00041     tool = _getToolByName(context, name, default)
00042     if name == 'mimetypes_registry' and tool is default:
00043         if FB_REGISTRY is None:
00044             from Products.MimetypesRegistry.MimeTypesRegistry \
00045                  import MimeTypesRegistry
00046             FB_REGISTRY = MimeTypesRegistry()
00047         tool = FB_REGISTRY
00048     return tool
00049 
00050 from zExceptions import BadRequest
00051 
00052 __all__ = ('Base', 'log', 'DictClass', 'ListClass', 'getToolByName', 'aq_base',
00053            'Interface', 'Attribute', 'implements', 'skins_dir', '_www',
00054            'BadRequest', )