Parra
> While working on the identity framework for TurboGears, I've been
> trying to come up with a clean way to allow developers to provide
> their own identity model classes. One thought was to load the name of
> the developer's preferred User class and instantiate that instead of
> the default User class.
I discovered a while back the perfect way to do this. Have a global in
your Inheritance module called _User or whatever, and provide a
function or class method to set this variable. Then I should be able
to do something like:
inheritance.userClass(MyUserClass)
inheritance.groupClass(MyGroupClass)
inheritance.roleClass(MyRoleClass)
Internally, you create new instances (or manage instances of) _User,
_Group, and _Role, or whatever you happen to use.
> All works great so far. But then I add an override for the User class
> to the config file to specify MyUser instead of User. MyUser is
> defined as:
>
> class MyUser(User):
> # additional package specific stuff
You simply can not do that with SQLObject classes unless you specify
the top-most one as being an InheritableSQLObject. Even then, this
isn't a very elegant or efficient way of organizing the data, as it
creates two tables (one for the base class, one for MyUser) and
performs two lookups for each .get(). Simple overriding of a "pointer"
to a class would probably be best. IMHO. YMMV. &c. ;)