예제 #1
0
 def manage_hook(self, hook=0):
     """ """
     if hook != self.hooked():
         if hook:
             hook = NameCaller(self.id)
             registerBeforeTraverse(aq_parent(self), hook, self.meta_type)
         else:
             unregisterBeforeTraverse(aq_parent(self), self.meta_type)
예제 #2
0
    def manage_afterAdd(self, item, container):
        if item is self:
            id = self.id
            if callable(id): id = id()

            # We want the original object, not stuff in between
            container = container.this()
            hook = NameCaller(id)
            registerBeforeTraverse(container, hook, self.meta_type,
                                   self.priority)
예제 #3
0
def Localizer_moved(object, event):
    container = event.oldParent
    if container is not None:
        unregisterBeforeTraverse(container, object.meta_type)

    container = event.newParent
    if container is not None:
        id = object.id
        container = container.this()
        hook = NameCaller(id)
        registerBeforeTraverse(container, hook, object.meta_type)
예제 #4
0
    def manage_afterAdd(self, item, container):
        if item is self:
            if queryBeforeTraverse(container, self.meta_type):
                raise BadRequest, ('This container already has a %s' %
                                   self.meta_type)
            id = self.id
            if callable(id): id = id()

            # We want the original object, not stuff in between
            container = container.this()
            hook = NameCaller(id)
            registerBeforeTraverse(container, hook, self.meta_type,
                                   self.priority)
예제 #5
0
def enableSite(obj, iface=ISite):
    """Install __before_traverse__ hook for Local Site
    """
    # We want the original object, not stuff in between, and no acquisition
    obj = aq_base(obj)
    if not IPossibleSite.providedBy(obj):
        raise TypeError('Must provide IPossibleSite')
    hook = NameCaller(HOOK_NAME)
    registerBeforeTraverse(obj, hook, HOOK_NAME, 1)

    if not hasattr(obj, HOOK_NAME):
        setattr(obj, HOOK_NAME, LocalSiteHook())

    zope.interface.alsoProvides(obj, iface)
예제 #6
0
def _cvt_btr(app):
    stack = [app]
    while stack:
        o = stack.pop()
        ov = getattr(o, 'objectValues', None)
        if ov is not None:
            stack.extend(list(ov()))
            btr = getattr(o, '__before_traverse__', None)
            if btr and type(btr) == type({}):
                touched = 0
                for k, v in btr.items():
                    if type(v) is type(''):
                        touched = 1
                        if k[1] == 'AccessRule':
                            btr[k] = AccessRule(v)
                        else:
                            btr[k] = NameCaller(v)
                if touched:
                    rewriteBeforeTraverse(o, btr)
예제 #7
0
 def __call__(self, container, request):
     if SUPPRESS_ACCESSRULE:
         return
     NameCaller.__call__(self, container, request)
예제 #8
0
 def __call__(self, container, request):
     if SUPPRESS_ACCESSRULE: return
     if '_SUPPRESS_ACCESSRULE' in _swallow(request, '_SUPPRESS'):
         request.setVirtualRoot(request.steps)
         return
     NameCaller.__call__(self, container, request)
예제 #9
0
 def __call__(self, container, request):
     if SUPPRESS_ACCESSRULE:
         return
     NameCaller.__call__(self, container, request)
예제 #10
0
 def __call__(self, container, request):
     if SUPPRESS_ACCESSRULE: return
     if '_SUPPRESS_ACCESSRULE' in _swallow(request, '_SUPPRESS'):
         request.setVirtualRoot(request.steps)
         return
     NameCaller.__call__(self, container, request)