Ejemplo n.º 1
0
 def testUpdateTraversalData(self):
     self.m.setBrowserIdNamespaces(('url',))
     self.m.updateTraversalData()
     self.failUnless(self.m.hasTraversalHook(self.app))
     self.failUnless(queryBeforeTraverse(self.app, 'BrowserIdManager'))
     self.m.setBrowserIdNamespaces(('cookies', 'form'))
     self.m.updateTraversalData()
     self.failUnless(not queryBeforeTraverse(self.app,'BrowserIdManager'))
Ejemplo n.º 2
0
 def testUpdateTraversalData(self):
     self.m.setBrowserIdNamespaces(('url', ))
     self.m.updateTraversalData()
     self.failUnless(self.m.hasTraversalHook(self.app))
     self.failUnless(queryBeforeTraverse(self.app, 'BrowserIdManager'))
     self.m.setBrowserIdNamespaces(('cookies', 'form'))
     self.m.updateTraversalData()
     self.failUnless(not queryBeforeTraverse(self.app, 'BrowserIdManager'))
    def test_add_addToContainer(self):
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        vhm1 = self._makeOne()
        vhm1.manage_addToContainer(self.root)

        self.assertTrue(vhm1.getId() in self.root.objectIds())
        self.assertTrue(queryBeforeTraverse(self.root, vhm1.meta_type))
Ejemplo n.º 4
0
    def test_add_addToContainer(self):
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        vhm1 = self._makeOne()
        vhm1.manage_addToContainer(self.root)

        self.assertTrue(vhm1.getId() in self.root.objectIds())
        self.assertTrue(queryBeforeTraverse(self.root, vhm1.meta_type))
Ejemplo n.º 5
0
def getAccessRule(self, REQUEST=None):
    "Return the name of the current AccessRule, if any"
    self = self.this()
    rules = queryBeforeTraverse(self, 'AccessRule')
    if rules:
        try:
            return rules[0][1].name
        except:
            return 'Invalid BeforeTraverse data: ' + `rules`
    return ''
    def test_add_manage_addVirtualHostMonster(self):
        from Products.SiteAccess.VirtualHostMonster import \
            manage_addVirtualHostMonster
        from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        manage_addVirtualHostMonster(self.root)

        self.assertTrue(VirtualHostMonster.id in self.root.objectIds())
        hook = queryBeforeTraverse(self.root, VirtualHostMonster.meta_type)
        self.assertTrue(hook)
Ejemplo n.º 7
0
def getAccessRule(self, REQUEST=None):
    "Return the name of the current AccessRule, if any"
    self = self.this()
    rules = queryBeforeTraverse(self, 'AccessRule')
    if rules:
        try:
            return rules[0][1].name
        except:
            return 'Invalid BeforeTraverse data: ' + `rules`
    return ''
Ejemplo n.º 8
0
    def test_add_manage_addVirtualHostMonster(self):
        from Products.SiteAccess.VirtualHostMonster import \
            manage_addVirtualHostMonster
        from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
        from ZPublisher.BeforeTraverse import queryBeforeTraverse
        manage_addVirtualHostMonster(self.root)

        self.assertTrue(VirtualHostMonster.id in self.root.objectIds())
        hook = queryBeforeTraverse(self.root, VirtualHostMonster.meta_type)
        self.assertTrue(hook)
Ejemplo n.º 9
0
 def test_unregisterTraversalHook_normal(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): object()}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.unregisterTraversalHook() # needs wrapper
     self.assertFalse(queryBeforeTraverse(mgr, 'BrowserIdManager'))
Ejemplo n.º 10
0
 def test_unregisterTraversalHook_normal(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): object()}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.unregisterTraversalHook() # needs wrapper
     self.assertFalse(queryBeforeTraverse(mgr, 'BrowserIdManager'))
Ejemplo n.º 11
0
 def test_updateTraversalData_not_url_ns(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     mgr.setBrowserIdNamespaces(('cookies', 'form'))
     parent = Parent()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): object()}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.updateTraversalData() # needs wrapper
     self.assertFalse(queryBeforeTraverse(mgr, 'BrowserIdManager'))
