[Zope] RE: What method do I use to check access?

Howard Clinton Shaw III shawh@sths.org
Thu, 27 May 1999 06:45:17 -0500


On Wed, 26 May 1999, Jay, Dylan wrote:
> The problem with your solution is that it doesn't take into account aquired
> permissions.
> 
> >for i in AUTHENTICATED_USER.getRoles():
> >	if i in SomeObject._View_Permission.getRoles():
> >		return 1
> >return 0

Oops. Think I just sent a message to the list which you had already answered.
OK, with respect to acquisition, the Permission object explicitly abandons
(assuming I understand this right) acquisition by setting the obj it gets equal
to obj.aq_base if such exists. Now this would be a severe kludge, but since
encapsulation in python is largely imaginary, you could try this:

SomeObject._View_Permission=obj
for i in AUTHENTICATED_USER.getRoles():
	obj=SomeObject._View_Permission.obj
	if i in SomeObject._View_Permission.getRoles():
		SomeObject._View_Permission=obj
		return 1
SomeObject._View_Permission=obj
return 0

Or conceivably:

P = Permission('View','',SomeObject)
P.obj=SomeObject
for i in AUTHENTICATED_USER.getRoles():
	if i in P.getRoles():
		return 1

Good luck.
--
Howard Clinton Shaw III - Grum
St. Thomas High School
#include "disclaimer.h"