Back to index

plone3  3.1.7
Functions | Variables
ATContentTypes.modulealiases Namespace Reference

Functions

def createModuleAliases

Variables

string __author__ = ''
string __docformat__ = 'restructuredtext'

Function Documentation

Creates module aliases in sys.modules

Aliases are created for Products.ATContentTypes.types and all modules below
it which contain classes with persistent objects (content types) but for
modules with base classes and schemata.

It might look a little bit tricky but it's very easy. The method is
iterating over all modules in the module name space (globals) and creating
aliases only forthoses modules which are modules with the module name starting with
Products.ATContentTypes. All these modules have a module level var called
"__old_name__".

Definition at line 55 of file modulealiases.py.

00055 
00056 def createModuleAliases():
00057     """Creates module aliases in sys.modules
00058 
00059     Aliases are created for Products.ATContentTypes.types and all modules below
00060     it which contain classes with persistent objects (content types) but for
00061     modules with base classes and schemata.
00062 
00063     It might look a little bit tricky but it's very easy. The method is
00064     iterating over all modules in the module name space (globals) and creating
00065     aliases only forthoses modules which are modules with the module name starting with
00066     Products.ATContentTypes. All these modules have a module level var called
00067     "__old_name__".
00068     """
00069     for module in globals().values():
00070         if type(module) is not ModuleType:
00071             # not a module
00072             continue
00073         name = module.__name__
00074         if not name.startswith('Products.ATContentTypes'):
00075             # not a module inside ATCT
00076             continue
00077         old_name = getattr(module, '__old_name__', None)
00078         if old_name is None:
00079             continue
00080         sys.modules[old_name] = module
00081 
# Aliase for EXIF classes

Here is the call graph for this function:


Variable Documentation

Definition at line 24 of file modulealiases.py.

string ATContentTypes.modulealiases.__docformat__ = 'restructuredtext'

Definition at line 25 of file modulealiases.py.