Ejemplo n.º 1
0
    def logout(self, request):
        notify(PrincipalLoggingOutEvent(request.principal))

        if isReadonly():
            storage = getUtility(IPrincipalInfoStorage, 'ram')
        else:
            storage = IPrincipalInfoStorage(self)

        storage.clear(self, request)
Ejemplo n.º 2
0
    def authenticate(self, request):
        if isReadonly():
            storage = getUtility(IPrincipalInfoStorage, 'ram')
        else:
            storage = IPrincipalInfoStorage(self)

        # use cached PrincipalInfo
        try:
            info = storage.get(self, request)
            if info is not None:
                principal = Principal(
                    self.prefix + info.id, info.title, info.description)
                notify(AuthenticatedPrincipalCreated(
                        self, principal, info, request))
                return principal
        except PrincipalInitializationFailed, err:
            storage.clear(self, request)
            cache.loginMessage = err.message