[Zope] adding properties and getting roles in python

Chris Hoefler hoeflerb@reed.edu
01 Jul 2002 22:41:49 -0600


Hi Folks,

Part of the Zope site I am trying to develop involves collecting and
storing membership information. I have run into a couple of snags,
though. I have a form for adding users that calls a python script. The
script is responsible for creating the user in acl_users, creating a
personal folder for the user, and setting properties on the folder. So
the code looks like this:

context.acl_users.userFolderAddUser(username, pass, roles, 0)
context.user_folders.manage_addFolder(username,'',0,0)
context.user_folders.username.manage_addProperty('First Name', fname,
'string')

The problem is with the third line. When the script is called I get an
AttributeError on username. I believe this is because username is a
variable containing the actual name of the folder. The interpreter
doesn't know this and I can't figure out how to tell it. I have looked
through the Zope API documentation and I haven't been able to find a
function analagous to getObject(id=None) or some such thing.

My second problem involves listing the roles of a user in acl_users. I
execute the following code:

context.acl_users.getUser('test').getRoles()

and I get a list back. But the list contains "Authenticated" in addition
to the actual roles of the user. I haven't logged in as this user, I am
running the script as the Manager user (admin), so getRoles() shouldn't
return "Authenticated" right? Does anybody know what is going on with
and/or how to solve either of these problems?

-Chris