[Zope-dev] Trouble setting LoginManager default user class

Dan L. Pierson dan@sol.control.com
Wed, 17 May 2000 15:18:23 -0400 (EDT)


I'm trying to port the PTK PersistentUserSource stuff to the new
LoginManager.  A lot of things seem to be working, but I seem to have
fallen into a Catch 22:

1. UserSources.BasicUserSource defines self._defaultClass as LoginUser, where
UserSources.LoginUser is a simple RackMountable class (not a ZClass)
defined earlier in the file.

2. PTK requires DemoPortal.LoginMember, a ZClass that inherits from
LoginUser and PersistentUserSource.MemberMixin (actually, it's having
the MemberMixin stuff that's crucial).

3. Rack._v_itemConstructor is a ComputedAttribute that looks at
self._defaultClass: if it's a class, it uses it, if it's a string it
looks in Products.meta_classes[self._defaultClass] for the class to
use.

So PersistentUserSource needs to change _defaultClass to refer to
DemoPortal.LoginMember.  If I try to do it by using a
ComputedAttribute:

    def _defaultClass(self):
        c = Products.DemoPortal.LoginMember
        self._defaultClass = c
    
    _defaultClass = ComputedAttribute(_defaultClass)

I get an error traceback from an AttributeError in Rack.createItem for
_v_itemConstructor.  BTW: this also happens if I also define
_v_itemConstructor as a ComputedAttribute in PersistentUserSource.  I
need something like ComputedAttributes here, because DemoPortal
doesn't (necessarily?) exist at the time PTKDemo is installed.

If I try to do it by setting _defaultClass to 'LoginMember', it fails
because 'LoginMember' isn't in Products.meta_classes.  In fact nothing
relating to DemoPortal or any other ZClass product is in
Products.meta_classes!  The official way to get into that dictionary
appears to be to call registerBaseClass or registerZClass.
registerZClass would seem like the correct method, but the ONLY call
of this is in Products/OFSP/__init__.py for
ZClasses.ObjectManager.ZObjectManager.  Should ZClass products be registering 
themselves?

If I try to set _defaultClass in PersistentUserSource.__init__. I
can't figure out how to refer to
/Control_Panel/Products/DemoPortal/LoginMember from there.

Looks like I need more Zen.  Please enlighten me.

Dan Pierson