[Checkins] SVN: zope.security/trunk/ Install decorated security checker support on LocationProxy from the

Christian Theune ct at gocept.com
Thu Jan 29 14:16:16 EST 2009


Log message for revision 95518:
  Install decorated security checker support on LocationProxy from the
  outside.
  
  

Changed:
  U   zope.security/trunk/CHANGES.txt
  U   zope.security/trunk/buildout.cfg
  A   zope.security/trunk/src/zope/security/location.py
  U   zope.security/trunk/src/zope/security/tests/test_decorator.py

-=-
Modified: zope.security/trunk/CHANGES.txt
===================================================================
--- zope.security/trunk/CHANGES.txt	2009-01-29 19:16:08 UTC (rev 95517)
+++ zope.security/trunk/CHANGES.txt	2009-01-29 19:16:15 UTC (rev 95518)
@@ -5,6 +5,9 @@
 3.6.0 - unreleased
 ------------------
 
+- Install decorated security checker support on LocationProxy from the
+  outside.
+
 - Added support to bootstrap on Jython.
 
 - Moved the `protectclass` module from `zope.app.security` to this

Modified: zope.security/trunk/buildout.cfg
===================================================================
--- zope.security/trunk/buildout.cfg	2009-01-29 19:16:08 UTC (rev 95517)
+++ zope.security/trunk/buildout.cfg	2009-01-29 19:16:15 UTC (rev 95518)
@@ -1,5 +1,5 @@
 [buildout]
-develop = .
+develop = . ../zope.location
 parts = test py
 versions = versions
 

Added: zope.security/trunk/src/zope/security/location.py
===================================================================
--- zope.security/trunk/src/zope/security/location.py	                        (rev 0)
+++ zope.security/trunk/src/zope/security/location.py	2009-01-29 19:16:15 UTC (rev 95518)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Corporation and Contributors.
+# 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.
+#
+##############################################################################
+"""Make LocationProxies security-aware.
+
+This module does a somewhat hard hack and is intended to be refactored
+at some point, but helps avoiding to have zope.location depend on
+zope.security.
+
+We start with an unlocated class that will be wrapped by a
+LocationProxy:
+
+>>> class Unlocated(object):
+...     a = 'a'
+
+>>> unlocated = Unlocated()
+
+Now we create a location proxy around it:
+
+>>> from zope.location.location import LocationProxy
+>>> located = LocationProxy(unlocated)
+
+We define a checker for the unlocated object, which will also be
+used by the security proxy as the LocationProxy defines
+__Security_checker__:
+
+>>> from zope.security.checker import NamesChecker, defineChecker
+>>> unlocatedChecker = NamesChecker(['a'])
+>>> defineChecker(Unlocated, unlocatedChecker)
+
+>>> from zope.security.proxy import ProxyFactory
+>>> secure_located = ProxyFactory(located)
+>>> secure_located.a
+'a'
+
+"""
+
+import zope.location.location
+from zope.security.decorator import DecoratedSecurityCheckerDescriptor
+
+zope.location.location.LocationProxy.__Security_checker__ = (
+    DecoratedSecurityCheckerDescriptor())


Property changes on: zope.security/trunk/src/zope/security/location.py
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: zope.security/trunk/src/zope/security/tests/test_decorator.py
===================================================================
--- zope.security/trunk/src/zope/security/tests/test_decorator.py	2009-01-29 19:16:08 UTC (rev 95517)
+++ zope.security/trunk/src/zope/security/tests/test_decorator.py	2009-01-29 19:16:15 UTC (rev 95518)
@@ -21,6 +21,7 @@
 def test_suite():
     suite = doctest.DocTestSuite()
     suite.addTest(doctest.DocTestSuite('zope.security.decorator'))
+    suite.addTest(doctest.DocTestSuite('zope.security.location'))
     return suite
 
 



More information about the Checkins mailing list