[Checkins] SVN: grok/trunk/ Not allowed to register two skins with the same name, so give conflict error.

Martijn Faassen faassen at infrae.com
Wed Apr 16 09:06:41 EDT 2008


Log message for revision 85437:
  Not allowed to register two skins with the same name, so give conflict error.
  Same for REST protocols.
  

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/src/grok/meta.py
  A   grok/trunk/src/grok/tests/conflict/
  A   grok/trunk/src/grok/tests/conflict/__init__.py
  A   grok/trunk/src/grok/tests/conflict/rest.py
  A   grok/trunk/src/grok/tests/conflict/skin.py
  U   grok/trunk/src/grok/tests/test_grok.py

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2008-04-16 07:47:06 UTC (rev 85436)
+++ grok/trunk/CHANGES.txt	2008-04-16 13:06:40 UTC (rev 85437)
@@ -78,6 +78,9 @@
   a module name is identical to the package name. At least modules
   with templates can now have same name as their package.
 
+* Multiple skins and REST protocols could be registered under the same
+  name, but this is actually a conflict. Now give configuration
+  conflict error when someone tries this.
 
 Restructuring
 -------------

Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py	2008-04-16 07:47:06 UTC (rev 85436)
+++ grok/trunk/src/grok/meta.py	2008-04-16 13:06:40 UTC (rev 85437)
@@ -877,7 +877,7 @@
                                           default=IBrowserRequest)
         name = get_name_classname(factory)
         config.action(
-            discriminator=None,
+            discriminator=('skin', name),
             callable=zope.component.interface.provideInterface,
             args=(name, layer, IBrowserSkinType)
             )
@@ -891,7 +891,7 @@
                                           default=IBrowserRequest)
         name = get_name_classname(factory)
         config.action(
-            discriminator=None,
+            discriminator=('restprotocol', name),
             callable=zope.component.interface.provideInterface,
             args=(name, layer, IRESTSkinType)
             )

Added: grok/trunk/src/grok/tests/conflict/__init__.py
===================================================================
--- grok/trunk/src/grok/tests/conflict/__init__.py	                        (rev 0)
+++ grok/trunk/src/grok/tests/conflict/__init__.py	2008-04-16 13:06:40 UTC (rev 85437)
@@ -0,0 +1 @@
+#

Added: grok/trunk/src/grok/tests/conflict/rest.py
===================================================================
--- grok/trunk/src/grok/tests/conflict/rest.py	                        (rev 0)
+++ grok/trunk/src/grok/tests/conflict/rest.py	2008-04-16 13:06:40 UTC (rev 85437)
@@ -0,0 +1,17 @@
+"""
+We cannot register two rest protocols under the same name::
+
+  >>> grok.testing.grok(__name__)
+  Traceback (most recent call last):
+    ...
+  ConfigurationConflictError: Conflicting configuration actions
+    For: ('restprotocol', 'foo')
+"""
+
+import grok
+
+class Protocol1(grok.RESTProtocol):
+    grok.name('foo')
+
+class Protocol2(grok.RESTProtocol):
+    grok.name('foo')

Added: grok/trunk/src/grok/tests/conflict/skin.py
===================================================================
--- grok/trunk/src/grok/tests/conflict/skin.py	                        (rev 0)
+++ grok/trunk/src/grok/tests/conflict/skin.py	2008-04-16 13:06:40 UTC (rev 85437)
@@ -0,0 +1,17 @@
+"""
+We cannot register two skins under the same name::
+
+  >>> grok.testing.grok(__name__)
+  Traceback (most recent call last):
+    ...
+  ConfigurationConflictError: Conflicting configuration actions
+    For: ('skin', 'foo')
+"""
+
+import grok
+
+class Skin1(grok.Skin):
+    grok.name('foo')
+
+class Skin2(grok.Skin):
+    grok.name('foo')

Modified: grok/trunk/src/grok/tests/test_grok.py
===================================================================
--- grok/trunk/src/grok/tests/test_grok.py	2008-04-16 07:47:06 UTC (rev 85436)
+++ grok/trunk/src/grok/tests/test_grok.py	2008-04-16 13:06:40 UTC (rev 85437)
@@ -46,7 +46,7 @@
                  'zcml', 'static', 'utility', 'xmlrpc', 'json', 'container',
                  'traversal', 'form', 'grokker', 'directive', 'util',
                  'baseclass', 'annotation', 'application', 'template', 'order',
-                 'viewlet', 'testsetup']:
+                 'viewlet', 'testsetup', 'conflict']:
         suite.addTest(suiteFromPackage(name))
     return suite
 



More information about the Checkins mailing list