[Zope3-checkins] SVN: Zope3/branches/jinty-zodbless/src/zope/app/publication/ Better deprecation warning and test.

Brian Sutherland jinty at web.de
Mon Apr 9 20:34:35 EDT 2007


Log message for revision 74075:
  Better deprecation warning and test.

Changed:
  U   Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py

-=-
Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py	2007-04-09 23:40:33 UTC (rev 74074)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/tests/test_zopepublication.py	2007-04-10 00:34:33 UTC (rev 74075)
@@ -146,7 +146,19 @@
         for interface in implementedBy(ZopePublication):
             verifyClass(interface, TestPublication)
 
+    def testZODBApplicationFactoryBBB(self):
+        from ZODB.DB import DB
+        from ZODB.DemoStorage import DemoStorage
+        from zope.app.zodb.app import ZODBApplicationFactory
+        import zope.deprecation
+        storage = DemoStorage('test_storage')
+        db = DB(storage)
+        zope.deprecation.__show__.off()
+        pub = self.klass(db)
+        zope.deprecation.__show__.on()
+        self.assert_(isinstance(pub.resource_factory, ZODBApplicationFactory))
 
+
 class ZopePublicationErrorHandling(BasePublicationTests):
 
     def testRetryAllowed(self):

Modified: Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py	2007-04-09 23:40:33 UTC (rev 74074)
+++ Zope3/branches/jinty-zodbless/src/zope/app/publication/zopepublication.py	2007-04-10 00:34:33 UTC (rev 74075)
@@ -76,10 +76,19 @@
     version_cookie = ROOT_NAME
 
     def __init__(self, resource_factory):
-        #BBB
         if not IResourceFactory.providedBy(resource_factory):
-            warnings.warn("This needs to be a more intelligent warning")
-            resource_factory = IResourceFactory(resource_factory)
+            #BBB we used to pass ZODB databases
+            import zope.deprecation
+            if zope.deprecation.__show__():
+                warnings.warn("Passing ZODB Database objects to this "
+                              "publication object is deprecated. Pass "
+                              "objects providing zope.app.publication."
+                              "interface.IResourceFactory instead. See "
+                              "zope.app.zodb for an implementation. This "
+                              "compatibiltiy will go away in Zope 3.6",
+                              DeprecationWarning)
+            from zope.app.zodb.app import ZODBApplicationFactory
+            resource_factory = ZODBApplicationFactory(resource_factory)
         self.resource_factory = resource_factory
 
     def beforeTraversal(self, request):



More information about the Zope3-Checkins mailing list