示例#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)
示例#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)
示例#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)
示例#4
0
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
示例#5
0
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)
示例#6
0
文件: marker.py 项目: goschtl/zope
 def dottedToInterfaces(self, seq):
     return [getInterface(self.context, dotted) for dotted in seq]
示例#7
0
文件: marker.py 项目: goschtl/zope
 def wrapper(ob, interface):
     if isinstance(interface, str):
         interface = getInterface(ob, interface)
     return f(ob, interface)