Author: jmorliaguet
Date: Tue Jun 20 19:11:23 2006
New Revision: 3470

Modified:
   
cpsskins/branches/paris-sprint-2006/configuration/negotiation/metaconfigure.py

Log:

- made it possible to register several strategies for a same chain



Modified: 
cpsskins/branches/paris-sprint-2006/configuration/negotiation/metaconfigure.py
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/configuration/negotiation/metaconfigure.py  
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/configuration/negotiation/metaconfigure.py  
    Tue Jun 20 19:11:23 2006
@@ -27,7 +27,8 @@
 from cpsskins.browser.negotiation.strategy import NegotiationStrategy
 from cpsskins.thememanager import IThemeManagementFolder
 
-registered_utilities = {}
+registered_strategies = {}
+registered_schemes = []
 
 class negotiationchain(object):
 
@@ -35,14 +36,14 @@
         self.name = name
         self.chain = NegotiationChain()
 
-        st = registered_utilities.get(strategy)
+        st = registered_strategies.get(strategy)
         if st is None:
             st = NegotiationStrategy()
 
-        if strategy not in registered_utilities:
+        if strategy not in  registered_strategies:
             utility(_context=_context, provides=INegotiationStrategy,
                     component=st, name=strategy)
-            registered_utilities[strategy] = st
+            registered_strategies[strategy] = st
 
         st.addChain(self.chain, name)
 
@@ -69,10 +70,12 @@
         raise ConfigurationError(
             "A negotiation scheme must implement INegotiationScheme.")
 
-    # register the negotition scheme
-    adapts = (None, IThemeManagementFolder, IBrowserRequest)
-
-    # zope:adapter
-    adapter(_context=_context, factory=(class_,), provides=interface,
-            for_=adapts, name=name)
+    if name not in registered_schemes:
+        # register the negotition scheme
+        adapts = (None, IThemeManagementFolder, IBrowserRequest)
+
+        # zope:adapter
+        adapter(_context=_context, factory=(class_,), provides=interface,
+                for_=adapts, name=name)
 
+        registered_schemes.append(name)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to