Hello If have a simple script (pyhton) called "test.py". I'd like to test the permission with "has_permission". The print out is the following: Anonymous User Permission on test.py not ok But this is obviously wrong, because I can execute the script. This is the code: <cut> from AccessControl import getSecurityManager obj = 'test.py' user = getSecurityManager().getUser() print user if user.has_permission('View', obj): print 'Permission on '+obj+' ok' else: print 'Permission on '+obj+' not ok' return printed </cut> What I'm doing wrong? Regards Dieter PS: System is: Zope Version (Zope 2.6.1 (binary release, python 2.1, win32-x86), python 2.1.3, win32) Python Version 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] But doesn't run also on Linux
Hello Thanks to Alexis Roda, I've found the solution: <cut> from AccessControl import getSecurityManager obj_name = 'test.py' obj_id = getattr(context, obj_name) user = getSecurityManager().getUser() print user if user.has_permission('View', obj_id): print 'Permission on '+obj_name+' ok' else: print 'Permission on '+obj_name+' not ok' return printed </cut> The problem was, that I've checked against a string. Regards Dieter
participants (1)
-
Dieter Fischer