Hi there, I need to write a Python script (or an Extension, if the former isn't possible) that will enumerate a list of owners (including those with local ownership roles) for a given context. The code must work in an anonymous security context. Unfortunately, it looks like the the getOwner method of the Owned mixin class is very useful as it won't work in an anonymous security context. Can someone please lend assistance? Thanks, -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
On Wed, Aug 28, 2002 at 04:29:29PM -0700, Michael S. Fischer wrote:
local ownership roles) for a given context. The code must work in an anonymous security context.
Do you mean that the script must run with effective anonymous security permissions? Or that it must be runnable by anonymous users? -- Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
On Wed, Aug 28, 2002 at 04:36:57PM -0700, Paul Winkler wrote:
Do you mean that the script must run with effective anonymous security permissions? Or that it must be runnable by anonymous users?
The latter. My apologies for misusing the terminology. -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
Unfortunately, it looks like the the getOwner method of the Owned mixin class is very useful as it won't work in an anonymous security context.
Right, but if you put that in a Python Script say, and give it the proxy role of Manager... -- Andy McKay Agmweb Consulting http://www.agmweb.ca
On Wed, Aug 28, 2002 at 04:45:01PM -0700, Andy McKay wrote:
Unfortunately, it looks like the the getOwner method of the Owned mixin class is very useful as it won't work in an anonymous security context.
Right, but if you put that in a Python Script say, and give it the proxy role of Manager...
I just tried. I created a Python Script called fileOwner: return context.getOwner(1) I then gave the script a proxy role of Manager, and then tried to call it (http://host/path/fileOwner), and I got a 401 in response. -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
Try owner_info rather than getOwner, the former needs View management screen permission. Something like: obj = context.restrictedTraverse('/Test') # get the Test object return obj.owner_info() -- Andy McKay Agmweb Consulting http://www.agmweb.ca ----- Original Message ----- From: "Michael S. Fischer" <michael@dynamine.net> To: "Andy McKay" <andy@agmweb.ca> Cc: <zope@zope.org> Sent: Wednesday, August 28, 2002 4:56 PM Subject: Re: [Zope] Enumerating owners
On Wed, Aug 28, 2002 at 04:45:01PM -0700, Andy McKay wrote:
Unfortunately, it looks like the the getOwner method of the Owned mixin class is very useful as it won't work in an anonymous security context.
Right, but if you put that in a Python Script say, and give it the proxy role of Manager...
I just tried. I created a Python Script called fileOwner:
return context.getOwner(1)
I then gave the script a proxy role of Manager, and then tried to call it (http://host/path/fileOwner), and I got a 401 in response.
-- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
On Wed, Aug 28, 2002 at 05:11:33PM -0700, Andy McKay wrote:
Try owner_info rather than getOwner, the former needs View management screen permission.
Something like:
obj = context.restrictedTraverse('/Test') # get the Test object return obj.owner_info()
Thanks. That works for the primary owner. How about enumerating local ownership roles? -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
On Wed, Aug 28, 2002 at 05:30:43PM -0700, Michael S. Fischer wrote:
On Wed, Aug 28, 2002 at 05:11:33PM -0700, Andy McKay wrote:
Try owner_info rather than getOwner, the former needs View management screen permission.
Something like:
obj = context.restrictedTraverse('/Test') # get the Test object return obj.owner_info()
Thanks. That works for the primary owner. How about enumerating local ownership roles?
First thing that comes to mind is something like (untested): owners = [] for owner in some_list_of_users: if owner.has_role(['Owner'], object): owners.append(owner) return owners But how to get the list of users? You could just get context.acl_users.objectValues(), but that won't be adequate if you have other user folders higher up. Hmmm.... Well, the manage_ListLocalRoles method does it, so let's look it up in the source code. (goes and looks for the relevant source) ... aha! it's in lib/python/AccessControl/dtml/listLocalRoles.dtml, and it's a call like this: <dtml-in get_valid_userids> which some grepping reveals is defined in lib/python/AccessControl/Role.py, right next to this (in class RoleManager): def users_with_local_role(self, role): ... so the answer is, do this: context.users_with_local_role('Owner') And the real answer is, "Use the source, luke!" ;) --PW Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
On Wed, Aug 28, 2002 at 05:30:43PM -0700, Michael S. Fischer wrote:
Thanks. That works for the primary owner. How about enumerating local ownership roles?
Figured it out, I had to create Yet Another Extension: def tpd_get_local_roles(self): return self.get_local_roles() This also returns the normal owner. Why doesn't Zope expose more of its API? I can't possibly be the only person interested in this stuff. I can keep making HOWTOs to compensate for the Mack-truck-sized holes in the public API specification, but it seems kinda silly given that Zope is supposed to be mature. -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
participants (3)
-
Andy McKay -
Michael S. Fischer -
Paul Winkler