Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFPlone.PloneBaseTool Namespace Reference

Classes

class  PloneBaseTool

Functions

def initializeTFC
def getOAI
def createExprContext
def getExprContext

Variables

 TempFolderClass = None

Function Documentation

def CMFPlone.PloneBaseTool.createExprContext (   folder,
  portal,
  object 
)

Definition at line 65 of file PloneBaseTool.py.

00065 
00066 def createExprContext(folder, portal, object):
00067     expr_context = Expression.createExprContext(folder, portal, object)
00068     view_obj = object
00069     if view_obj is None:
00070         view_obj = portal
00071     req = view_obj.REQUEST
00072     
00073     globals_view = getMultiAdapter((view_obj, req), name='plone')
00074     expr_context.setGlobal('globals_view', globals_view)
00075     
00076     # XXX: For some reason, when using getMultiAdapter() here we get 
00077     # authoriziation problems in some cases (e.g. when using one of these
00078     # in a python: expression in an action).
00079     
00080     plone_portal_state = view_obj.restrictedTraverse('@@plone_portal_state')
00081     expr_context.setGlobal('plone_portal_state', plone_portal_state)
00082     
00083     plone_context_state = view_obj.restrictedTraverse('@@plone_context_state')
00084     expr_context.setGlobal('plone_context_state', plone_context_state)
00085     
00086     plone_tools = view_obj.restrictedTraverse('@@plone_tools')
00087     expr_context.setGlobal('plone_tools', plone_tools)
00088     
00089     # Add checkPermission to the action expression context to make cleaner
00090     # faster expressions
00091     membership_tool = getToolByName(view_obj, 'portal_membership')
00092     checkPerm = membership_tool.checkPermission
00093     expr_context.setGlobal('checkPermission', checkPerm)
00094 
00095     return expr_context

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneBaseTool.getExprContext (   context,
  object = None 
)

Definition at line 96 of file PloneBaseTool.py.

00096 
00097 def getExprContext(context, object=None):
00098     initializeTFC()
00099     request = getattr(context, 'REQUEST', None)
00100     if request:
00101         cache = request.get('_ec_cache', None)
00102         if cache is None:
00103             request['_ec_cache'] = cache = {}
00104         ec = cache.get( id(object), None )
00105     else:
00106         ec = None
00107     if ec is None:
00108         utool = getToolByName(context, 'portal_url')
00109         portal = utool.getPortalObject()
00110         if object is None or not hasattr(object, 'aq_base'):
00111             folder = portal
00112         else:
00113             folder = object
00114             # Search up the containment hierarchy until we find an
00115             # object that claims it's a folder.
00116             while folder is not None:
00117                 if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
00118                     # found it.
00119                     break
00120                 else:
00121                     # If the parent of the object at hand is a TempFolder
00122                     # don't strip off its outer acquisition context (Plone)
00123                     parent = aq_parent(aq_inner(folder))
00124                     if getattr(parent, '__class__', None) == TempFolderClass:
00125                         folder = aq_parent(folder)
00126                     else:
00127                         folder = parent
00128         ec = createExprContext(folder, portal, object)
00129         if request:
00130             cache[ id(object) ] = ec
00131     return ec

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.PloneBaseTool.getOAI (   context,
  object = None 
)

Definition at line 31 of file PloneBaseTool.py.

00031 
00032 def getOAI(context, object=None):
00033     initializeTFC()
00034     request = getattr(context, 'REQUEST', None)
00035     if request:
00036         cache = request.get('_oai_cache', None)
00037         if cache is None:
00038             request['_oai_cache'] = cache = {}
00039         info = cache.get( id(object), None )
00040     else:
00041         info = None
00042     if info is None:
00043         if object is None or not hasattr(object, 'aq_base'):
00044             folder = None
00045         else:
00046             folder = object
00047             # Search up the containment hierarchy until we find an
00048             # object that claims it's a folder.
00049             while folder is not None:
00050                 if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
00051                     # found it.
00052                     break
00053                 else:
00054                     # If the parent of the object at hand is a TempFolder
00055                     # don't strip off its outer acquisition context (Plone)
00056                     parent = aq_parent(aq_inner(folder))
00057                     if getattr(parent, '__class__', None) == TempFolderClass:
00058                         folder = aq_parent(folder)
00059                     else:
00060                         folder = parent
00061         info = oai(context, folder, object)
00062         if request:
00063             cache[ id(object) ] = info
00064     return info

Here is the call graph for this function:

Here is the caller graph for this function:

To work around circular imports ...

Definition at line 23 of file PloneBaseTool.py.

00023 
00024 def initializeTFC():
00025     """To work around circular imports ...
00026     """
00027     global TempFolderClass
00028     if TempFolderClass is None:
00029          from Products.CMFPlone.FactoryTool import TempFolder
00030          TempFolderClass = TempFolder

Here is the caller graph for this function:


Variable Documentation

Definition at line 16 of file PloneBaseTool.py.