예제 #1
0
    def test_queryNextSiteManager(self):
        from zope.app.component import queryNextSiteManager
        marker = object()
        self.assert_(queryNextSiteManager(self.root, marker) is marker)
        self.assert_(queryNextSiteManager(self.f1, marker) is getGlobalSiteManager())
        self.assertEqual(queryNextSiteManager(self.f2, marker), self.sm1)
        self.assertEqual(queryNextSiteManager(self.sm1), getGlobalSiteManager())
        self.assertEqual(queryNextSiteManager(self.sm2), self.sm1)
        self.assert_(queryNextSiteManager(self.p1, marker) is marker)
        self.assert_(queryNextSiteManager(self.p2, marker) is marker)

        self.assert_(queryNextSiteManager(self.unparented_folder, marker)
                     is marker)
        self.assert_(queryNextSiteManager(self.unrooted_subfolder, marker)
                     is marker)
예제 #2
0
    def test_queryNextSiteManager(self):
        from zope.app.component import queryNextSiteManager
        marker = object()
        self.assert_(queryNextSiteManager(self.root, marker) is marker)
        self.assert_(queryNextSiteManager(self.f1, marker) is getGlobalSiteManager())
        self.assertEqual(queryNextSiteManager(self.f2, marker), self.sm1)
        self.assertEqual(queryNextSiteManager(self.sm1), getGlobalSiteManager())
        self.assertEqual(queryNextSiteManager(self.sm2), self.sm1)
        self.assert_(queryNextSiteManager(self.p1, marker) is marker)
        self.assert_(queryNextSiteManager(self.p2, marker) is marker)

        self.assert_(queryNextSiteManager(self.unparented_folder, marker)
                     is marker)
        self.assert_(queryNextSiteManager(self.unrooted_subfolder, marker)
                     is marker)
예제 #3
0
    def items(self):
        sm = zapi.getSiteManager()
        ifaces = {}
        while sm is not None:
            for reg in sm.registrations():
                if isinstance(reg, UtilityRegistration):
                    path = getPythonPath(reg.provided)
                    ifaces[path] = UtilityInterface(self, path, reg.provided)
            sm = queryNextSiteManager(sm)

        items = ifaces.items()
        items.sort(lambda x, y: cmp(x[0].split('.')[-1], y[0].split('.')[-1]))
        return items
예제 #4
0
 def __init__(self, context):
     self.context = context
     self.sm = getSiteManager(context)
     self.nsm = queryNextSiteManager(context)