Commit a85ff53f authored by Evan Simpson's avatar Evan Simpson

Use allowed() instead of deprecated hasRole(), and enable proxy roles

by passing self in.
parent 2c206751
...@@ -89,7 +89,7 @@ This product provides support for Script objects containing restricted ...@@ -89,7 +89,7 @@ This product provides support for Script objects containing restricted
Python code. Python code.
""" """
__version__='$Revision: 1.35 $'[11:-2] __version__='$Revision: 1.36 $'[11:-2]
import sys, os, traceback, re, marshal import sys, os, traceback, re, marshal
from Globals import DTMLFile, MessageDialog, package_home from Globals import DTMLFile, MessageDialog, package_home
...@@ -371,20 +371,14 @@ class PythonScript(Script, Historical, Cacheable): ...@@ -371,20 +371,14 @@ class PythonScript(Script, Historical, Cacheable):
def manage_haveProxy(self,r): return r in self._proxy_roles def manage_haveProxy(self,r): return r in self._proxy_roles
def _validateProxy(self, roles=None): def _validateProxy(self, roles=None):
if roles is None: roles=self._proxy_roles if roles is None: roles = self._proxy_roles
if not roles: return if not roles: return
user=u=getSecurityManager().getUser() user = getSecurityManager().getUser()
if user is not None: if user is not None and user.allowed(self, roles):
user=user.hasRole return
for r in roles:
if r and not user(None, (r,)):
user=None
break
if user is not None: return
raise 'Forbidden', ('You are not authorized to change <em>%s</em> ' raise 'Forbidden', ('You are not authorized to change <em>%s</em> '
'because you do not have proxy roles.\n<!--%s, %s-->' 'because you do not have proxy roles.\n<!--%s, %s-->'
% (self.id, u, roles)) % (self.id, user, roles))
security.declareProtected('Change proxy roles', security.declareProtected('Change proxy roles',
'manage_proxyForm', 'manage_proxy') 'manage_proxyForm', 'manage_proxy')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment