[Zope3-checkins] CVS: Zope3/src/zope/publisher - base.py:1.6.12.1 browser.py:1.17.12.1 ftp.py:1.4.14.1 http.py:1.24.12.1 publish.py:1.10.12.1 xmlrpc.py:1.5.14.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:21 -0400
Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/publisher
Modified Files:
Tag: cw-mail-branch
base.py browser.py ftp.py http.py publish.py xmlrpc.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/publisher/base.py 1.6 => 1.6.12.1 ===
--- Zope3/src/zope/publisher/base.py:1.6 Mon Apr 28 09:14:21 2003
+++ Zope3/src/zope/publisher/base.py Sun Jun 22 10:23:50 2003
@@ -20,6 +20,7 @@
import traceback
from cStringIO import StringIO
+from zope.interface import implements
from zope.interface.common.mapping import IReadMapping, IEnumerableMapping
from zope.exceptions import NotFoundError
@@ -27,6 +28,7 @@
from zope.publisher.interfaces import NotFound, DebugError, Unauthorized
from zope.publisher.interfaces import IRequest, IResponse
from zope.publisher.publish import mapply
+from zope.server.interfaces import IHeaderOutput
_marker = object()
@@ -39,7 +41,7 @@
'_outstream', # The output stream
)
- __implements__ = IResponse
+ implements(IResponse)
def __init__(self, outstream):
@@ -82,7 +84,7 @@
class RequestDataGetter(object):
- __implements__ = IReadMapping
+ implements(IReadMapping)
def __init__(self, request):
self.__get = getattr(request, self._gettrname)
@@ -101,7 +103,7 @@
class RequestDataMapper(object):
- __implements__ = IEnumerableMapping
+ implements(IEnumerableMapping)
def __init__(self, request):
self.__map = getattr(request, self._mapname)
@@ -126,8 +128,10 @@
def items(self):
return self.__map.items()
+
def values(self):
return self.__map.values()
+
def __len__(self):
return len(self.__map)
@@ -160,7 +164,7 @@
collection of variable to value mappings.
"""
- __implements__ = IRequest
+ implements(IRequest)
__slots__ = (
'_held', # Objects held until the request is closed
@@ -174,7 +178,7 @@
'_body', # The request body as a string
'_publication', # publication object
'_presentation_skin', # View skin
- 'user' # request user, set by publication
+ '_user' # request user, set by publication
)
environment = RequestDataProperty(RequestEnvironment)
@@ -193,7 +197,12 @@
self._response = response
self._body_instream = body_instream
self._held = ()
- self.user = None
+ self._user = None
+
+ def setUser(self, user):
+ self._user = user
+
+ user = property(lambda self: self._user)
def _getPublication(self):
'See IPublisherRequest'
@@ -426,7 +435,7 @@
class DefaultPublication:
- __implements__ = IPublication
+ implements(IPublication)
require_docstrings = 1
=== Zope3/src/zope/publisher/browser.py 1.17 => 1.17.12.1 ===
--- Zope3/src/zope/publisher/browser.py:1.17 Fri Apr 25 06:36:38 2003
+++ Zope3/src/zope/publisher/browser.py Sun Jun 22 10:23:50 2003
@@ -20,6 +20,7 @@
from types import ListType, TupleType, StringType, StringTypes
from cgi import FieldStorage, escape
+from zope.interface import implements
from zope.i18n.interfaces import IUserPreferredLanguages
from zope.i18n.interfaces import IUserPreferredCharsets
from zope.publisher.interfaces.browser import IBrowserPresentation
@@ -29,6 +30,7 @@
from zope.publisher.interfaces.browser import IBrowserView
from zope.component import getAdapter
from zope.publisher.http import HTTPRequest, HTTPResponse
+from zope.publisher.base import BaseRequest
__metaclass__ = type # All classes are new style when run with Python 2.2+
@@ -225,10 +227,7 @@
class BrowserRequest(HTTPRequest):
- __implements__ = (HTTPRequest.__implements__,
- IBrowserRequest,
- IBrowserApplicationRequest,
- )
+ implements(IBrowserRequest, IBrowserApplicationRequest)
__slots__ = (
'form', # Form data
@@ -707,8 +706,12 @@
use_redirect = 1
class TestRequest(BrowserRequest):
+ """Browser request with a constructor convenient for testing
+ """
- def __init__(self, body_instream=None, outstream=None, environ=None, **kw):
+ def __init__(self,
+ body_instream=None, outstream=None, environ=None, form=None,
+ **kw):
_testEnv = {
'SERVER_URL': 'http://127.0.0.1',
@@ -730,7 +733,13 @@
outstream = StringIO()
super(TestRequest, self).__init__(body_instream, outstream, _testEnv)
+ if form:
+ self.form.update(form)
+ def setUser(self, user):
+ # HTTPRequest needs to notify the HTTPTask of the username.
+ # We don't want to have to stub HTTPTask in the tests.
+ BaseRequest.setUser(self, user)
class BrowserResponse(HTTPResponse):
"""Browser response
@@ -829,7 +838,7 @@
class BrowserLanguages:
- __implements__ = IUserPreferredLanguages
+ implements(IUserPreferredLanguages)
def __init__(self, request):
self.request = request
@@ -846,7 +855,7 @@
class BrowserView:
- __implements__ = IBrowserView
+ implements(IBrowserView)
def __init__(self, context, request):
self.context = context
=== Zope3/src/zope/publisher/ftp.py 1.4 => 1.4.14.1 ===
--- Zope3/src/zope/publisher/ftp.py:1.4 Fri Apr 11 08:55:41 2003
+++ Zope3/src/zope/publisher/ftp.py Sun Jun 22 10:23:50 2003
@@ -16,6 +16,7 @@
$Id$
"""
+from zope.interface import implements
from zope.publisher.interfaces.ftp import IFTPPresentation
from zope.publisher.interfaces.ftp import IFTPCredentials
from zope.publisher.base import BaseResponse, BaseRequest
@@ -36,7 +37,7 @@
self._exc = exc_info
class FTPRequest(BaseRequest):
- __implements__ = BaseRequest.__implements__, IFTPCredentials
+ implements(IFTPCredentials)
_presentation_type = IFTPPresentation
=== Zope3/src/zope/publisher/http.py 1.24 => 1.24.12.1 ===
--- Zope3/src/zope/publisher/http.py:1.24 Mon Apr 28 09:14:21 2003
+++ Zope3/src/zope/publisher/http.py Sun Jun 22 10:23:50 2003
@@ -21,6 +21,8 @@
from types import StringTypes, UnicodeType, ClassType
from cgi import escape
+from zope.interface import implements
+
from zope.publisher.interfaces.http import IHTTPCredentials
from zope.publisher.interfaces.http import IHTTPRequest
from zope.publisher.interfaces.http import IHTTPApplicationRequest
@@ -264,9 +266,7 @@
_presentation_type = IHTTPPresentation
- __implements__ = (BaseRequest.__implements__,
- IHTTPCredentials, IHTTPRequest, IHTTPApplicationRequest,
- )
+ implements(IHTTPCredentials, IHTTPRequest, IHTTPApplicationRequest)
__slots__ = (
'_auth', # The value of the HTTP_AUTHORIZATION header.
@@ -506,6 +506,22 @@
self._response.setHeader("WWW-Authenticate", challenge, True)
self._response.setStatus(401)
+ def setUser(self, user):
+ 'See IPublicationRequest'
+ super(HTTPRequest, self).setUser(user)
+
+ # XXX: under the publishing conditions,
+ # self.response._outstream is an HTTPTask. It needs to know
+ # the username for logging purposes. It would make sense to
+ # do this in the server, when the actual hit log entry is
+ # written, but it would require a major refactoring.
+ #
+ # When removing this wart after the server refactoring, grep
+ # the source for setAuthUserName, we had to stub that in
+ # several tests.
+
+ self.response._outstream.setAuthUserName(user.getId())
+
#
############################################################
@@ -590,8 +606,7 @@
class HTTPResponse (BaseResponse):
- __implements__ = (IHTTPResponse, IHTTPApplicationResponse,
- BaseResponse.__implements__)
+ implements(IHTTPResponse, IHTTPApplicationResponse)
__slots__ = (
'_header_output', # Hook object to collaborate with a server
@@ -940,7 +955,7 @@
class DefaultPublisher:
- __implements__ = IHTTPPublisher
+ implements(IHTTPPublisher)
def publishTraverse(self, request, name):
'See IHTTPPublisher'
@@ -957,7 +972,7 @@
class HTTPCharsets:
- __implements__ = IUserPreferredCharsets
+ implements(IUserPreferredCharsets)
def __init__(self, request):
self.request = request
=== Zope3/src/zope/publisher/publish.py 1.10 => 1.10.12.1 ===
--- Zope3/src/zope/publisher/publish.py:1.10 Tue Apr 29 13:00:25 2003
+++ Zope3/src/zope/publisher/publish.py Sun Jun 22 10:23:50 2003
@@ -20,7 +20,7 @@
import sys
from zope.publisher.interfaces import Retry
-from zope.proxy.introspection import removeAllProxies
+from zope.proxy import removeAllProxies
_marker = [] # Create a new marker object.
=== Zope3/src/zope/publisher/xmlrpc.py 1.5 => 1.5.14.1 ===
--- Zope3/src/zope/publisher/xmlrpc.py:1.5 Fri Apr 11 08:55:41 2003
+++ Zope3/src/zope/publisher/xmlrpc.py Sun Jun 22 10:23:50 2003
@@ -18,6 +18,7 @@
import sys
import xmlrpclib
+from zope.interface import implements
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublication
from zope.publisher.interfaces.xmlrpc import IXMLRPCPresentation
@@ -25,7 +26,7 @@
from zope.publisher.http import HTTPRequest, HTTPResponse
from zope.publisher.http import DefaultPublisher
-from zope.proxy.introspection import removeAllProxies
+from zope.proxy import removeAllProxies
__metaclass__ = type # All classes are new style when run with Python 2.2+
@@ -35,7 +36,7 @@
except that it implements the IXMLRPCPublisher interface.
"""
- __implements__ = IXMLRPCPublisher
+ implements(IXMLRPCPublisher)
def __init__(self, context, request):
self.context = context
@@ -44,7 +45,7 @@
class XMLRPCRequest(HTTPRequest):
- __implements__ = HTTPRequest.__implements__, IXMLRPCPublication
+ implements(IXMLRPCPublication)
# _presentation_type is overridden from the BaseRequest
# to implement IXMLRPCPublisher
@@ -99,8 +100,6 @@
"""XMLRPC response
"""
- __implements__ = HTTPResponse.__implements__
-
def setBody(self, body):
"""Sets the body of the response
@@ -168,7 +167,7 @@
class XMLRPCView:
- __implements__ = IXMLRPCView
+ implements(IXMLRPCView)
def __init__(self, context, request):
self.context = context