Author: jmorliaguet
Date: Mon Apr  3 16:38:40 2006
New Revision: 2767

Added:
   cpsskins/branches/jmo-perspectives/browser/negotiation/scheme.py
      - copied, changed from r2762, 
cpsskins/branches/jmo-perspectives/browser/negotiation/negotiator.py
Removed:
   cpsskins/branches/jmo-perspectives/browser/negotiation/negotiator.py
Modified:
   cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt
   cpsskins/branches/jmo-perspectives/browser/negotiation/interfaces.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.zcml
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/interfaces.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.zcml
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.py
   
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.zcml
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.py
   cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.zcml
   cpsskins/branches/jmo-perspectives/browser/negotiation/views.py
   cpsskins/branches/jmo-perspectives/configuration/negotiation/meta.zcml
   cpsskins/branches/jmo-perspectives/configuration/negotiation/metaconfigure.py
   
cpsskins/branches/jmo-perspectives/configuration/negotiation/metadirectives.py
Log:

- renamed 'negotiator' as 'negotiation scheme'

- doc update



Modified: cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt   
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/README.txt   Mon Apr 
 3 16:38:40 2006
@@ -3,6 +3,63 @@
 NEGOTIATION
 ===========
 
+The negotiation process takes place between the client (browser) and the server
+to determine the parameters required for delivering a rendered page to the
+user.
+
+The negotiation strategy is fixed and is deterministic, which means that under
+the same premises the outcome of the negotiation will always be the same.
+
+In particular, the renderer needs to know:
+
+- what *theme* to use
+
+- what *page* to render
+
+- which rendering *engine* to use
+
+- from which *perspective* to render the page
+
+
+Hence the entire negotiation process is split into 4 phases:
+
+1) the 'theme negotiation' phase
+
+2) the 'page negotiation' phase
+
+3) the 'engine negotiation' phase
+
+4) the 'perspective negotiation' phase
+
+
+By design, the phases are independent of one another. To each phase
+corresponds a *negotiation chain*.
+
+
+Negotiation chains
+------------------
+
+A negotiation *chain* is a series of steps under which the client requests an
+object from the server using various schemes (passing a URL parameter,
+looking for a cookie variable, looking for a session or request variable, ...).
+
+For each step, the server either responds with the requested object if it
+is available or with nothing.
+
+The first available object will be the result of the negotiation for that
+particular chain.
+
+
+Negotiation strategy
+--------------------
+
+A negotiation *strategy* is a set of negotiation chains.
+
+Each *theme management folder* can have its own negotiation strategy.
+
+
+Test setup:
+
     >>> from zope.publisher.browser import TestRequest
     >>> request = TestRequest()
 

Modified: cpsskins/branches/jmo-perspectives/browser/negotiation/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/interfaces.py        
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/interfaces.py        
Mon Apr  3 16:38:40 2006
@@ -40,14 +40,17 @@
         """Return the viewer used to render the page."""
 
 
-class INegotiator(Interface):
+class INegotiationScheme(Interface):
 
     def __call__(self):
-        """Return the result of the negotiation."""
+        """Return the result of the negotiation step:
+        - the requested object if available
+        - None if the objected is not available
+        """
 
 
 class INegotiationChain(Interface):
-    """A marker interface for registering a list of negotiator interfaces
+    """A marker interface for registering a list of negotiation schemes
     """
 
     def __call__():

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py    
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.py    
Mon Apr  3 16:38:40 2006
@@ -19,13 +19,14 @@
 
 from zope.interface import implements
 
-from cpsskins.browser.negotiation.negotiator import Negotiator
-from cpsskins.browser.negotiation.plugins.interfaces import IRequestNegotiator
+from cpsskins.browser.negotiation.scheme import NegotiationScheme
+from cpsskins.browser.negotiation.plugins.interfaces import \
+     IRequestNegotiationScheme
 
-class Request(Negotiator):
+class Request(NegotiationScheme):
     """Look for an engine name as a request annotation.
     """
-    implements(IRequestNegotiator)
+    implements(IRequestNegotiationScheme)
 
     def __call__(self):
         return self.request.annotations.get('cpsskins.engine', 'default')

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.zcml  
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/engine.zcml  
Mon Apr  3 16:38:40 2006
@@ -3,9 +3,9 @@
 
   <negotiationchain name="engine">
 
-    <negotiator
+    <scheme
         factory=".engine.Request"
-        interface=".interfaces.IRequestNegotiator"
+        interface=".interfaces.IRequestNegotiationScheme"
     />
 
   </negotiationchain>

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    
    Mon Apr  3 16:38:40 2006
@@ -17,33 +17,33 @@
 """
 __docformat__ = "reStructuredText"
 
-from cpsskins.browser.negotiation.interfaces import INegotiator
+from cpsskins.browser.negotiation.interfaces import INegotiationScheme
 
