Commit dd7af1b9 authored by Julien Muchembled's avatar Julien Muchembled

Add support for TALES guard on PythonScript/ExternalMethod

parent 81de15db
...@@ -2,27 +2,10 @@ ...@@ -2,27 +2,10 @@
<dtml-var manage_tabs> <dtml-var manage_tabs>
<form action="manage_setGuard" method="POST"> <form action="manage_setGuard" method="POST">
<table> <dtml-with getGuard>
<dtml-var guardForm>
<tr> </dtml-with>
<th align="left" valign="top">Guard</th> <input type="submit" name="submit" value="Save changes" />
<td>
<dtml-with getGuard>
<table>
<tr>
<th align="left">Permission(s)</th>
<td><input type="text" name="guard_permissions" value="&dtml-getPermissionsText;" /></td>
<th align="left">Role(s)</th>
<td><input type="text" name="guard_roles" value="&dtml-getRolesText;" /></td>
<th align="left">Group(s)</th>
<td><input type="text" name="guard_groups" value="&dtml-getGroupsText;" /></td>
</tr>
</table>
</dtml-with>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Save changes" />
</form> </form>
<dtml-var manage_page_footer> <dtml-var manage_page_footer>
...@@ -14,6 +14,7 @@ from Products.DCWorkflow.Guard import Guard ...@@ -14,6 +14,7 @@ from Products.DCWorkflow.Guard import Guard
from Products.PythonScripts.PythonScript import PythonScript from Products.PythonScripts.PythonScript import PythonScript
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from .. import _dtmldir from .. import _dtmldir
from ..Utils import createExpressionContext
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.class_init import InitializeClass from AccessControl.class_init import InitializeClass
from AccessControl.PermissionRole import rolesForPermissionOn from AccessControl.PermissionRole import rolesForPermissionOn
...@@ -121,8 +122,6 @@ def getRoles(ob): ...@@ -121,8 +122,6 @@ def getRoles(ob):
def _checkGuard(guard, ob): def _checkGuard(guard, ob):
# returns 1 if guard passes against ob, else 0. # returns 1 if guard passes against ob, else 0.
# TODO : implement TALES evaluation by defining an appropriate
# context.
if guard.permissions: if guard.permissions:
# Require at least one role for required roles for the given permission. # Require at least one role for required roles for the given permission.
u_roles = getRoles(ob) u_roles = getRoles(ob)
...@@ -155,7 +154,7 @@ def _checkGuard(guard, ob): ...@@ -155,7 +154,7 @@ def _checkGuard(guard, ob):
break break
else: else:
return 0 return 0
return 1 return guard.expr is None or guard.expr(createExpressionContext(ob))
def checkGuard(aq_base=aq_base, aq_parent=aq_parent, _checkGuard=_checkGuard): def checkGuard(aq_base=aq_base, aq_parent=aq_parent, _checkGuard=_checkGuard):
def checkGuard(self, _exec=False): def checkGuard(self, _exec=False):
......
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