A simple question, how can I determine the Owner of a ZClass instance (or any Zope object for that matter)? My users create instances of a Seminar ZClass. I did not create a SubmittedBy property (which I would fill from AUTHENTICATED_USER.getUserName()) thinking that I could easily extract this from the Owner role. I just can't see how to do it. Cheers, Darran.
Here's one way. There's probably an easier one. <dtml-in get_local_roles> <dtml-if "'Owner' in _['sequence-item']"> Owner: <dtml-var sequence-key> </dtml-if> <dtml-else> No Owner </dtml-in> or in Python: def getOwner(ob): for userid, roles in ob.get_local_roles(): if 'Owner' in roles: return userid -jfarr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hi! I'm a signature virus. Copy me into your .sig to join the fun! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----- Original Message ----- From: Darran Edmundson <Darran.Edmundson@anu.edu.au> To: zope <zope@zope.org> Sent: Thursday, March 23, 2000 3:26 PM Subject: [Zope] determining Owner of an object?
A simple question, how can I determine the Owner of a ZClass instance (or any Zope object for that matter)?
<dtml-in get_local_roles>
I tried sticking <dtml-var get_local_roles> in a dtml document and got a blank list back even though I know I've got some local roles. Also, where did you find out about this? I haven't found it documented anywhere... <dtml-var "AUTHENTICATED_USER.getRoles()"> is also not too useful since it only returns roles where the user object is defined, ie no local roles... What am I doing wrong? Chris
I tried sticking <dtml-var get_local_roles> in a dtml document and got a blank list back even though I know I've got some local roles.
Hmm. That's not what happens for me. I get something like: [('admin', ['Owner'])] How do you know you've got some local roles? Also, is this a DTML document or DTML method, because methods seem to acquire the roles from their container.
Also, where did you find out about this? I haven't found it documented anywhere...
It's all in AccessControl/Role.py. IMO the documentation is just a good place to figure out where to start reading the code. ;) -jfarr
participants (3)
-
Chris Withers -
Darran Edmundson -
Jonothan Farr