[Zope3-checkins] CVS: Zope3/src/zope/publisher/interfaces - __init__.py:1.1.2.1 browser.py:1.1.2.1 http.py:1.1.2.1 vfs.py:1.1.2.1 xmlrpc.py:1.1.2.1
Jim Fulton
jim@zope.com
Mon, 23 Dec 2002 14:33:12 -0500
Update of /cvs-repository/Zope3/src/zope/publisher/interfaces
In directory cvs.zope.org:/tmp/cvs-serv19908/zope/publisher/interfaces
Added Files:
Tag: NameGeddon-branch
__init__.py browser.py http.py vfs.py xmlrpc.py
Log Message:
Initial renaming before debugging
=== Added File Zope3/src/zope/publisher/interfaces/__init__.py ===
#
# This file is necessary to make this directory a package.
=== Added File Zope3/src/zope/publisher/interfaces/browser.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""
Revision information:
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.publisher.interfaces.http import IHTTPApplicationRequest
from zope.interface.element import Attribute
class IBrowserApplicationRequest(IHTTPApplicationRequest):
"""Browser-specific requests
"""
def __getitem__(key):
"""Return Browser request data
Request data sre retrieved from one of:
- Environment variables
These variables include input headers, server data, and other
request-related data. The variable names are as <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html">specified</a>
in the <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html">CGI
specification</a>
- Cookies
These are the cookie data, if present.
- Form data
Form data are searched before cookies, which are searched
before environmental data.
"""
form = Attribute(
"""Form data
This is a read-only mapping from name to form value for the name.
""")
"""
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IResource
class IBrowserResource(IBrowserPresentation, IResource):
"Browser View"
def __call__():
"""Return a URL for getting the resource
This URL should not be context dependent. Typically, the URL
will be based on the service that defined the resource.
"""
"""
Revision information:
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IPublication
class IBrowserPublication (IPublication):
"""
Object publication framework.
"""
def getDefaultTraversal(request, ob):
"""Get the default published object for the request
Allows a default view to be added to traversal.
Returns (ob, steps_reversed).
"""
"""
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.publisher.interfaces.http import IHTTPRequest
class IBrowserRequest(IHTTPRequest, IVirtualHostRequest):
"""Browser-specific Request functionality.
Note that the browser is special in many ways, since it exposes
the Request object to the end-developer.
"""
"""
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IPresentation
class IBrowserPresentation(IPresentation):
"""Browser presentations are for interaction with user's using Web Browsers
"""
"""
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interface import Interface
class IVirtualHostRequest(Interface):
"""The support for virtual hosts in Zope is very important.
In order to make virtual hosts working, we need to support several
methods in our Request object. This interface defines the required
methods.
"""
def setVirtualRoot(path, hard=0):
"""Treat the current publishing object as a VirtualRoot.
"""
def convertPhysicalPathToVirtualPath(path):
"""Remove the path to the VirtualRoot from a physical path.
"""
def convertPhysicalPathToURL(path, relative=0):
"""Convert a physical path into a URL in the current context.
"""
def getPhysicalPathFromURL(URL):
"""Convert a URL into a physical path in the current context.
If the URL makes no sense in light of the current virtual
hosting context, a ValueError is raised.
"""
def getEffectiveURL(self):
"""Return the effective URL.
"""
from zope.interfaces.publisher import IPublishTraverse
class IBrowserPublisher(IPublishTraverse):
def browserDefault(request):
"""Provide the default object
The default object is expressed as a (possibly different)
object and/or additional traversal steps.
Returns an object and a sequence of names. If the sequence of
names is not empty, then a traversal step is made for each name.
After the publisher gets to the end of the sequence, it will
call browserDefault on the last traversed object.
Normal usage is to return self for object and a default view name.
The publisher calls this method at the end of each traversal path. If
a non-empty sequence of names is returned, the publisher will traverse
those names and call browserDefault again at the end.
Note that if additional traversal steps are indicated (via a
nonempty sequence of names), then the publisher will try to adjust
the base href.
"""
"""
$Id: browser.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IView
class IBrowserView(IBrowserPresentation, IView):
"Browser View"
=== Added File Zope3/src/zope/publisher/interfaces/http.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""
Revision information:
$Id: http.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IApplicationRequest
from zope.interface.element import Attribute
class IHTTPApplicationRequest(IApplicationRequest):
"""HTTP request data.
This object provides access to request data. This includes, the
input headers, server data, and cookies.
Request objects are created by the object publisher and will be
passed to published objects through the argument name, REQUEST.
The request object is a mapping object that represents a
collection of variable to value mappings. In addition, variables
are divided into four categories:
- Environment variables
These variables include input headers, server data, and other
request-related data. The variable names are as <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html">specified</a>
in the <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html">CGI
specification</a>
- Cookies
These are the cookie data, if present.
- Other
Data that may be set by an application object.
The request object may be used as a mapping object, in which case
values will be looked up in the order: environment variables,
other variables, cookies, and special.
"""
def __getitem__(key):
"""Return HTTP request data
Request data sre retrieved from one of:
- Environment variables
These variables include input headers, server data, and other
request-related data. The variable names are as <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/env.html">specified</a>
in the <a
href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html">CGI
specification</a>
- Cookies
These are the cookie data, if present.
Cookies are searched before environmental data.
"""
def getCookies():
"""Return the cookie data
Data are returned as a mapping object, mapping cookie name to value.
"""
return IMapping(str, str)
cookies = Attribute(
"""Request cookie data
This is a read-only mapping from variable name to value.
""")
def getHeader(name, default=None):
"""Get a header value
Return the named HTTP header, or an optional default
argument or None if the header is not found. Note that
both original and CGI-ified header names are recognized,
e.g. 'Content-Type', 'CONTENT_TYPE' and 'HTTP_CONTENT_TYPE'
should all return the Content-Type header, if available.
"""
headers = Attribute(
"""Request header data
This is a read-only mapping from variable name to value.
""")
URL = Attribute(
"""Request URL data
When convered to a string, this gives the effective published URL.
This is object can also be used as a mapping object. The keys
must be integers or strings that can be converted to
integers. A non-negative integer returns a URL n steps from
the URL of the top-level application objects. A negative
integer gives a URL that is -n steps back from the effective
URL.
For example, 'request.URL[-2]' is equivalent to the Zope 2
'request["URL2"]'. The notion is that this would be used in
path expressions, like 'request/URL/-2'.
""")
def getURL(level=0, path_only=0):
"""Return the published URL with level names removed from the end.
If path_only is true, then only a path will be returned.
"""
def getApplicationURL(depth=0, path_only=0):
"""Return the application URL plus depth steps
If path_only is true, then only a path will be returned.
"""
"""
$Id: http.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interface import Interface
class IHTTPPublisher(Interface):
def publishTraverse(request, name):
"""Lookup a name
The request argument is the publisher request object.
"""
"""
$Id: http.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interface import Interface
# XXX Should we extend IRequest?
class IHTTPRequest(Interface):
def setPathSuffix(steps):
"""Add additional traversal steps to be taken after all other traversal
This is used to handle HTTP request methods (except for GET
and POST in the case of browser requests) and XML-RPC methods.
"""
from zope.interface import Interface
class IHTTPCredentials(Interface):
# XXX Eventially this will be a different method
def _authUserPW():
"""Return (login, password) if there are basic credentials;
return None if there aren't."""
def unauthorized(challenge):
"""Issue a 401 Unauthorized error (asking for login/password).
The challenge is the value of the WWW-Authenticate header."""
"""
$Id: http.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IApplicationResponse
from zope.interface.element import Attribute
class IHTTPApplicationResponse(IApplicationResponse):
"""HTTP Response
"""
def redirect(location, status=302):
"""Causes a redirection without raising an error.
"""
"""
$Id: http.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interface import Interface
class IHTTPResponse(Interface):
"""An object representation of an HTTP response.
The Response type encapsulates all possible responses to HTTP
requests. Responses are normally created by the object publisher.
A published object may recieve the response object as an argument
named 'RESPONSE'. A published object may also create its own
response object. Normally, published objects use response objects
to:
- Provide specific control over output headers,
- Set cookies, or
- Provide stream-oriented output.
If stream oriented output is used, then the response object
passed into the object must be used.
"""
def getStatus():
"""Returns the current HTTP status code as an integer.
"""
def setStatus(status, reason=None):
"""Sets the HTTP status code of the response
The argument may either be an integer or a string from { OK,
Created, Accepted, NoContent, MovedPermanently,
MovedTemporarily, NotModified, BadRequest, Unauthorized,
Forbidden, NotFound, InternalError, NotImplemented,
BadGateway, ServiceUnavailable } that will be converted to the
correct integer value.
"""
def setHeader(name, value, literal=0):
"""Sets an HTTP return header "name" with value "value"
The previous value is cleared. If the literal flag is true,
the case of the header name is preserved, otherwise
word-capitalization will be performed on the header name on
output.
"""
def addHeader(name, value):
"""Add an HTTP Header
Sets a new HTTP return header with the given value, while retaining
any previously set headers with the same name.
"""
def getHeader(name, default=None):
"""Gets a header value
Returns the value associated with a HTTP return header, or
'default' if no such header has been set in the response
yet.
"""
def getHeaders():
"""Returns a mapping of correctly-cased header names to values.
"""
def appendToCookie(name, value):
"""Append text to a cookie value
If a value for the cookie has previously been set, the new
value is appended to the old one separated by a colon.
"""
def expireCookie(name, **kw):
"""Causes an HTTP cookie to be removed from the browser
The response will include an HTTP header that will remove the cookie
corresponding to "name" on the client, if one exists. This is
accomplished by sending a new cookie with an expiration date
that has already passed. Note that some clients require a path
to be specified - this path must exactly match the path given
when creating the cookie. The path can be specified as a keyword
argument.
"""
def setCookie(name, value, **kw):
"""Sets an HTTP cookie on the browser
The response will include an HTTP header that sets a cookie on
cookie-enabled browsers with a key "name" and value
"value". This overwrites any previously set value for the
cookie in the Response object.
"""
def appendToHeader(name, value, delimiter=","):
"""Appends a value to a header
Sets an HTTP return header "name" with value "value",
appending it following a comma if there was a previous value
set for the header.
"""
def setCharset(charset=None):
"""Set the character set into which the response body should be
encoded. If None is passed in then no encoding will be done to
the output body.
The default character set is None.
"""
def setCharsetUsingRequest(request):
"""This convinience function determines the character set based on the
HTTP header information.
"""
=== Added File Zope3/src/zope/publisher/interfaces/vfs.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
class IVFSDirectoryPublisher(IVFSObjectPublisher):
""" """
def exists(name):
"""Checks whether the name exists.
"""
def listdir(with_stats=0, pattern='*'):
"""Returns a sequence of names ot (name, stat)
"""
def mkdir(name, mode=0777):
"""Create a container with name in this object.
"""
def remove(name):
"""Remove file with naem from this container.
"""
def rmdir(name):
"""Remove the container name from this container.
"""
def rename(old, new):
"""Rename an object from old name to new name.
"""
def writefile(name, mode, instream, start=0):
"""Write a file to the container. If the object does not exist,
inspect the content and the file name to create the right object
type.
"""
def check_writable(name):
"""Check whether we can write to a subobject.
"""
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
class IVFSFilePublisher(IVFSObjectPublisher):
"""This interface describes the necessary methods a VFS view has to
implement in order to be used by teh VFS.
"""
def read(mode, outstream, start=0, end=-1):
"""Read the content of this object.
"""
def write(mode, instream, start=0):
"""Write data specified in instream to object.
"""
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IPresentation
class IVFSPresentation(IPresentation):
"""VFS presentations"""
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IView
class IVFSView(IVFSPresentation, IView):
"VFS View"
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IPublishTraverse
class IVFSPublisher(IPublishTraverse):
"""VFS Publisher"""
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interface import Interface
class IVFSCredentials(Interface):
# XXX Eventually this will be a different method
def _authUserPW():
"""Return (login, password) if there are basic credentials;
return None if there aren't."""
def unauthorized(challenge):
"""Cause a FTP-based unautorized error message"""
"""
$Id: vfs.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
class IVFSObjectPublisher(IVFSPublisher):
""" """
def isdir():
"""Returns true, if the object is a container, namely implements
IContainer. For all other cases it returns false.
"""
def isfile():
"""Returns always the oposite of isdir() for the same reasons.
"""
def stat():
"""This method should return the typical file stat information:
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
"""
=== Added File Zope3/src/zope/publisher/interfaces/xmlrpc.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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: xmlrpc.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IPublishTraverse
class IXMLRPCPublisher(IPublishTraverse):
"""XML-RPC Publisher"""
"""
$Id: xmlrpc.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IView
class IXMLRPCView(IXMLRPCPresentation, IView):
"XMLRPC View"
"""
$Id: xmlrpc.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.interfaces.publisher import IPublication
class IXMLRPCPublication (IPublication):
"""Object publication framework."""
def getDefaultTraversal(request, ob):
"""Get the default published object for the request
Allows a default view to be added to traversal.
Returns (ob, steps_reversed).
"""
"""
$Id: xmlrpc.py,v 1.1.2.1 2002/12/23 19:33:10 jim Exp $
"""
from zope.component.interfaces import IPresentation
class IXMLRPCPresentation(IPresentation):
"""XMLRPC presentations are for interaction with user's
"""