Added persistent lists, mappings and sets handling to 'unproxied' function
authorThierry Florac <tflorac@ulthar.net>
Wed, 02 Dec 2009 23:10:48 +0100
changeset 24 d8b0b7625f9c
parent 23 d6a38a66c8a6
child 25 7d4d896fd1ce
Added persistent lists, mappings and sets handling to 'unproxied' function
ztfy/utils/security.py
--- a/ztfy/utils/security.py	Sat Oct 10 00:19:49 2009 +0200
+++ b/ztfy/utils/security.py	Wed Dec 02 23:10:48 2009 +0100
@@ -14,12 +14,15 @@
 
 
 # import standard packages
+from persistent.list import PersistentList
+from persistent.dict import PersistentDict
 
 # import Zope3 interfaces
 
 # import local interfaces
 
 # import Zope3 packages
+from zc.set import Set
 from zope.security.proxy import removeSecurityProxy
 
 # import local packages
@@ -27,14 +30,18 @@
 
 def unproxied(value):
     """Remove security proxies from given value ; if value is a list or dict, all elements are unproxied"""
-    if isinstance(value, list):
+    if isinstance(value, (list, PersistentList)):
         result = []
         for v in value:
             result.append(unproxied(v))
-    elif isinstance(value, dict):
+    elif isinstance(value, (dict, PersistentDict)):
         result = value.copy()
         for v in value:
             result[v] = unproxied(value[v])
+    elif isinstance(value, (set, Set)):
+        result = []
+        for v in value:
+            result.append(unproxied(v))
     else:
         result = removeSecurityProxy(value)
     return result