-class IQueryParameterNegotiator(INegotiator):
+class IQueryParameterNegotiationScheme(INegotiationScheme):
     """Negotiation though a query parameter in a URL.
     """
 
-class ICookieNegotiator(INegotiator):
+class ICookieNegotiationScheme(INegotiationScheme):
     """Cookie-based negotiation.
     """
 
-class ISessionNegotiator(INegotiator):
+class ISessionNegotiationScheme(INegotiationScheme):
     """Session-based negotiation.
     """
 
-class IRequestNegotiator(INegotiator):
+class IRequestNegotiationScheme(INegotiationScheme):
     """Request-based negotiation.
     """
 
-class ILocalNegotiator(INegotiator):
+class ILocalNegotiationScheme(INegotiationScheme):
     """Local negotiation.
     """
 
-class IDefaultNegotiator(INegotiator):
+class IDefaultNegotiationScheme(INegotiationScheme):
     """Use the default object.
     """
 
-class IContextNegotiator(INegotiator):
+class IContextNegotiationScheme(INegotiationScheme):
     """Contextual negotiation.
     """
 

Modified: cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.py      
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.py      
Mon Apr  3 16:38:40 2006
@@ -20,18 +20,19 @@
 from zope.interface import implements
 from zope.component import queryUtility
 
-from cpsskins.browser.negotiation.negotiator import Negotiator
+from cpsskins.browser.negotiation.scheme import NegotiationScheme
 from cpsskins.browser.negotiation.plugins.interfaces import (
-    IQueryParameterNegotiator, ICookieNegotiator, ILocalNegotiator,
-    IDefaultNegotiator, IContextNegotiator)
+    IQueryParameterNegotiationScheme, ICookieNegotiationScheme,
+    ILocalNegotiationScheme, IDefaultNegotiationScheme,
+    IContextNegotiationScheme)
 
 from cpsskins.elements.interfaces import IThemePage
 
-class QueryParameter(Negotiator):
+class QueryParameter(NegotiationScheme):
     """Look for a page whose name is passed as a URL query parameter:
     ?theme=name
     """
-    implements(IQueryParameterNegotiator)
+    implements(IQueryParameterNegotiationScheme)
 
     def __call__(self):
         name = self.request.form.get('page')
@@ -39,10 +40,10 @@
             return None
         return self.manager.getPageByName(name)
 
-class Cookie(Negotiator):
+class Cookie(NegotiationScheme):
     """Look for a page whose name is stored in a cookie
     """
-    implements(ICookieNegotiator)
+    implements(ICookieNegotiationScheme)
 
     def __call__(self):
         name = self.request.cookies.get('cpsskins_work_page')
@@ -50,26 +51,26 @@
             return None
         return self.manager.getPageByName(name)
 
-class Local(Negotiator):
+class Local(NegotiationScheme):
     """Look for a page located in a parent folder.
     """
-    implements(ILocalNegotiator)
+    implements(ILocalNegotiationScheme)
 
     def __call__(self):
         return queryUtility(IThemePage, context=self.context)
 
-class Default(Negotiator):
+class Default(NegotiationScheme):
     """Look for a default page
     """
-    implements(IDefaultNegotiator)
+    implements(IDefaultNegotiationScheme)
 
     def __call__(self):
         return self.manager.getDefaultPage()
 
-class Context(Negotiator):
+class Context(NegotiationScheme):
     """Look for a page in the context
     """
-    implements(IContextNegotiator)
+    implements(IContextNegotiationScheme)
 
     def __call__(self):
         if IThemePage.providedBy(self.context):

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.zcml    
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/page.zcml    
Mon Apr  3 16:38:40 2006
@@ -3,29 +3,29 @@
 
   <negotiationchain name="page">
 
-    <negotiator
+    <scheme
         factory=".page.QueryParameter"
-        interface=".interfaces.IQueryParameterNegotiator"
+        interface=".interfaces.IQueryParameterNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".page.Cookie"
-        interface=".interfaces.ICookieNegotiator"
+        interface=".interfaces.ICookieNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".page.Local"
-        interface=".interfaces.ILocalNegotiator"
+        interface=".interfaces.ILocalNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".page.Default"
-        interface=".interfaces.IDefaultNegotiator"
+        interface=".interfaces.IDefaultNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".page.Context"
-        interface=".interfaces.IContextNegotiator"
+        interface=".interfaces.IContextNegotiationScheme"
     />
 
   </negotiationchain>

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.py   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.py   
    Mon Apr  3 16:38:40 2006
@@ -20,13 +20,14 @@
 from zope.app.session.interfaces import ISession
 from zope.interface import implements
 
