Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFCore.src.five.localsitemanager.registry Namespace Reference

Classes

class  FiveVerifyingAdapterLookup
class  PersistentComponents

Functions

def _recurse_to_site
def _wrap
def _rewrap

Variables

tuple _marker = object()

Function Documentation

def CMFCore.src.five.localsitemanager.registry._recurse_to_site (   current,
  wanted 
) [private]

Definition at line 92 of file registry.py.

00092 
00093 def _recurse_to_site(current, wanted):
00094     if not Acquisition.aq_base(current) == wanted:
00095         current = _recurse_to_site(get_parent(current), wanted)
00096     return current

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 150 of file registry.py.

00150 
00151 def _rewrap(obj):
00152     obj = Acquisition.aq_inner(obj)
00153     base = Acquisition.aq_base(obj)
00154     parent = Acquisition.aq_parent(obj)
00155     if not parent or isinstance(parent, RequestContainer):
00156         return base
00157     return base.__of__(_rewrap(parent))
00158 

Here is the caller graph for this function:

def CMFCore.src.five.localsitemanager.registry._wrap (   comp,
  registry 
) [private]
Return an aq wrapped component with the site as the parent but
only if the comp has an aq wrapper to begin with.

Definition at line 97 of file registry.py.

00097 
00098 def _wrap(comp, registry):
00099     """Return an aq wrapped component with the site as the parent but
00100     only if the comp has an aq wrapper to begin with.
00101     """
00102 
00103     # BBB: The primary reason for doing this sort of wrapping of
00104     # returned utilities is to support CMF tool-like functionality where
00105     # a tool expects its aq_parent to be the portal object. New code
00106     # (ie new utilities) should not rely on this predictability to
00107     # get the portal object and should search out an alternate means
00108     # (possibly retrieve the ISiteRoot utility). Although in most
00109     # cases getting at the portal object shouldn't be the required pattern
00110     # but instead looking up required functionality via other (possibly
00111     # local) components.
00112 
00113     if registry.__bases__ and IAcquirer.providedBy(comp):
00114         current_site = getSite()
00115         registry_site = Acquisition.aq_base(registry.__parent__)
00116         if not ISite.providedBy(registry_site):
00117             registry_site = registry_site.__parent__
00118 
00119         if current_site is None:
00120             # If no current site can be found, return utilities wrapped in
00121             # the site they where registered in. We loose the whole aq chain
00122             # here though
00123             current_site = Acquisition.aq_base(registry_site)
00124 
00125         parent = None
00126 
00127         if current_site == registry_site:
00128             parent = current_site
00129         else:
00130             parent = _recurse_to_site(current_site, registry_site)
00131 
00132         if parent is None:
00133             raise ValueError('Not enough context to acquire parent')
00134 
00135         base = Acquisition.aq_base(comp)
00136         # clean up aq_chain, removing REQUEST objects
00137         parent = _rewrap(parent)
00138 
00139         if base is not Acquisition.aq_base(parent):
00140             # If the component is not the component registry container,
00141             # wrap it in the parent
00142             comp = base.__of__(parent)
00143         else:
00144             # If the component happens to be the component registry
00145             # container we are looking up a ISiteRoot.
00146             # We are not wrapping it in itself but in its own parent
00147             comp = base.__of__(Acquisition.aq_parent(parent))
00148 
00149     return comp

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 17 of file registry.py.