Ejemplo n.º 1
0
    def installUtility(self):
        sm = getSiteManager()

        if 'auth' in sm:
            pau = sm[u'auth']
            sm.registerUtility(pau, IAuthentication)
            return

        portal = getSite()
        if IContainmentRoot.providedBy(portal):
            prefix = u''
        else:
            id = getUtility(IIntIds).queryId(removeAllProxies(portal))
            if not id:
                id = u''
            prefix = u'%s.'%id

        # PluggableAuthentication
        pau = PluggableAuthentication(prefix)
        event.notify(ObjectCreatedEvent(pau))
        sm[u'auth'] = pau
        sm.registerUtility(pau, IAuthentication)

        # Credentials Plugin
        factory = getUtility(ICredentialsPluginFactory, 'default.credentials')
        factory.install()
        factory.activate()
Ejemplo n.º 2
0
 def __str__(self):
     if IContainmentRoot.providedBy(self.context):
         return ''
     name = self.context.__name__
     url = absoluteURL(getParent(self.context), self.request)
     url += '/' + name
     return url
Ejemplo n.º 3
0
 def __str__(self):
     if IContainmentRoot.providedBy(self.context):
         return ''
     name = self.context.__name__
     url = absoluteURL(getParent(self.context), self.request)
     url += '/' + name
     return url
Ejemplo n.º 4
0
    def upperContainer(self):
        request = self.request
        vhr = request.getVirtualHostRoot()
        parent = getattr(self.context, '__parent__', None)

        while True:
            if (parent is None or
                sameProxiedObjects(parent, vhr) or
                IContainmentRoot.providedBy(parent)):
                return None

            if IContentContainer.providedBy(parent):
                url = absoluteURL(parent, request)

                if checkPermission('zojax.ModifyContent', parent):
                    return '%s/@@context.html' % url

                viewName = queryMultiAdapter(
                    (parent, request),
                    IContentViewView
                )
                if viewName:
                    return '%s/%s' % (url, viewName.name)

                return '%s/' % url
            else:
                parent = getattr(parent, '__parent__', None)
Ejemplo n.º 5
0
 def name(self):
     """See interfaces.IBreadcrumb"""
     name = getattr(self.context, 'title', '')
     if not name:
         name = getattr(self.context, '__name__', '')
     if not name and IContainmentRoot.providedBy(self.context):
         name = 'top'
     return name
Ejemplo n.º 6
0
 def name(self):
     """See interfaces.IBreadcrumb"""
     name = getattr(self.context, 'ikName', '')
     if not name:
         name = getattr(self.context, '__name__', '')
     if not name and IContainmentRoot.providedBy(self.context):
         name = 'top'
     return name
Ejemplo n.º 7
0
 def name(self):
     """See interfaces.IBreadcrumbInfo"""
     try:
         name = IBrwsOverview(self.context).getTitle()
     except TypeError:
         name = getattr(self.context, 'title', None)
     if name is None:
         name = getattr(self.context, '__name__', None)
     if name is None and IContainmentRoot.providedBy(self.context):
         name = 'top'
     return name
Ejemplo n.º 8
0
 def name(self):
     dc = IDCDescriptiveProperties(self.context, None)
     if dc is not None:
         name = dc.title
     else:
         name = getattr(self.context, 'title', '')
     if not name:
         name = getattr(self.context, '__name__', '')
     if not name and IContainmentRoot.providedBy(self.context):
         name = _('top')
     return name
Ejemplo n.º 9
0
def findNextSite(container):
    """Return the next site.
    """
    while container:
        if IContainmentRoot.providedBy(container):
            return None
        try:
            container = get_parent(container)
            if container is None:
                return None
        except TypeError:
            return None
        if ISite.providedBy(container):
            return container
Ejemplo n.º 10
0
    def __call__(self, data):
        # authentication
        setSite(self.context)

        sm = self.context.getSiteManager()
        auth = sm.getUtility(IAuthenticationConfiglet)
        auth.installUtility()

        if IContainmentRoot.providedBy(self.context):
            auth.installPrincipalRegistry()

        for name in ('principal.users',):
            factory = sm.queryUtility(IAuthenticatorPluginFactory, name=name)
            if factory is not None:
                factory.install()
                factory.activate()

        setSite(None)
Ejemplo n.º 11
0
def get_parent(obj, default=_marker):
    """Returns the container the object was traversed via.

    Returns None if the object is a containment root.
    Raises TypeError if the object doesn't have enough context to get the
    parent.
    """
    if IContainmentRoot.providedBy(obj):
        return None

    parent = aq_parent(aq_inner(obj))
    if parent is not None:
        return parent

    if default != _marker:
        return default

    raise TypeError("Not enough context information to get parent", obj)
Ejemplo n.º 12
0
def get_parent(obj, default=_marker):
    """Returns the container the object was traversed via.

    Returns None if the object is a containment root.
    Raises TypeError if the object doesn't have enough context to get the
    parent.
    """
    if IContainmentRoot.providedBy(obj):
        return None

    parent = aq_parent(aq_inner(obj))
    if parent is not None:
        return parent

    if default != _marker:
        return default

    raise TypeError("Not enough context information to get parent", obj)
Ejemplo n.º 13
0
Archivo: utils.py Proyecto: dtgit/dtedu
def get_parent(obj):
    """Returns the container the object was traversed via.  This
    is a version of zope.traversing.api.getParent that is designed to
    handle acquisition as well.

    Returns None if the object is a containment root.
    Raises TypeError if the object doesn't have enough context to get the
    parent.
    """
    
    if IContainmentRoot.providedBy(obj):
        return None
    
    parent = getattr(obj, '__parent__', None)
    if parent is not None:
        return parent

    parent = aq_parent(aq_inner(obj))
    if parent is not None:
        return parent

    raise TypeError("Not enough context information to get parent", obj)
Ejemplo n.º 14
0
def find_next_sitemanager(site):
    """Find the closest sitemanager that is not the specified site's
    sitemanager.
    """
    container = site
    sm = None
    while sm is None:
        if IContainmentRoot.providedBy(container):
            # We are at the root site, return None
            return None

        try:
            container = get_parent(container)
            if container is None:
                return None
        except TypeError:
            # There was not enough context; probably run from a test
            return None

        if ISite.providedBy(container):
            sm = container.getSiteManager()
    return sm
Ejemplo n.º 15
0
 def isRoot(self):
     return IContainmentRoot.providedBy(self.context)
Ejemplo n.º 16
0
    def isAvailable(self):
        if not IContainmentRoot.providedBy(getSite()) and not \
            IFolder.providedBy(getSite().__parent__):
            return False

        return super(SessionConfiglet, self).isAvailable()
Ejemplo n.º 17
0
 def isRoot(self):
     return IContainmentRoot.providedBy(self.context)
Ejemplo n.º 18
0
 def crumb_parent(self):
     if getattr(self.context, '__parent__', None) is None:
         return None
     if IContainmentRoot.providedBy(self.context):
         return None
     return self.context.__parent__
Ejemplo n.º 19
0
 def crumb_parent(self):
     if getattr(self.context, '__parent__', None) is None:
         return None
     if IContainmentRoot.providedBy(self.context):
         return None
     return self.context.__parent__