durusmail: quixote-users: Notes on Webware's User classes
Notes on Webware's User classes
2002-05-21
2002-05-21
2002-05-22
Notes on Webware's User classes
akuchlin@mems-exchange.org
2002-05-21
In the past it's been suggested that there should be a standard user
framework for use with Quixote.  We implemented users and groups for
the MEMS Exchange; Greg had to do it again for SPLAT!; I'm going to
have to do it again for Woolgather; and there are few Web-based
projects that won't have user logins at some point.

The Quixote way wouldn't be to write some purely Quixote-specific
modules, though.  Instead there should be a generic User object that
can be subclassed and made persistent in some way.  That way other Web
frameworks could (at least in theory) use the same classes.

As part of this, we should check if anyone has already implemented
code we can use.  I took a look at two candidates.

* Zope has machinery in the AccessControl package, with a User class.
Objects then have an __ac_roles__ attribute listing the roles
required to access it.  Unfortunately the AccessControl package also
contains Zope-specific things such as the management screens, and
disentangling this seems difficult, because it's just under 4000
lines long.  I don't think the Zope code is usable.  (I couldn't
find the equivalent code in the Zope3 CVS tree, so I assume they
haven't been implemented for Zope3 yet.)

* Webware includes a pre-alpha set of classes called UserKit.  The
User class stores an ID, password, and last access, last login, and
creation times.  A UserRole subclass adds a list of roles, and a
.playsRole() method so you can do 'if user.playsRole("manager"):
...do stuff...'.

Roles are stored as strings, and a Role class is used to store an
additional description.  A HierRole allows a hierarchy of roles, so
you could have a role of 'animal' with a subrole of 'mammal'.  There
doesn't seem to be any concept of groups, so there's no easy way to
get all people with a given role.

There's a bit of extra code to store data using MiddleKit, Webware's
object-relational mapper, but not so much code that it would get in
the way.  UserKit seems usable as a framework, though the naming
convention (playsRole(), setManager()) doesn't mesh well with
Quixote's use of underscores.

I think UserKit would be somewhat usable, but it might be easier just
to factor out the basic functionality from the MEMS Exchange's User
and Group classes.

--amk




reply