|
|
||||||||||||||||||
|
|
||||||||||||||||||
![]() |
![]() |
Issue 1 - Revision 5 / June 14, 2002
|
|||
|
Customized User Folders Part I Write your own product that suits you best. - - - - - - - - - - - - By Kristoph Kirchner | May 22, 2002 Example: Adding an Email Property to Users
If you want to add extra properties to your users, you can use the existing user and user folder classes as a basis. That way, you do not need to concern yourself with the actual authentication mechanism and can minimize your code to a couple of methods.
class ExtendedUser(User.SimpleUser):
""" User with additional email property """
def __init__(self,name,password,roles,domains,email):
""" constructor method """
self.name =name
self.__ =password
self.roles =roles
self.domains=domains
self.email =email
def getEmail(self):
""" returns the user's email """
return self.email
That is all you need to do in this class. Everything else is already done in the base class SimpleUser.
If you don't declare these variables, the ones declared in the base class UserFolder will be used. This will result in them being used in the wrong context. When adding or editing a user, you will not get the forms for your user folder, i.e. the forms that contain extra fields for the email of a user, but you will get the standard forms of the Zope user folder. Because the user folder contains the methods that manage the users, you have to overwrite all methods that concern the adding and editing of users. These methods are:
Copy these methods from the UserFolder class and modify them so that they will add or change the email property for the user (lines 40, 74, 78, 84, 91, Listing 2). Listing 2: The New User Class ExtendedUser
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZopeMag is committed to bringing you the best in Zope Documentation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
Reproduction of material from any of ZopeMag's pages without prior written permission is strictly prohibited. Copyright 2003 - 2005 ZopeMag |
|