[Zope-dev] Trouble setting LoginManager default user class
Steve Alexander
steve@cat-box.net
Wed, 17 May 2000 22:01:31 +0100
"Dan L. Pierson" wrote:
>
> 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.
The _defaultClass only needs to become DemoPortal.LoginMember before a
Portal's LoginManager instance is created.
Therefore, you can leave the _defaultClass as LoginUser until the
"install" method of DemoPortalBase is called (PTKDemo/Portal.py).
In the "install" method, after creating a MembersClass(), set its
_defaultClass to LoginMember.
...or have I misunderstood something important? :-)
--
Steve Alexander
Software Engineer
Cat-Box limited