Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #4
0
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
Beispiel #5
0
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)
Beispiel #6
0
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
Beispiel #7
0
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)