Commit 0cefd1ee authored by Evan Simpson's avatar Evan Simpson

Fix SafeMapping

parent 55506c2e
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
An implementation of a generic TALES engine An implementation of a generic TALES engine
""" """
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import re, sys, ZTUtils import re, sys, ZTUtils
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
...@@ -140,21 +140,17 @@ class SafeMapping(MultiMapping): ...@@ -140,21 +140,17 @@ class SafeMapping(MultiMapping):
able to read any value. able to read any value.
''' '''
__allow_access_to_unprotected_subobjects__ = 1 __allow_access_to_unprotected_subobjects__ = 1
def __init__(self, *dicts): push = pop = None
self._mm = apply(MultiMapping, dicts) def _push(self, ob):
def __getitem__(self, index): MultiMapping.push(self, ob)
return self._mm[index] def _pop(self, *args):
def __len__(self): if args:
return len(self._mm) return apply(MultiMapping.pop, (self,) + args)
def _push(self, arg): else:
self._mm.push(arg) return MultiMapping.pop(self)
def _pop(self):
return self._mm.pop()
def has_key(self, key):
return self._mm.has_key(key)
def has_get(self, key): def has_get(self, key):
v = self._mm.get(key, self) v = self.get(key, _marker)
if v is self: if v is _marker:
return 0, None return 0, None
else: else:
return 1, v return 1, v
......
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