[Zope] FW: Change roles with python

Dieter Maurer dieter@handshake.de
Sat, 31 May 2003 11:19:36 +0200


Andrew R. Halko wrote at 2003-5-29 15:21 -0400:
 > Well I want to give users with a certain IP range access to objects that
 > regular visitors are not.  I have a very large organization and I want
 > everyone in the organization to be able to view certain content and they
 > all will be within an IP range.  Then I have another level of content
 > that a user must login to view.  Asking hundreds of people to register
 > and also administrate them is nightmare/impossible.

The built-in UserFolder has such a feature:

  When you define a user with empty password and domain restriction,
  then requests coming from this domain are associated with this
  user provided it provides the required roles.

This feature is now disabled by default but can be enabled on
an instance base (look at the code, for details: --> "AccessControl/User.py").


 > So I set up two Roles Intranet User and Internal User.  My objects have
 > a state associated with them which is also associated to the various
 > roles.  Now I would like to use an access rule to check the users IP
 > address and then set the role for them to be an Intranet User.

This will not work (easily):

  Roles are managed by the User object.
  A User object is only created after traversal finished,
  there is not yet a User object when AccessRules are executed.


Dieter