[Checkins] SVN: zope.publisher/trunk/ Move IPrincipal->ILoggingInfo here from zope.app.security.

Dan Korostelev nadako at gmail.com
Wed Mar 11 17:07:13 EDT 2009


Log message for revision 97915:
  Move IPrincipal->ILoggingInfo here from zope.app.security.

Changed:
  U   zope.publisher/trunk/CHANGES.txt
  U   zope.publisher/trunk/src/zope/publisher/configure.zcml
  A   zope.publisher/trunk/src/zope/publisher/principallogging.py
  A   zope.publisher/trunk/src/zope/publisher/tests/test_principallogging.py

-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt	2009-03-11 20:57:37 UTC (rev 97914)
+++ zope.publisher/trunk/CHANGES.txt	2009-03-11 21:07:13 UTC (rev 97915)
@@ -4,7 +4,9 @@
 3.6.2 (unreleased)
 ------------------
 
-- ...
+- Add an adapter from ``zope.security.interfaces.IPrincipal`` to
+  ``zope.publisher.interfaces.logginginfo.ILoggingInfo``. It was moved
+  from ``zope.app.security`` as a part of refactoring process. 
 
 3.6.1 (2009-03-09)
 ------------------

Modified: zope.publisher/trunk/src/zope/publisher/configure.zcml
===================================================================
--- zope.publisher/trunk/src/zope/publisher/configure.zcml	2009-03-11 20:57:37 UTC (rev 97914)
+++ zope.publisher/trunk/src/zope/publisher/configure.zcml	2009-03-11 21:07:13 UTC (rev 97915)
@@ -31,6 +31,12 @@
       provides="zope.publisher.interfaces.IDefaultSkin"
       />
 
+  <adapter
+      factory=".principallogging.PrincipalLogging"
+      provides=".interfaces.logginginfo.ILoggingInfo"
+      for="zope.security.interfaces.IPrincipal"
+      />
+
   <apidoc:bookchapter
       zcml:condition="have apidoc"
       id="zopepublisherhttpresults.txt"

Added: zope.publisher/trunk/src/zope/publisher/principallogging.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/principallogging.py	                        (rev 0)
+++ zope.publisher/trunk/src/zope/publisher/principallogging.py	2009-03-11 21:07:13 UTC (rev 97915)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""An adapter from zope.security.interfaces.IPrincipal to
+zope.publisher.interfaces.logginginfo.ILoggingInfo.
+
+$Id$
+"""
+from zope.component import adapts
+from zope.interface import implements
+from zope.publisher.interfaces.logginginfo import ILoggingInfo
+from zope.security.interfaces import IPrincipal
+
+class PrincipalLogging(object):
+
+    adapts(IPrincipal)
+    implements(ILoggingInfo)
+
+    def __init__(self, principal):
+        self.principal = principal
+
+    def getLogMessage(self):
+        return str(self.principal.id)


Property changes on: zope.publisher/trunk/src/zope/publisher/principallogging.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: zope.publisher/trunk/src/zope/publisher/tests/test_principallogging.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_principallogging.py	                        (rev 0)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_principallogging.py	2009-03-11 21:07:13 UTC (rev 97915)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Test for PrincipalLogging adapter.
+
+$Id$
+"""
+import unittest
+from zope.interface.verify import verifyObject
+
+class PrincipalStub(object):
+
+    id = 42
+
+class TestPrincipalLogging(unittest.TestCase):
+
+    def test_interface(self):
+        from zope.publisher.interfaces.logginginfo import ILoggingInfo
+        from zope.publisher.principallogging import PrincipalLogging
+        principal = PrincipalStub()
+        pl = PrincipalLogging(principal)
+        verifyObject(ILoggingInfo, pl)
+
+    def test_getLogMessage(self):
+        from zope.publisher.principallogging import PrincipalLogging
+        principal = PrincipalStub()
+        pl = PrincipalLogging(principal)
+        self.assertEquals(pl.getLogMessage(), '42')
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestPrincipalLogging))
+    return suite


Property changes on: zope.publisher/trunk/src/zope/publisher/tests/test_principallogging.py
___________________________________________________________________
Added: svn:keywords
   + Id



More information about the Checkins mailing list