def ServiceFactory(factory): """A factory for Silva services. """ service_interface = get_service_interface(factory) def factory_method(container, identifier=None, REQUEST=None, *args, **kw): """Create a instance of that service, callable through the web. """ identifier = get_service_id(factory, identifier) identifier = normalize_identifier(identifier) if identifier is None: raise ValueError("No id for the new service") service = factory(identifier, *args, **kw) service = registerService( container, identifier, service, service_interface) notify(ObjectCreatedEvent(service)) if REQUEST is not None: REQUEST.response.redirect( service.absolute_url() + '/manage_workspace') return '' else: return service return factory_method
def unregisterByDefaultServices(service, event): interface = get_service_interface(service, is_class=False) unregisterService(service, interface)