[Zope-CMF] How to access user info stored by Zope?

Dieter Maurer dieter@handshake.de
Fri, 13 Jun 2003 22:35:32 +0200


smita  singh wrote at 2003-6-13 10:58 -0000:
 > How can I access the username and their roles w.r.t different objects which are stored by Zope?

The "User" object has methods "getUserName" and "getRolesInContext"
to provide the requested information.


The easiest way to access the user object is "REQUEST.AUTHENTICATED_USER".
Some people say this is deprecated but the alternative is an
API mess:

  In DTML, you can use "_.getSecurityUser()",

  in PythonScripts: 
     from AccessControl import getSecurityManager
     ...
     getSecurityManager().getUser()

  and in ZPT: "user"


Dieter