def execute( self, content, config, icon, factory, zmi_addable, **kw): """Register a Silva Service or a ZMIObject """ default_factory = None if ISilvaService.implementedBy(content): default_factory = ServiceFactory zmi_addable = ISilvaLocalService.implementedBy(content) self._register_content( config, content, factory, default_factory, icon, zmi_addable) return True
def get_service_interface(factory, is_class=True): """Get service interface. """ if not is_class: factory = factory.__class__ provided = grok.provides.bind(get_default=lambda *x: None).get(factory) if provided is not None: return provided implemented = list(implementedBy(factory).interfaces()) if (not len(implemented) or ISilvaService.extends(implemented[0])): raise ValueError( u"Service %r doesn't implements a service interface" % ( factory,)) return implemented[0]