Esempio n. 1
0
    def test_getLocalInterface_delegates_to_globalUtility(self):
        gsm = zapi.getGlobalSiteManager()
        gsm.provideUtility(IInterface, Bar("blob"), name="blob")
        gsm.provideUtility(IBaz, Baz("global baz"))
        gsm.provideUtility(IInterface, Foo("global bob"), name="bob")

        self.assertEqual(getInterface(None, "bob").__class__, Foo)
        self.assertEqual(getInterface(None, "blob").__class__, Bar)
Esempio n. 2
0
 def getInterfaceURL(self, name):
     sm = zapi.getSiteManager(self.context)
     try:
         getInterface(self.context, name)
         url = zapi.absoluteURL(sm, self.request)
     except ComponentLookupError:
         return ""
     return "%s/interfacedetail.html?id=%s" % (url, name)
Esempio n. 3
0
    def update(self):
        if 'ADD' in self.request:
            for interface in self.getIntrospector().getMarkerInterfaceNames():
                if "add_%s" % interface in self.request:
                    ob = self.context
                    interface = getInterface(ob, interface)
                    directlyProvides(removeAllProxies(ob), directlyProvidedBy(ob), interface)

        if 'REMOVE' in self.request:
            for interface in self.getIntrospector().getDirectlyProvidedNames():
                if "rem_%s" % interface in self.request:
                    ob = self.context
                    interface = getInterface(ob, interface)
                    directlyProvides(removeAllProxies(ob), directlyProvidedBy(ob)-interface)
Esempio n. 4
0
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
Esempio n. 5
0
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)
Esempio n. 6
0
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
Esempio n. 7
0
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)