Commit e409de5f authored by matt@zope.com's avatar matt@zope.com

Change DTMLMethod to call DTMLValidate, a minor performance enhancement

discovered for a media client.  DTMLValidate is just validate with
different arguments -- this eliminates an argument remapping step.
parent a72f5e50
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''short description __doc__='''short description
$Id: SecurityManager.py,v 1.5 2001/07/02 16:29:55 evan Exp $''' $Id: SecurityManager.py,v 1.6 2001/10/01 21:03:15 matt Exp $'''
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import ZopeSecurityPolicy, os, string import ZopeSecurityPolicy, os, string
...@@ -148,6 +148,35 @@ class SecurityManager: ...@@ -148,6 +148,35 @@ class SecurityManager:
return policy.validate(accessed, container, name, value, return policy.validate(accessed, container, name, value,
self._context, roles) self._context, roles)
def DTMLValidate(self, accessed=None, container=None, name=None,
value=None,md=None):
"""Validate access.
* THIS EXISTS FOR DTML COMPATIBILITY *
Arguments:
accessed -- the object that was being accessed
container -- the object the value was found in
name -- The name used to access the value
value -- The value retrieved though the access.
md -- multidict for DTML (ignored)
The arguments may be provided as keyword arguments. Some of these
arguments may be ommitted, however, the policy may reject access
in some cases when arguments are ommitted. It is best to provide
all the values possible.
"""
policy=self._policy
if policy is None: policy=_defaultPolicy
return policy.validate(accessed, container, name, value,
self._context, _noroles)
def validateValue(self, value, roles=_noroles): def validateValue(self, value, roles=_noroles):
"""Convenience for common case of simple value validation. """Convenience for common case of simple value validation.
""" """
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""DTML Method objects.""" """DTML Method objects."""
__version__='$Revision: 1.67 $'[11:-2] __version__='$Revision: 1.68 $'[11:-2]
import History import History
from Globals import HTML, DTMLFile, MessageDialog from Globals import HTML, DTMLFile, MessageDialog
...@@ -180,6 +180,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -180,6 +180,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
security=getSecurityManager() security=getSecurityManager()
security.addContext(self) security.addContext(self)
self.validate = security.DTMLValidate
try: try:
if client is None: if client is None:
...@@ -197,7 +198,9 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -197,7 +198,9 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
self.ZCacheable_set(r) self.ZCacheable_set(r)
return r return r
finally: security.removeContext(self) finally:
security.removeContext(self)
del self.validate
have_key=RESPONSE.headers.has_key have_key=RESPONSE.headers.has_key
if not (have_key('content-type') or have_key('Content-Type')): if not (have_key('content-type') or have_key('Content-Type')):
......
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