--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ztfy/utils/security.py Sat Jan 10 00:35:35 2009 +0100
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2008 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id: $
+"""
+
+__version__ = "$Revision: $"
+__release__ = "$Id: $"
+__docformat__ = "restructuredtext"
+
+# import standard packages
+
+# import Zope3 interfaces
+
+# import local interfaces
+
+# import Zope3 packages
+from zope.security.proxy import removeSecurityProxy
+
+# import local packages
+
+
+def unproxied(value):
+ """Remove security proxies from given value ; if value is a list or dict, all elements are unproxied"""
+ if isinstance(value, list):
+ result = []
+ for v in value:
+ result.append(removeSecurityProxy(v))
+ elif isinstance(value, dict):
+ result = value.copy()
+ for v in value:
+ result[v] = removeSecurityProxy(value[v])
+ else:
+ result = removeSecurityProxy(value)
+ return result