Back to index

plone3  3.1.7
Classes | Functions
CMFCore.Expression Namespace Reference

Classes

class  Expression

Functions

def getExprContext
def createExprContext

Function Documentation

def CMFCore.Expression.createExprContext (   folder,
  portal,
  object 
)
An expression context provides names for TALES expressions.

Definition at line 86 of file Expression.py.

00086 
00087 def createExprContext(folder, portal, object):
00088     '''
00089     An expression context provides names for TALES expressions.
00090     '''
00091     pm = getToolByName(portal, 'portal_membership')
00092     if object is None:
00093         object_url = ''
00094     else:
00095         object_url = object.absolute_url()
00096     if pm.isAnonymousUser():
00097         member = None
00098     else:
00099         member = pm.getAuthenticatedMember()
00100     data = {
00101         'object_url':   object_url,
00102         'folder_url':   folder.absolute_url(),
00103         'portal_url':   portal.absolute_url(),
00104         'object':       object,
00105         'folder':       folder,
00106         'portal':       portal,
00107         'nothing':      None,
00108         'request':      getattr(portal, 'REQUEST', None),
00109         'modules':      SecureModuleImporter,
00110         'member':       member,
00111         'here':         object,
00112         }
00113     return getEngine().getContext(data)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.Expression.getExprContext (   context,
  object = None 
)

Definition at line 56 of file Expression.py.

00056 
00057 def getExprContext(context, object=None):
00058     request = getattr(context, 'REQUEST', None)
00059     if request:
00060         cache = request.get('_ec_cache', None)
00061         if cache is None:
00062             request['_ec_cache'] = cache = {}
00063         ec = cache.get( id(object), None )
00064     else:
00065         ec = None
00066     if ec is None:
00067         utool = getToolByName(context, 'portal_url')
00068         portal = utool.getPortalObject()
00069         if object is None or not hasattr(object, 'aq_base'):
00070             folder = portal
00071         else:
00072             folder = object
00073             # Search up the containment hierarchy until we find an
00074             # object that claims it's a folder.
00075             while folder is not None:
00076                 if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
00077                     # found it.
00078                     break
00079                 else:
00080                     folder = aq_parent(aq_inner(folder))
00081         ec = createExprContext(folder, portal, object)
00082         if request:
00083             cache[ id(object) ] = ec
00084     return ec
00085 

Here is the call graph for this function:

Here is the caller graph for this function: