예제 #1
0
 def index(self, model):
     """ See IACLPathCache.
     """
     for obj in lineage(model):
         acl = getattr(obj, '__acl__', None)
         if acl is not None:
             self._index[self._getPath(obj)] = acl[:]
예제 #2
0
 def _getPath(self, model):
     rpath = []
     for location in lineage(model):
         if location.__name__ is None:
             break
         rpath.insert(0, location.__name__)
     return tuple(rpath)
예제 #3
0
파일: api.py 프로젝트: boothead/karl
 def render_sidebar(self):
     """Render the sidebar appropriate for the context."""
     for ancestor in lineage(self.context):
         r = queryMultiAdapter((ancestor, self.request), ISidebar)
         if r is not None:
             return r(self)
     # no sidebar exists for this context.
     return ""
예제 #4
0
파일: api.py 프로젝트: boothead/karl
    def render_footer(self):
        """Render the footer appropriate for the context."""
        for ancestor in lineage(self.context):
            r = queryMultiAdapter((ancestor, self.request), IFooter)
            if r is not None:
                return r(self)

        # no footer exists for this context, use the default.
        return DefaultFooter(self.context, self.request)(self)
예제 #5
0
 def lookup(self, model, permission=None):
     """ See IACLPathCache.
     """
     aces = []
     for obj in lineage(model):
         path = self._getPath(obj)
         acl = self._index.get(path)
         if acl is None:
             acl = getattr(obj, '__acl__', ())
             if acl:
                 self._index[path] = acl
         if permission is not None:
             acl = [x for x in acl
                     if x[2] == permission
                         or isinstance(x[2], AllPermissionsList)]
         aces.extend(acl)
         if [x for x in acl if x[1] is Everyone]:
             break
     return aces
예제 #6
0
파일: site.py 프로젝트: cguardia/karl
def get_containment(object, defaults):
    ifaces = set()
    for ancestor in lineage(object):
        ifaces.update(get_interfaces(ancestor, ()))
    return ifaces