예제 #1
0
파일: zcml.py 프로젝트: bedwards/lampy
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)
        )
예제 #2
0
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)
        )
예제 #3
0
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),
        )
예제 #4
0
 def proxyResource(request, factory=factory, checker=checker):
     return proxify(factory(request), checker)
예제 #5
0
 def __call__(self, *objects):
     return proxify(self.factory(*objects), self.checker)
예제 #6
0
 def _callFUT(self, *args, **kw):
     from zope.component.security import proxify
     return proxify(*args, **kw)
예제 #7
0
 def _callFUT(self, *args, **kw):
     from zope.component.security import proxify
     return proxify(*args, **kw)
예제 #8
0
파일: zcml.py 프로젝트: sofian86/Mailman-1
 def proxyResource(request, factory=factory, checker=checker):
     return proxify(factory(request), checker)
예제 #9
0
파일: zcml.py 프로젝트: sofian86/Mailman-1
 def __call__(self, *objects):
     return proxify(self.factory(*objects), self.checker)
예제 #10
0
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)
예제 #11
0
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)
예제 #12
0
 def _assertPermission(permission, interfaces, component):
     return proxify(component, provides=interfaces, permission=permission)