Author: jmorliaguet
Date: Mon Apr  3 21:17:39 2006
New Revision: 2770

Modified:
   cpsskins/branches/jmo-perspectives/browser/negotiation/views.py
   cpsskins/branches/jmo-perspectives/interfaces.py
   cpsskins/branches/jmo-perspectives/thememanager.py
Log:

- the negotiation strategy is obtained from the theme management folder



Modified: cpsskins/branches/jmo-perspectives/browser/negotiation/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/views.py     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/views.py     Mon Apr 
 3 21:17:39 2006
@@ -34,20 +34,16 @@
     implements(INegotiation)
 
     def negotiate(self, name):
-        chain = self.getChain(name)
-        negotiation_context = (self.context, getThemeManager(), self.request)
+        manager = getThemeManager()
+        strategy = zapi.getUtility(INegotiationStrategy, manager.negotiation)
+        chain = strategy.getChain(name)
+        negotiation_context = (self.context, manager, self.request)
         for scheme in chain:
             result = getMultiAdapter(negotiation_context, scheme, name=name)()
             if result:
                 return result
         return None
 
-    def getStrategy(self, name=u'default'):
-        return zapi.getUtility(interface=INegotiationStrategy, name=name)
-
-    def getChain(self, name):
-        return self.getStrategy().getChain(name)
-
     ###################################################################
     # Themes and pages
     ###################################################################

Modified: cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/interfaces.py    (original)
+++ cpsskins/branches/jmo-perspectives/interfaces.py    Mon Apr  3 21:17:39 2006
@@ -20,6 +20,7 @@
 from zope.app.cache.interfaces.ram import IRAMCache
 from zope.i18nmessageid import MessageFactory
 from zope.interface import Interface
+from zope.schema import TextLine
 
 from cpsskins.elements.interfaces import IElement, IPortlet, IDisplay, IFormat
 
@@ -33,6 +34,12 @@
     The methods may be moved to other classes.
     """
 
+    negotiation = TextLine(
+        title=_(u"The negotiation strategy"),
+        description=_(u"The name of the negotiation strategy."),
+        required=False,
+        )
+
     def getIdRegistry():
         """Return the unique id registry."""
 

Modified: cpsskins/branches/jmo-perspectives/thememanager.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/thememanager.py  (original)
+++ cpsskins/branches/jmo-perspectives/thememanager.py  Mon Apr  3 21:17:39 2006
@@ -70,8 +70,11 @@
 
     implements(IThemeManagementFolder, IThemeContainer)
 
-    def __init__(self):
+    def __init__(self, negotiation=u'default'):
         super(ThemeManagementFolder, self).__init__()
+        # negotiation strategy
+        self.negotiation = negotiation
+        # registries, storages
         self[u'uids'] = IntIds()
         self[u'imagecache'] = ImageCache()
         self[u'settings'] = Settings()
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to