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)
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)
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)
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)
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)
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)
def __call__(self, container, request): if SUPPRESS_ACCESSRULE: return NameCaller.__call__(self, container, request)
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)