[Zope3-Users] principal folder subclassing

Pete Taylor baldtrol at gmail.com
Tue Apr 11 03:45:37 EDT 2006


hi all...  i have a question about principalfolder derivatives. 
weirdest thing keeps happening...

I have a class that i derived from
zope.app.authentication.principalfolder.PrincipalFolder.  I've added
it to my PAU, even created principals in it without trouble.  but i've
been trying (and failing, currently) to create a login page that lets
me log in with that particular user.  i'm still working on that
though, and may send other questions about it later, but for now, i
found something else strange.

i was trying to add roles to the principal i have in my folder.  going
to grant, i hit "search" on the slot for ConsumerPrincipalFolder, and
it gave me a system error.  i thought that was strange, so i went back
and put in specific criteria.  still, same error.  this is a snip of
the relevant bits:

 Module zope.app.form.browser.source, line 244, in __call__
    result.append('      <div class="queryresults">\n%s' %
  Module zope.app.form.browser.source, line 254, in _renderResults
    for value in results:
  Module zope.app.authentication.authentication, line 175, in search
    for id in self.authplugin.search(query, start, batch_size):
  Module zope.app.authentication.principalfolder, line 300, in search
    if (search in value.title.lower() or
AttributeError: 'NoneType' object has no attribute 'lower'

just to make sure, i put some debugging into principalfolder, raising
what self and query were at the time it hit line 300, and sure enough,
it was my principal folder implementation, and my query just as i
expected it.  so i pulled that debugging out, and went into zopectl
debug.  i got my principal folder from the site manager, and tried to
iterate over "cpf.values()"...  the output of my attempts is below:

>>> root = debugger.root()
>>> from zope.app import zapi
>>> sm = zapi.getSiteManager(context=root)
>>> cpf = sm['tools']['PluggableAuthentication']['ConsumerPrincipalFolder']
>>> for i, value in enumerate(cpf.values()):
...     print i, value
...
0 <personium.principal.ConsumerPrincipal object at 0xb7f03aec>
>>> query = {'search': 'baldtrol at gmail.com'}
>>> generatorObj = cpf.search(query)
>>> for obj in generatorObj:
...     print obj
...
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/opt/zope3/lib/python/zope/app/authentication/principalfolder.py",
line 300, in search
    if (search in value.title.lower() or
AttributeError: 'NoneType' object has no attribute 'lower'

now, what i don't get is that cpf isn't 'NoneType"...  all search does
is take self, query, start, and batch_size and return a generator. 
cpf can't possibly be "NoneType" or it wouldn't have a method 'search"
to throw an error.

so i'm confused.  i tried it with the standard PrincipalFolder, but it
works fine, which isn't surprising.  but my ConsumerPrincipalFolder is
derived from PrincipalFolder...  only thing it does differently is
hold my ConsumerPrincipal's, which needed to be slightly different
than standard principals.

does anyone have any idea where i should start here?  i have other
issues to solve surrounding actually creating login pages and viewlets
and such, but in troubleshooting those, i ran into this...

Thanks for any help!
Pete

--
"All guilt is relative, loyalty counts, and never let your conscience
be your guide."
  - Lucas Buck, American Gothic


More information about the Zope3-users mailing list