Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFEditions.Modifiers Namespace Reference

Classes

class  ConditionalModifier
class  ConditionalTalesModifier

Functions

def createExpressionContext

Variables

tuple manage_addModifierForm
tuple manage_addTalesModifierForm

Function Documentation

def CMFEditions.Modifiers.createExpressionContext (   obj,
  portal = None,
  more_symbols 
)
Creates a valid context for the expression.

Tal expressions need a context in order to do the evaluation.
obj is the object that will be mapped to "object" in the
expression's context.
Other symbols like "repo_clone" and "obj_clone" can be passed as keyword
arguments.

Definition at line 155 of file Modifiers.py.

00155 
00156 def createExpressionContext(obj, portal=None, **more_symbols):
00157     """Creates a valid context for the expression.
00158 
00159     Tal expressions need a context in order to do the evaluation.
00160     obj is the object that will be mapped to "object" in the
00161     expression's context.
00162     Other symbols like "repo_clone" and "obj_clone" can be passed as keyword
00163     arguments.
00164     """
00165 
00166     def findNextFolderishParent(obj):
00167         """Try to find the folder of the given object by aquisition.
00168 
00169         XXX what's the correct strategy in Zope2 land to check for a folder?
00170             what's most relyable?
00171             a) check if isPrincipiaFolderish is True?
00172             b) check if the object is an ObjectManager?
00173             c) other?
00174 
00175             We have to do the right thing here to get things working
00176             correctly. I hope all the products out there do the right
00177             thing also ...
00178         """
00179         # XXX propose this check (should be the same):
00180         #    if aq_base(obj) is obj:
00181         if obj is None or not hasattr(obj, 'aq_base'):
00182             folder = None
00183         else:
00184             folder = obj
00185             # Search up the containment hierarchy until we find an
00186             # obj that claims it's a folder.
00187             while folder is not None:
00188                 if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
00189                     # found it.
00190                     break
00191                 else:
00192                     folder = aq_parent(aq_inner(folder))
00193         return folder
00194 
00195     try:
00196         obj_url = obj.absolute_url()
00197     except AttributeError:
00198         obj_url = ''
00199 
00200     # use the portal if folder lookup fails due to an unwrapped obj
00201     folder = findNextFolderishParent(obj) or portal
00202 
00203     pm = getToolByName(portal, 'portal_membership', None)
00204     if pm is None or pm.isAnonymousUser():
00205         member = None
00206     else:
00207         member = pm.getAuthenticatedMember()
00208 
00209     try:
00210         meta_type = obj.meta_type
00211     except AttributeError:
00212         meta_type = None
00213 
00214     try:
00215         portal_type = obj.getPortalTypeName()
00216     except AttributeError:
00217         portal_type  = None
00218 
00219     data = {
00220         'object_url':   obj_url,
00221         'folder_url':   folder is not None and folder.absolute_url() or '',
00222         'portal_url':   portal is not None and portal.absolute_url() or '',
00223         'object':       obj,
00224         'folder':       folder,
00225         'portal':       portal,
00226         'nothing':      None,
00227         'request':      getattr(obj, 'REQUEST', None),
00228         'modules':      SecureModuleImporter,
00229         'member':       member,
00230         'meta_type':    meta_type,
00231         'portal_type':  portal_type,
00232         }
00233     data.update(more_symbols)
00234     return getEngine().getContext(data)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 PageTemplateFile('www/modifierAddForm.pt',
00002                                           globals(),
00003                                           __name__='manage_addModifierForm')

Definition at line 40 of file Modifiers.py.

Initial value:
00001 PageTemplateFile('www/talesModifierAddForm.pt',
00002                                                globals(),
00003                                                __name__='manage_addTalesModifierForm')

Definition at line 102 of file Modifiers.py.