-from cpsskins.browser.negotiation.negotiator import Negotiator
-from cpsskins.browser.negotiation.plugins.interfaces import ISessionNegotiator
+from cpsskins.browser.negotiation.scheme import NegotiationScheme
+from cpsskins.browser.negotiation.plugins.interfaces import \
+     ISessionNegotiationScheme
 
-class Session(Negotiator):
+class Session(NegotiationScheme):
     """Look for a perspective in the session.
     """
-    implements(ISessionNegotiator)
+    implements(ISessionNegotiationScheme)
 
     def __call__(self):
         pkg_id = 'cpsskins'

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.zcml
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.zcml 
    (original)
+++ 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/perspective.zcml 
    Mon Apr  3 16:38:40 2006
@@ -3,9 +3,9 @@
 
   <negotiationchain name="perspective">
 
-    <negotiator
+    <scheme
         factory=".perspective.Session"
-        interface=".interfaces.ISessionNegotiator"
+        interface=".interfaces.ISessionNegotiationScheme"
     />
 
   </negotiationchain>

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.py     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.py     
Mon Apr  3 16:38:40 2006
@@ -20,18 +20,19 @@
 from zope.component import queryUtility
 from zope.interface import implements
 
-from cpsskins.browser.negotiation.negotiator import Negotiator
+from cpsskins.browser.negotiation.scheme import NegotiationScheme
 from cpsskins.browser.negotiation.plugins.interfaces import (
-    IQueryParameterNegotiator, ICookieNegotiator, ILocalNegotiator,
-    IDefaultNegotiator, IContextNegotiator)
+    IQueryParameterNegotiationScheme, ICookieNegotiationScheme,
+    ILocalNegotiationScheme, IDefaultNegotiationScheme,
+    IContextNegotiationScheme)
 
 from cpsskins.elements.interfaces import ITheme
 
-class QueryParameter(Negotiator):
+class QueryParameter(NegotiationScheme):
     """Look for a theme whose name is passed as a URL query parameter:
     ?theme=name
     """
-    implements(IQueryParameterNegotiator)
+    implements(IQueryParameterNegotiationScheme)
 
     def __call__(self):
         name = self.request.form.get('theme')
@@ -39,10 +40,10 @@
             return None
         return self.manager.getThemeByName(name)
 
-class Cookie(Negotiator):
+class Cookie(NegotiationScheme):
     """Look for a theme whose name is stored in a cookie
     """
-    implements(ICookieNegotiator)
+    implements(ICookieNegotiationScheme)
 
     def __call__(self):
         name = self.request.cookies.get('cpsskins_theme')
@@ -50,26 +51,26 @@
             return None
         return self.manager.getThemeByName(name)
 
-class Local(Negotiator):
+class Local(NegotiationScheme):
     """Look for a theme located in a parent folder.
     """
-    implements(ILocalNegotiator)
+    implements(ILocalNegotiationScheme)
 
     def __call__(self):
         return queryUtility(ITheme, context=self.context)
 
-class Default(Negotiator):
+class Default(NegotiationScheme):
     """Look for a default theme
     """
-    implements(IDefaultNegotiator)
+    implements(IDefaultNegotiationScheme)
 
     def __call__(self):
         return self.manager.getDefaultTheme()
 
-class Context(Negotiator):
+class Context(NegotiationScheme):
     """Look for a theme in the context
     """
-    implements(IContextNegotiator)
+    implements(IContextNegotiationScheme)
 
     def __call__(self):
         if ITheme.providedBy(self.context):

Modified: 
cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.zcml   
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/plugins/theme.zcml   
Mon Apr  3 16:38:40 2006
@@ -3,29 +3,29 @@
 
   <negotiationchain name="theme">
 
-    <negotiator
+    <scheme
         factory=".theme.QueryParameter"
-        interface=".interfaces.IQueryParameterNegotiator"
+        interface=".interfaces.IQueryParameterNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".theme.Cookie"
-        interface=".interfaces.ICookieNegotiator"
+        interface=".interfaces.ICookieNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".theme.Local"
-        interface=".interfaces.ILocalNegotiator"
+        interface=".interfaces.ILocalNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".theme.Default"
-        interface=".interfaces.IDefaultNegotiator"
+        interface=".interfaces.IDefaultNegotiationScheme"
     />
 
-    <negotiator
+    <scheme
         factory=".theme.Context"
-        interface=".interfaces.IContextNegotiator"
+        interface=".interfaces.IContextNegotiationScheme"
     />
 
   </negotiationchain>

Copied: cpsskins/branches/jmo-perspectives/browser/negotiation/scheme.py (from 
r2762, cpsskins/branches/jmo-perspectives/browser/negotiation/negotiator.py)
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negotiation/negotiator.py        
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negotiation/scheme.py    Mon Apr 
 3 16:38:40 2006
