diff options
author | Souheil CHELFOUH <trollfot@gmail.com> | 2011-03-24 16:09:52 +0000 |
---|---|---|
committer | Souheil CHELFOUH <trollfot@gmail.com> | 2011-03-24 16:09:52 +0000 |
commit | 919902916f183d4e81f96ed6e6719909398328b5 (patch) | |
tree | bbb5143e35aa6642b6029303aaf0202f8670dd78 /src/zope/browser/interfaces.py | |
parent | df78dd6a2177b77e0c13ea1cfe05db911e074412 (diff) | |
download | zope-browser-919902916f183d4e81f96ed6e6719909398328b5.tar.gz |
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.
Diffstat (limited to 'src/zope/browser/interfaces.py')
-rw-r--r-- | src/zope/browser/interfaces.py | 108 |
1 files changed, 100 insertions, 8 deletions
diff --git a/src/zope/browser/interfaces.py b/src/zope/browser/interfaces.py index a7c0188..9db799e 100644 --- a/src/zope/browser/interfaces.py +++ b/src/zope/browser/interfaces.py @@ -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 IAdding(IBrowserView): 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 @@ class ITerms(Interface): 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 """ |