Ejemplo n.º 12
0
 def test_updateTraversalData_not_url_ns(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     mgr.setBrowserIdNamespaces(('cookies', 'form'))
     parent = Parent()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): object()}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.updateTraversalData() # needs wrapper
     self.assertFalse(queryBeforeTraverse(mgr, 'BrowserIdManager'))
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
 def test_registerTraversalHook_normal(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     from Products.Sessions.BrowserIdManager import BrowserIdManagerTraverser
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     parent.browser_id_manager = mgr
     parent.browser_id_manager.registerTraversalHook() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 40)
     self.assertTrue(isinstance(hooks[0][1], BrowserIdManagerTraverser))
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
 def test_registerTraversalHook_normal(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     from Products.Sessions.BrowserIdManager import BrowserIdManagerTraverser
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     parent.browser_id_manager = mgr
     parent.browser_id_manager.registerTraversalHook() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 40)
     self.assertTrue(isinstance(hooks[0][1], BrowserIdManagerTraverser))
Ejemplo n.º 17
0
 def test_updateTraversalData_w_url_ns(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     from Products.Sessions.BrowserIdManager import BrowserIdManagerTraverser
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     mgr.setBrowserIdNamespaces(('url',))
     parent = Parent()
     parent.browser_id_manager = mgr
     parent.browser_id_manager.updateTraversalData() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 40)
     self.assertTrue(isinstance(hooks[0][1], BrowserIdManagerTraverser))
Ejemplo n.º 18
0
 def test_updateTraversalData_w_url_ns(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     from Products.Sessions.BrowserIdManager import BrowserIdManagerTraverser
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     mgr.setBrowserIdNamespaces(('url',))
     parent = Parent()
     parent.browser_id_manager = mgr
     parent.browser_id_manager.updateTraversalData() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 40)
     self.assertTrue(isinstance(hooks[0][1], BrowserIdManagerTraverser))
Ejemplo n.º 19
0
 def test_registerTraversalHook_doesnt_replace_existing(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     hook = object()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): hook}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.registerTraversalHook() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 0)
     self.assertTrue(hooks[0][1] is hook)
Ejemplo n.º 20
0
 def test_registerTraversalHook_doesnt_replace_existing(self):
     from Acquisition import Implicit
     from ZPublisher.BeforeTraverse import queryBeforeTraverse
     class Parent(Implicit):
         pass
     mgr = self._makeOne()
     parent = Parent()
     hook = object()
     parent.__before_traverse__ = {(0, 'BrowserIdManager'): hook}
     parent.browser_id_manager = mgr
     parent.browser_id_manager.registerTraversalHook() # needs wrapper
     hooks = queryBeforeTraverse(parent, 'BrowserIdManager')
     self.assertEqual(len(hooks), 1)
     self.assertEqual(hooks[0][0], 0)
     self.assertTrue(hooks[0][1] is hook)
    def testSwitchDefaultSkin(self):
        response = self.publish(
            self.folder_path + '/@@switchDefaultSkin?skin_name=Sunburst%20Theme',
            basic=self.basic_auth)
        self.assertEqual(response.getStatus(), 302)
        self.assertEqual(self.folder.absolute_url(),
                         response.getHeader("Location"))
        self.assertTrue(hasattr(aq_base(self.folder), HOOK_NAME))
        self.assertTrue(isinstance(getattr(aq_base(self.folder), HOOK_NAME),
                                   LocalSiteHook))

        btr = queryBeforeTraverse(self.folder, HOOK_NAME)[0]
        self.assertEqual(1, btr[0])
        self.assertTrue(isinstance(btr[1], AccessRule))
        self.assertEqual(HOOK_NAME, btr[1].name)
        ns = IAnnotations(self.folder).get(ANNOTATION_KEY, None)
        self.assertNotEqual(None, ns)
        self.assertEqual("Sunburst Theme", ns["default-skin"])
Ejemplo n.º 22
0
 def hooked(self):
     """ """
     if queryBeforeTraverse(aq_parent(self), self.meta_type):
         return 1
     return 0
Ejemplo n.º 23
0
 def hasTraversalHook(self, parent):
     name = TRAVERSAL_APPHANDLE
     return not not queryBeforeTraverse(parent, name)
Ejemplo n.º 24
0
 def hasTraversalHook(self, parent):
     name = TRAVERSAL_APPHANDLE
     return not not queryBeforeTraverse(parent, name)
Ejemplo n.º 25
0
 def hooked(self):
     """ """
     if queryBeforeTraverse(self.aq_parent, self.meta_type):
         return 1
     return 0