[Zope3-Users] IPluggableAuthentication -- 'new style'
authentication problem
Christian Lueck
christian.lueck at ruhr-uni-bochum.de
Thu Oct 13 12:18:56 EDT 2005
Hi list!
I'd like to write a custom principal source for signup analgous to
chapter 19.2 of Philipp's book BUT based on the 'new style'
authentication (zope.app.authentication instead of the old
zope.app.pluggableauth). But I'm totally stuck with it.
I have registered a Pluggable Authentication Utility (PAU) via ZMI, then
created a principal folder and principal information. I've done that for
the global site (root folder) and a local site (called 'subfolder'). All
this works fine: I can log in as the new ZMI-created users.
But writing a custom pau thing really sucks!
How do I get the PAUtility? (or the several PAUs?)
paus =
zapi.getAllUtilitiesRegisteredFor(zope.app.authentication.interfaces.IPluggableAuthentication)
returns no pau at all, neither in the context of the root-folder, nor in
the context of the local site called 'subfolder'. len(paus) is allways 0.
Note: Since I don't know how to get into a site's context with the
debugger (zopectl debug) I've written a very simple view, that shows me
the length of the list returned by
zapi.getAllUtilitiesRegisteredFor(...) and other things. See below. --
That's a personal-knowledge-lack-workaround because I don't really
understand how to use zope.app.component.hooks.setSite() from the
debugger ;( But it makes sure, that I'm not in a global context in that
particular sense, that only zcml-registered utilities are returned. (Jim
told me on IRC about that problem, thanks again!) To control this, the
'aus'-method of the viewclass (see below) returns different values
depending on the site (root-folder: 2 and 'subfolder': 3).
I'm totally stuck and every hint is welcome!
Kind regards,
Christian
from zope.app.component.hooks import getSite
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app import zapi
from zope.app.authentication.interfaces import IPluggableAuthentication
from zope.app.security.interfaces import IAuthentication
class ExperimentView:
template = ViewPageTemplateFile('experiment.pt')
def site(self):
return getSite()
def siteName(self):
s = getSite()
return s.__name__
def paus(self):
paus = zapi.getAllUtilitiesRegisteredFor(IPluggableAuthentication)
return len(paus)
def aus(self):
aus = zapi.getAllUtilitiesRegisteredFor(IAuthentication)
return len(aus)
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
return self.template()
More information about the Zope3-users
mailing list