def utility(_context, provides=None, component=None, factory=None, permission=None, name=''): if factory and component: raise TypeError("Can't specify factory and component.") if provides is None: if factory: provides = list(zope.interface.implementedBy(factory)) else: provides = list(zope.interface.providedBy(component)) if len(provides) == 1: provides = provides[0] else: raise TypeError("Missing 'provides' attribute") if permission is not None: check_security_support() component = proxify(component, provides=provides, permission=permission) _context.action( discriminator = ('utility', provides, name), callable = handler, args = ('registerUtility', component, provides, name), kw = dict(factory=factory), ) _context.action( discriminator = None, callable = provideInterface, args = (provides.__module__ + '.' + provides.getName(), provides) )
def utility(_context, provides=None, component=None, factory=None, permission=None, name=''): if factory and component: raise TypeError("Can't specify factory and component.") if provides is None: if factory: provides = list(implementedBy(factory)) else: provides = list(providedBy(component)) if len(provides) == 1: provides = provides[0] else: raise TypeError("Missing 'provides' attribute") if name == '': if factory: name = getName(factory) else: name = getName(component) if permission is not None: component = proxify(component, provides=provides, permission=permission) _context.action( discriminator = ('utility', provides, name), callable = handler, args = ('registerUtility', component, provides, name, _context.info), kw = dict(factory=factory), ) _context.action( discriminator = None, callable = provideInterface, args = ('', provides), )
def proxyResource(request, factory=factory, checker=checker): return proxify(factory(request), checker)
def __call__(self, *objects): return proxify(self.factory(*objects), self.checker)
def _callFUT(self, *args, **kw): from zope.component.security import proxify return proxify(*args, **kw)
def _assertPermission(permission, interfaces, component): if not SECURITY_SUPPORT: raise ConfigurationError( "security proxied components are not " "supported because zope.security is not available") return proxify(component, provides=interfaces, permission=permission)
def _assertPermission(permission, interfaces, component): if not SECURITY_SUPPORT: raise ConfigurationError("security proxied components are not " "supported because zope.security is not available") return proxify(component, provides=interfaces, permission=permission)
def _assertPermission(permission, interfaces, component): return proxify(component, provides=interfaces, permission=permission)