@@ -17,7 +17,7 @@
 """
 __docformat__ = "reStructuredText"
 
-class Negotiator(object):
+class NegotiationScheme(object):
 
     def __init__(self, context, manager, request):
         self.context = context
@@ -26,4 +26,4 @@
 
     def __call__(self):
         raise NotImplementedError(
-            "A negotiator must implement the __call__() method.")
+            "A negotiation scheme must implement the __call__() method.")

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 16:38:40 2006
@@ -35,9 +35,8 @@
     def negotiate(self, type):
         chain = self.getChain(type)
         negotiation_context = (self.context, getThemeManager(), self.request)
-        for negotiator in chain:
-            result = getMultiAdapter(negotiation_context,
-                                     negotiator, name=type)()
+        for scheme in chain:
+            result = getMultiAdapter(negotiation_context, scheme, name=type)()
             if result:
                 return result
         return None
@@ -97,8 +96,8 @@
     def __init__(self):
         self.chain = ()
 
-    def add(self, negotiator):
-        self.chain += negotiator,
+    def add(self, scheme):
+        self.chain += scheme,
 
     def __call__(self):
         return self.chain

Modified: cpsskins/branches/jmo-perspectives/configuration/negotiation/meta.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/negotiation/meta.zcml      
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/negotiation/meta.zcml      
Mon Apr  3 16:38:40 2006
@@ -10,8 +10,8 @@
         >
 
       <subdirective
-          name="negotiator"
-          schema=".metadirectives.INegotiatorDirective"
+          name="scheme"
+          schema=".metadirectives.INegotiationSchemeDirective"
       />
 
     </complexDirective>

Modified: 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metaconfigure.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metaconfigure.py   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metaconfigure.py   
    Mon Apr  3 16:38:40 2006
@@ -22,7 +22,7 @@
 from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.component import provideUtility
 
-from cpsskins.browser.negotiation.interfaces import INegotiator
+from cpsskins.browser.negotiation.interfaces import INegotiationScheme
 from cpsskins.interfaces import IThemeManagementFolder
 from cpsskins.browser.negotiation.interfaces import INegotiationChain
 from cpsskins.browser.negotiation.views import NegotiationChain
@@ -36,31 +36,33 @@
         chain = chains[name] = NegotiationChain()
         provideUtility(chain, INegotiationChain, name)
 
-    def negotiator(self, _context, factory=None, interface=None):
+    def scheme(self, _context, factory=None, interface=None):
         if not interface:
-            raise ConfigurationError("Must specify a negotiator interface.")
-        return negotiator(_context, name=self.name, factory=factory,
+            raise ConfigurationError(
+              "Must specify a negotiation scheme interface.")
+        return scheme(_context, name=self.name, factory=factory,
                           interface=interface)
 
-def negotiator(_context, name=u'', factory=None, interface=None):
+def scheme(_context, name=u'', factory=None, interface=None):
 
     if not factory:
-        raise ConfigurationError("Must specify a negotiator factory.")
+        raise ConfigurationError("Must specify a negotiation scheme factory.")
 
-    if not interface.extends(INegotiator):
+    if not interface.extends(INegotiationScheme):
         raise ConfigurationError(
-            "A negotiator interface must extend INegotiator.")
+            "A negotiation scheme must extend INegotiationScheme.")
 
-    if not INegotiator.implementedBy(factory):
-        raise ConfigurationError("A negotiator must implement INegotiator.")
+    if not INegotiationScheme.implementedBy(factory):
+        raise ConfigurationError(
+            "A negotiation scheme must implement INegotiationScheme.")
 
-    # register the negotiator
+    # register the negotition scheme
     adapts = (None, IThemeManagementFolder, IBrowserRequest)
 
     # zope:adapter
     adapter(_context=_context, factory=(factory,), provides=interface,
             for_=adapts, name=name)
 
-    # add the negotiator to the chain
+    # add the negotiation scheme to the chain
     chains[name].add(interface)
 

Modified: 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metadirectives.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metadirectives.py  
    (original)
+++ 
cpsskins/branches/jmo-perspectives/configuration/negotiation/metadirectives.py  
    Mon Apr  3 16:38:40 2006
@@ -32,16 +32,16 @@
         required=False,
         )
 
-class INegotiatorDirective(Interface):
+class INegotiationSchemeDirective(Interface):
 
     factory = GlobalObject(
-        title=_(u"The negotiator's factory"),
-        description=_(u"The factory used to create the negotiator."),
+        title=_(u"The negotiation scheme factory"),
+        description=_(u"The factory used to create the negotiation scheme."),
         required=False,
         )
 
     interface = GlobalObject(
-        title=_(u"The negotiator's interface"),
-        description=_(u"The interface implemented by the negotiator."),
+        title=_(u"The negotiation scheme's interface"),
+        description=_(u"The interface implemented by the negotiation scheme."),
         required=False,
         )
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to