[Checkins] SVN: zope.browser/trunk/ Added definitions to the base browser publishing process.

Souheil CHELFOUH souheil at chelfouh.com
Thu Mar 24 12:09:52 EDT 2011


Log message for revision 121117:
  Added definitions to the base browser publishing process.
  This allows us to move toward a greater interoperability with other systems.
  This change will trigger a serie for changes in the zope packages, mainly in zope.publisher.
  

Changed:
  U   zope.browser/trunk/CHANGES.txt
  U   zope.browser/trunk/README.txt
  U   zope.browser/trunk/setup.py
  U   zope.browser/trunk/src/zope/browser/README.txt
  U   zope.browser/trunk/src/zope/browser/interfaces.py

-=-
Modified: zope.browser/trunk/CHANGES.txt
===================================================================
--- zope.browser/trunk/CHANGES.txt	2011-03-24 15:38:35 UTC (rev 121116)
+++ zope.browser/trunk/CHANGES.txt	2011-03-24 16:09:52 UTC (rev 121117)
@@ -1,10 +1,27 @@
 Changelog
 =========
 
-1.3.1 (unreleased)
-------------------
+1.4 (unreleased)
+----------------
 
+Added definitions to the base browser publishing process, including :
 
+  * IRequest and IResponse
+  * IPublisher
+  * Errors definitions with : IPublishingError, IBadRequest, INotFound
+    and IRedirect
+  * Views publishing help : IDefaultViewName, that permits to retrieve
+    the name of the default view for a context.
+
+This allows us to move toward a greater interoperability with other
+systems, severing a lot of zope packages' ties with ``zope.publisher``,
+where all these concepts were initially defined. ``zope.publisher`` will
+now use these interfaces as mixins to create zope publication
+specific definitions. Components that don't need the full blow
+definition can now register on broader interfaces, making them
+available to non ``zope.publisher`` aware applications.
+
+
 1.3 (2010-04-30)
 ----------------
 

Modified: zope.browser/trunk/README.txt
===================================================================
--- zope.browser/trunk/README.txt	2011-03-24 15:38:35 UTC (rev 121116)
+++ zope.browser/trunk/README.txt	2011-03-24 16:09:52 UTC (rev 121117)
@@ -1,4 +1,8 @@
 zope.browser
 ============
 
-This package provides shared browser components for the Zope Toolkit.
+This package provides shared browser components for the Zope
+Toolkit. It defines the base actors for an interaction with a browser,
+including the publishing process, from the request to the response and
+the MVC oriented components. This ensures the pluggability and the
+general interoperability of the publishing mechanisms and protagonists.

