Exemple #1
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 = AccessRule(HOOK_NAME)
    registerBeforeTraverse(obj, hook, HOOK_NAME, 1)

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

    zope.interface.alsoProvides(obj, iface)
Exemple #2
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)