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