Modified: zope.browser/trunk/setup.py
===================================================================
--- zope.browser/trunk/setup.py	2011-03-24 15:38:35 UTC (rev 121116)
+++ zope.browser/trunk/setup.py	2011-03-24 16:09:52 UTC (rev 121117)
@@ -22,7 +22,7 @@
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
 setup(name='zope.browser',
-    version = '1.3.1dev',
+    version = '1.4.0dev',
     author='Zope Foundation and Contributors',
     author_email='zope-dev at zope.org',
     description='Shared Zope Toolkit browser components',

Modified: zope.browser/trunk/src/zope/browser/README.txt
===================================================================
--- zope.browser/trunk/src/zope/browser/README.txt	2011-03-24 15:38:35 UTC (rev 121116)
+++ zope.browser/trunk/src/zope/browser/README.txt	2011-03-24 16:09:52 UTC (rev 121117)
@@ -1,5 +1,105 @@
+IRequest
+========
+
+Requests are the fundamental entry point of a browser request.
+
+There is not much we can test except that ``IRequest`` is importable
+and an interface:
+
+  >>> from zope.interface import Interface
+  >>> from zope.browser.interfaces import IRequest
+  >>> Interface.providedBy(IRequest)
+  True
+
+
+IResponse
+=========
+
+Naturally, each request made to the server triggers a
+response. Defined by IResponse, it mainly consist in a group of
+headers and, optionnaly, a body.
+
+There is not much we can test except that ``IResponse`` is importable
+and an interface:
+
+  >>> from zope.browser.interfaces import IResponse
+  >>> Interface.providedBy(IResponse)
+  True
+
+
+IPublisher
+==========
+
+The publisher is the component responsable, usually, in transforming a
+request into a response.
+
+There is not much we can test except that ``IPublisher`` is importable
+and an interface:
+
+  >>> from zope.browser.interfaces import IPublisher
+  >>> Interface.providedBy(IPublisher)
+  True
+
+
+
+IPublishingException
+====================
+
+A publishing exception is an exception raised during the publishing
+process. The handling of such exception is therefore often handled
+by the publisher component itself.
+
+  >>> from zope.interface.common.interfaces import IException
+  >>> from zope.browser.interfaces import IPublishingException
+  >>> Interface.providedBy(IPublishingException)
+  True
+  >>> IPublishingException.extends(IException)
+  True
+
+
+IRedirect
+---------
+
+A redirect exception is a publishing exception that interrupt the
+publishing in order to return a redirect-aware response.
+
+  >>> from zope.browser.interfaces import IRedirect
+  >>> Interface.providedBy(IRedirect)
+  True
+  >>> IRedirect.extends(IPublishingException)
+  True
+
+
+INotFound
+---------
+
+An exception meaning that the looked up object has not been found
+during the publishing process.
+
+  >>> from zope.browser.interfaces import INotFound
+  >>> from zope.interface.common.interfaces import ILookupError
+  >>> Interface.providedBy(INotFound)
+  True
+  >>> INotFound.extends(IPublishingException)
+  True
+  >>> INotFound.extends(ILookupError)
+  True
+
+
+IBadRequest
+-----------
+
+Bad request means the request is somehow malformed or erroneous.
+
+  >>> from zope.browser.interfaces import IBadRequest
+  >>> Interface.providedBy(IBadRequest)
+  True
+  >>> IBadRequest.extends(IPublishingException)
+  True
+
+
 IView
------
+=====
 
 Views adapt both a context and a request.
 
@@ -11,8 +111,9 @@
   >>> Interface.providedBy(IView)
   True
 
+
 IBrowserView
--------------
+=============
 
 Browser views are views specialized for requests from a browser (e.g.,
 as distinct from WebDAV, FTP, XML-RPC, etc.).
@@ -20,30 +121,40 @@
 There is not much we can test except that ``IBrowserView`` is importable
 and an interface derived from ``IView``:
 
-  >>> from zope.interface import Interface
   >>> from zope.browser.interfaces import IBrowserView
   >>> Interface.providedBy(IBrowserView)
   True
   >>> IBrowserView.extends(IView)
   True
 
+
+IDefaultViewName
+================
+
+A string that contains the default view name
+
+  >>> from zope.browser.interfaces import IDefaultViewName
+  >>> Interface.providedBy(IDefaultViewName)
+  True
+
+
 IAdding
--------
+=======
 
-Adding views manage how newly-created items get added to containers.
+Adding views manage how newly=created items get added to containers.
 
 There is not much we can test except that ``IAdding`` is importable
 and an interface derived from ``IBrowserView``:
 
-  >>> from zope.interface import Interface
   >>> from zope.browser.interfaces import IAdding
   >>> Interface.providedBy(IBrowserView)
   True
   >>> IAdding.extends(IBrowserView)
   True
 
+
 ITerms
-------
+======
 
 The ``ITerms`` interface is used as a base for ``ISource`` widget
 implementations.  This interfaces get used by ``zope.app.form`` and was
@@ -57,13 +168,13 @@
 There is not much we can test except that ITerms is importable
 and an interface:
 
-  >>> from zope.interface import Interface
   >>> from zope.browser.interfaces import ITerms
   >>> Interface.providedBy(ITerms)
   True
 
+
 ISystemErrorView
-----------------
+================
 
 Views providing this interface can classify their contexts as system
 errors. These errors can be handled in a special way (e. g. more
@@ -72,7 +183,6 @@
 There is not much we can test except that ISystemErrorView is importable
 and an interface:
 
-  >>> from zope.interface import Interface
   >>> from zope.browser.interfaces import ISystemErrorView
   >>> Interface.providedBy(ISystemErrorView)
   True

Modified: zope.browser/trunk/src/zope/browser/interfaces.py
===================================================================
--- zope.browser/trunk/src/zope/browser/interfaces.py	2011-03-24 15:38:35 UTC (rev 121116)
+++ zope.browser/trunk/src/zope/browser/interfaces.py	2011-03-24 16:09:52 UTC (rev 121117)
@@ -11,31 +11,122 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Shared dependency less Zope3 brwoser components.
+"""Shared dependency less Zope3 browser components.
 """
 __docformat__ = 'restructuredtext'
 
-from zope.interface import Attribute
-from zope.interface import Interface
+from zope.interface import Attribute, Interface
+from zope.interface.common.interfaces import IException, ILookupError
 
+
+class IRequest(Interface):
+    """A request is a directive sent by a browser to the server,
+    to retrieve a resource. It consists of a location and a set of headers.
+    This information is represented by the environment data.
+    """
+    form = Attribute("parsed GET or POST data")
+    method = Attribute("HTTP method used to query the server.")
+
+    environment = Attribute(
+        "Request environment data. This is a read-only mapping "
+        "from variable name to value.")
+
+
+class IResponse(Interface):
+    """A response is the result of the publishing process.
+    This prototypes a very basic response item, that can be
+    extended for more specific uses.
+    """
+    body = Attribute("body of the response")
+    headers = Attribute("headers of the response")
+
+    def getStatus(as_int=False):
+        """returns the status of the response.
+        """
+
+    def redirect(url, status=None, trusted=False):
+        """Sets the response for a redirect.
+        """
+
+
+class IPublisher(Interface):
+    """A publisher is charged with the task to use a request to publish
+    a resource. This is usually done by returning a response after a
+    'traversal' operation.
+    """
+
+    def publish(request, *args, **kwargs):
+        """Publish a request
+
+        The request is expected to be an IRequest.
+        """
+
+
+class IPublishingException(IException):
+    """A publishing exception is an exception raised during the publishing
+    process. The handling of such exception is therefore handled mainly
+    by the publisher itself, opposed to the other kind of exceptions that
+    are to be handled at another stage or/and another component.
+    """
+
+
+class IRedirect(IPublishingException):
+    """A redirect exception is a publishing exception that interrupt the
+    publishing in order to return a redirect-aware response.
+    """
+
+    location = Attribute("Target location of the redirect")
+
+
+class INotFound(ILookupError, IPublishingException):
+    """An exception meaning that the looked up object has not been found
+    during the publishing process.
+    """
+
+
+class IBadRequest(IPublishingException):
+    """Bad request means the request is somehow malformed or erroneous.
+    It must have the capabilities to expose the error message when printed.
+    """
+
+    def __str__():
+        """Returns the error message.
+        """
+
+
 class IView(Interface):
-    """ Views are multi-adapters for context and request objects.
+    """Views are multi-adapters for context and request objects.
     """
     context = Attribute("The context object the view renders")
     request = Attribute("The request object driving the view")
 
+
 class IBrowserView(IView):
-    """ Views which are specialized for requests from a browser
+    """Views which are specialized for requests from a browser
 
-    o Such views are distinct from those geerated via WebDAV, FTP, XML-RPC,
+    o Such views are distinct from those generated via WebDAV, FTP, XML-RPC,
       etc..
     """
 
+
+class IDefaultViewName(Interface):
+    """A string that contains the default view name
+
+    A default view name is used to select a view when a user hasn't
+    specified one.
+    """
+
+    def __str__():
+        """Returns the default view name.
+        """
+
+
 class IAdding(IBrowserView):
-    """ Multi-adapter interface for views which add items to containers.
+    """Multi-adapter interface for views which add items to containers.
 
     o The 'context' of the view must implement ``zope.container.IContainer``.
     """
+
     def add(content):
         """Add content object to context.
 
@@ -86,7 +177,7 @@
 
 
 class ITerms(Interface):
-    """ Adapter providing lookups for vocabulary terms.
+    """Adapter providing lookups for vocabulary terms.
     """
     def getTerm(value):
         """Return an ITitledTokenizedTerm object for the given value
@@ -100,6 +191,7 @@
         LookupError is raised if there isn't a value in the source.
         """
 
+
 class ISystemErrorView(Interface):
     """Error views that can classify their contexts as system errors
     """



More information about the checkins mailing list