Author: jmorliaguet
Date: Sun Jul  2 22:45:32 2006
New Revision: 3592

Modified:
   cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.py
   cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.zcml

Log:

- made engines (default, tableless) negotiable be location



Modified: cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.py  
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.py  Sun Jul 
 2 22:45:32 2006
@@ -21,6 +21,9 @@
 
 from cpsskins.browser.negotiation.scheme import NegotiationScheme
 from cpsskins.standard.negotiation import IRequestNegotiationScheme
+from cpsskins.standard.negotiation import ILocationNegotiationScheme
+from cpsskins.standard.negotiation import IDefaultNegotiationScheme
+from cpsskins.utils import guessPath
 
 class Request(NegotiationScheme):
     """Look for an engine name as a request annotation.
@@ -28,5 +31,26 @@
     implements(IRequestNegotiationScheme)
 
     def __call__(self):
-        return self.request.annotations.get('cpsskins.engine', u'default')
+        return self.request.annotations.get('cpsskins.engine')
+
+class Location(NegotiationScheme):
+    """Look for an engine among locations. The path is obtained from
+    the context.
+    """
+    implements(ILocationNegotiationScheme)
+
+    def __call__(self):
+        path = guessPath(self.context, self.request)
+        location = self.manager.getLocationStorage().find(path, u'engines')
+        if location is not None:
+            return location()
+        return None
+
+class Default(NegotiationScheme):
+    """Look for a default engine
+    """
+    implements(IDefaultNegotiationScheme)
+
+    def __call__(self):
+        return u'default'
 

Modified: cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.zcml        
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/negotiation/engine.zcml        
Sun Jul  2 22:45:32 2006
@@ -10,6 +10,16 @@
         interface=".interfaces.IRequestNegotiationScheme"
     />
 
+    <scheme
+        class=".engine.Location"
+        interface=".interfaces.ILocationNegotiationScheme"
+    />
+
+    <scheme
+        class=".engine.Default"
+        interface=".interfaces.IDefaultNegotiationScheme"
+    />
+
   </negotiationchain>
 
 
@@ -17,6 +27,11 @@
 
   <negotiationchain name="engine" strategy="content-author">
 
+    <scheme
+        class=".engine.Default"
+        interface=".interfaces.IDefaultNegotiationScheme"
+    />
+
   </negotiationchain>
 
 
@@ -24,6 +39,11 @@
 
   <negotiationchain name="engine" strategy="page-designer">
 
+    <scheme
+        class=".engine.Default"
+        interface=".interfaces.IDefaultNegotiationScheme"
+    />
+
   </negotiationchain>
 
 </configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to