Author: jmorliaguet
Date: Fri Mar 31 23:35:54 2006
New Revision: 2751

Added:
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py   
(contents, props changed)
Modified:
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/configure.zcml
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/interfaces.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/views.py
Log:

- added a negotiation chain for engines

- added an IRequestNegotiator (the information is stored in request annotations)



Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/configure.zcml
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/configure.zcml   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/configure.zcml   
    Fri Mar 31 23:35:54 2006
@@ -55,4 +55,14 @@
   />
 
 
+  <!-- engine negotiators -->
+
+  <adapter
+      factory=".engine.Request"
+      provides=".interfaces.IRequestNegotiator"
+      for="cpsskins.elements.interfaces.IElement
+           cpsskins.interfaces.IThemeManagementFolder
+           zope.publisher.interfaces.IRequest"
+  />
+
 </configure>

Added: cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py    
Fri Mar 31 23:35:54 2006
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.component import provideUtility
+from zope.interface import implements
+
+from cpsskins.browser.negotiation.interfaces import INegotiationChain
+from cpsskins.browser.negotiation.negotiator import Negotiator
+from cpsskins.browser.negotiation.plugins.interfaces import IRequestNegotiator
+
+class Request(Negotiator):
+    """Look for an engine name as a request annotation.
+    """
+    implements(IRequestNegotiator)
+
+    def __call__(self):
+        return self.request.annotations.get('cpsskins.engine', 'default')
+
+class EngineNegotiationChain:
+
+    implements(INegotiationChain)
+
+    def __call__(self):
+
+        return (IRequestNegotiator, )
+
+provideUtility(EngineNegotiationChain(), INegotiationChain, 'engine')

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/interfaces.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/interfaces.py    
    (original)
+++ 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/interfaces.py    
    Fri Mar 31 23:35:54 2006
@@ -17,8 +17,6 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.interface import Interface
-
 from cpsskins.browser.negotiation.interfaces import INegotiator
 
 class IQueryParameterNegotiator(INegotiator):
@@ -33,6 +31,10 @@
     """Session-based negotiation.
     """
 
+class IRequestNegotiator(INegotiator):
+    """Request-based negotiation.
+    """
+
 class ILocalNegotiator(INegotiator):
     """Local negotiation.
     """

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     Fri Mar 
31 23:35:54 2006
@@ -89,7 +89,7 @@
     ###################################################################
 
     def getEngine(self):
-        return self.request.annotations.get('cpsskins.engine', 'default')
+        return self.negociate('engine')
 
     ###################################################################
     # Rendering
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to