Пример #1
0
    def test_gsm_is_IComponentLookup(self):
        from guillotina.component.globalregistry import base
        from guillotina.component.interfaces import IComponentLookup

        gsm = self._callFUT()
        self.assertTrue(gsm is base)
        self.assertTrue(IComponentLookup.providedBy(gsm))
Пример #2
0
def get_component_registry(context=None):
    """ See IComponentArchitecture.
    """
    if context is None:
        return globalregistry.base
    else:
        # Use the global site manager to adapt context to `IComponentLookup`
        # to avoid the recursion implied by using a local `get_adapter()` call.
        try:
            return IComponentLookup(context)
        except TypeError as error:
            raise ComponentLookupError(*error.args)
Пример #3
0
def getSiteManager(context=None):
    """ See IComponentArchitecture.
    """
    global base
    if context is None:
        if base is None:
            from guillotina.component.globalregistry import base
        return base
    else:
        # Use the global site manager to adapt context to `IComponentLookup`
        # to avoid the recursion implied by using a local `getAdapter()` call.
        try:
            return IComponentLookup(context)
        except TypeError as error:
            raise ComponentLookupError(*error.args)
Пример #4
0
def getSiteManager(context=None):
    """A special hook for getting the site manager.

    Here we take the currently set site into account to find the appropriate
    site manager.
    """
    if context is None:
        return siteinfo.sm

    # We remove the security proxy because there's no way for
    # untrusted code to get at it without it being proxied again.

    # We should really look look at this again though, especially
    # once site managers do less.  There's probably no good reason why
    # they can't be proxied.  Well, except maybe for performance.
    sm = IComponentLookup(context, getGlobalSiteManager())
    return sm
Пример #5
0
 def test_gsm_is_IComponentLookup(self):
     from guillotina.component.globalregistry import base
     from guillotina.component.interfaces import IComponentLookup
     gsm = self._callFUT()
     self.assertTrue(gsm is base)
     self.assertTrue(IComponentLookup.providedBy(gsm))
Пример #6
0
 def test_sm_is_IComponentLookup(self):
     from guillotina.component.interfaces import IComponentLookup
     sm = self._callFUT()
     self.assertTrue(IComponentLookup.providedBy(sm))
Пример #7
0
 def test_sm_is_IComponentLookup(self):
     from guillotina.component.interfaces import IComponentLookup
     sm = self._callFUT()
     self.assertTrue(IComponentLookup.providedBy(sm))