Esempio n. 1
0
 def form_action_url(self):
     from opencore.interfaces import IOpenSiteRoot
     url = self.request.getURL()
     if IOpenSiteRoot.providedBy(self.context):
         return url
     else:
         return self.context.absolute_url() + '/searchresults'
Esempio n. 2
0
def contained_within(viewlet):
    """
    walk up the acquisition chain and verify if the any either the context
    of the viewlet, or any of its parents, provide the viewlet.container
    interface

    returns the nearest satisfactory container or None.

    however, we don't want to go outside the current 'content locus' (portal,
    project or person) -- that is, if we're at /openplans/projects/foo/wikipage
    and the viewlet's contained_within filter is IAddProjects, this function
    should *not* return a true value.
    """

    from Acquisition import aq_inner, aq_parent

    obj = aq_inner(viewlet.context)
    iface = viewlet.container

    while obj is not None:
        if iface.providedBy(obj):
            return obj

        if IMemberFolder.providedBy(obj) or \
                IProject.providedBy(obj) or \
                IOpenSiteRoot.providedBy(obj):
            return None

        obj = aq_parent(obj)
        
    return None