[Zope3-checkins] SVN: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/ fixes and more tests

Andreas Jung andreas at andreas-jung.com
Sat Oct 8 04:08:30 EDT 2005


Log message for revision 38917:
  fixes and more tests
  

Changed:
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py
  U   Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py

-=-
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml	2005-10-08 07:24:30 UTC (rev 38916)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml	2005-10-08 08:08:30 UTC (rev 38917)
@@ -31,7 +31,7 @@
       factory=".requestpublicationfactories.BrowserFactory"
       method="GET,POST,HEAD"
       mimetype="*"
-      priority="10"
+      priority="0"
       />
 
   <publisher

Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py	2005-10-08 07:24:30 UTC (rev 38916)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py	2005-10-08 08:08:30 UTC (rev 38917)
@@ -54,6 +54,7 @@
         # Check if there is already a registered publisher factory (check by name).
         # If yes then it will be removed and replaced by a new publisher.
         for pos, d in enumerate(l): 
+            print pos,d, name
             if d['name'] == name:
                 del l[pos]
                 break

Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py	2005-10-08 07:24:30 UTC (rev 38916)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py	2005-10-08 08:08:30 UTC (rev 38917)
@@ -23,6 +23,7 @@
 from zope.interface.verify import verifyClass
 from zope.component.tests.placelesssetup import PlacelessSetup
 
+from zope.configuration.exceptions import ConfigurationError
 from zope.app.publication import interfaces
 from zope.app.publication.interfaces import IRequestPublicationRegistry
 from zope.app.publication.requestpublicationregistry import RequestPublicationRegistry
@@ -61,6 +62,25 @@
                             ])
         self.assertEqual(r.getFactoriesFor('POST', 'text/html'), None)
 
+    def test_configuration_same_priority(self):
+        r = RequestPublicationRegistry()
+        xmlrpc_f = DummyFactory()
+        r.register('POST', 'text/xml', 'xmlrpc', 0, DummyFactory)
+        r.register('POST', 'text/xml', 'soap', 1, DummyFactory())
+        # try to register a factory with the same priority
+        self.assertRaises(ConfigurationError, r.register, 'POST', 'text/xml', 'soap2', 1, DummyFactory())
+
+    def test_configuration_reregistration(self):
+        r = RequestPublicationRegistry()
+        xmlrpc_f = DummyFactory()
+        r.register('POST', 'text/xml', 'xmlrpc', 0, DummyFactory)
+        r.register('POST', 'text/xml', 'soap', 1, DummyFactory())
+        # re-register 'soap' but with priority 2
+        r.register('POST', 'text/xml', 'soap', 2, DummyFactory())
+        factory_data = r.getFactoriesFor('POST', 'text/xml')
+        priorities = [item['priority'] for item in factory_data]
+        self.assertEqual(priorities, [2, 0])
+
     def test_realfactories(self):
         r = RequestPublicationRegistry()
         r.register('POST', '*', 'post_fallback', 0, HTTPFactory())



More information about the Zope3-Checkins mailing list