[Checkins] SVN: zope.app.publication/trunk/ ZopePublication now annotates the request with the connection to the main

Alex Smith asmith at zope.com
Tue Sep 16 11:06:24 EDT 2008


Log message for revision 91191:
  
  ZopePublication now annotates the request with the connection to the main
  ZODB when getApplication is called.
  

Changed:
  U   zope.app.publication/trunk/CHANGES.txt
  U   zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
  U   zope.app.publication/trunk/src/zope/app/publication/zopepublication.py

-=-
Modified: zope.app.publication/trunk/CHANGES.txt
===================================================================
--- zope.app.publication/trunk/CHANGES.txt	2008-09-16 14:49:43 UTC (rev 91190)
+++ zope.app.publication/trunk/CHANGES.txt	2008-09-16 15:06:24 UTC (rev 91191)
@@ -2,6 +2,14 @@
 CHANGES
 =======
 
+3.5.0 (unreleased)
+------------------
+
+- Now ``zope.app.publication.zopepublication.ZopePublication`` annotates the
+  request with the connection to the main ZODB when ``getApplication`` is
+  called.
+
+
 3.4.3 (2007-11-01)
 ------------------
 

Modified: zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py	2008-09-16 14:49:43 UTC (rev 91190)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py	2008-09-16 15:06:24 UTC (rev 91191)
@@ -571,7 +571,18 @@
         self.assertEqual(len(clear), 1)
         self.assertEqual(clear[0].object, ob2)
 
+    def testConnectionAnnotation(self):
+        """The request is annotated with the connection to the main ZODB.
+        """
+        self.assertRaises(
+            KeyError,
+            lambda: self.request.annotations['ZODB.interfaces.IConnection'])
 
+        app = self.publication.getApplication(self.request)
+        conn = self.request.annotations['ZODB.interfaces.IConnection']
+        self.assertEqual(conn.db(), self.db)
+
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(ZopePublicationTests),

Modified: zope.app.publication/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2008-09-16 14:49:43 UTC (rev 91190)
+++ zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2008-09-16 15:06:24 UTC (rev 91191)
@@ -150,6 +150,7 @@
         cleanup = Cleanup(conn.close)
         request.hold(cleanup)  # Close the connection on request.close()
 
+        request.annotations['ZODB.interfaces.IConnection'] = conn
         self.openedConnection(conn)
         #conn.setDebugInfo(getattr(request, 'environ', None), request.other)
 



More information about the Checkins mailing list