1.1 --- a/WebStack/BaseHTTPRequestHandler.py Sat Jan 14 01:51:20 2006 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Sat Jan 14 01:52:43 2006 +0000
1.3 @@ -51,8 +51,6 @@
1.4 self.content = StringIO()
1.5 self.headers_out = {}
1.6 self.cookies_out = SimpleCookie()
1.7 - self.user = None
1.8 - self.path_info = None
1.9
1.10 # Define the incoming cookies.
1.11
1.12 @@ -292,7 +290,8 @@
1.13 Returns a dictionary mapping field names to lists of values (even if a
1.14 single value is associated with any given field name). Each value is
1.15 either a Unicode object (representing a simple form field, for example)
1.16 - or a plain string (representing a file upload form field, for example).
1.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
1.18 + upload form field).
1.19 """
1.20
1.21 encoding = encoding or self.get_content_type().charset or self.default_charset
1.22 @@ -325,7 +324,8 @@
1.23 Returns a dictionary mapping field names to lists of values (even if a
1.24 single value is associated with any given field name). Each value is
1.25 either a Unicode object (representing a simple form field, for example)
1.26 - or a plain string (representing a file upload form field, for example).
1.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
1.28 + upload form field).
1.29
1.30 Where a given field name is used in both the path and message body to
1.31 specify values, the values from both sources will be combined into a
2.1 --- a/WebStack/CGI.py Sat Jan 14 01:51:20 2006 +0000
2.2 +++ b/WebStack/CGI.py Sat Jan 14 01:52:43 2006 +0000
2.3 @@ -56,8 +56,6 @@
2.4 self.content = StringIO()
2.5 self.headers_out = {}
2.6 self.cookies_out = SimpleCookie()
2.7 - self.user = None
2.8 - self.path_info = None
2.9
2.10 # Define the incoming cookies.
2.11
2.12 @@ -270,7 +268,8 @@
2.13 Returns a dictionary mapping field names to lists of values (even if a
2.14 single value is associated with any given field name). Each value is
2.15 either a Unicode object (representing a simple form field, for example)
2.16 - or a plain string (representing a file upload form field, for example).
2.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
2.18 + upload form field).
2.19 """
2.20
2.21 encoding = encoding or self.get_content_type().charset or self.default_charset
2.22 @@ -305,7 +304,8 @@
2.23 Returns a dictionary mapping field names to lists of values (even if a
2.24 single value is associated with any given field name). Each value is
2.25 either a Unicode object (representing a simple form field, for example)
2.26 - or a plain string (representing a file upload form field, for example).
2.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
2.28 + upload form field).
2.29
2.30 Where a given field name is used in both the path and message body to
2.31 specify values, the values from both sources will be combined into a
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/WebStack/Django.py Sat Jan 14 01:52:43 2006 +0000
3.3 @@ -0,0 +1,471 @@
3.4 +#!/usr/bin/env python
3.5 +
3.6 +"""
3.7 +Django classes.
3.8 +
3.9 +Copyright (C) 2006 Paul Boddie <paul@boddie.org.uk>
3.10 +
3.11 +This library is free software; you can redistribute it and/or
3.12 +modify it under the terms of the GNU Lesser General Public
3.13 +License as published by the Free Software Foundation; either
3.14 +version 2.1 of the License, or (at your option) any later version.
3.15 +
3.16 +This library is distributed in the hope that it will be useful,
3.17 +but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3.19 +Lesser General Public License for more details.
3.20 +
3.21 +You should have received a copy of the GNU Lesser General Public
3.22 +License along with this library; if not, write to the Free Software
3.23 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
3.24 +"""
3.25 +
3.26 +import WebStack.Generic
3.27 +from WebStack.Helpers import Environment
3.28 +from WebStack.Helpers.Request import decode_value, FileContent
3.29 +from WebStack.Helpers.Response import ConvertingStream
3.30 +from django.utils.httpwrappers import HttpResponse
3.31 +from StringIO import StringIO
3.32 +
3.33 +class Transaction(WebStack.Generic.Transaction):
3.34 +
3.35 + """
3.36 + Django transaction interface.
3.37 + """
3.38 +
3.39 + def __init__(self, request):
3.40 +
3.41 + """
3.42 + Initialise the transaction with the Django 'request' object.
3.43 + """
3.44 +
3.45 + self.request = request
3.46 +
3.47 + # Attributes which may be changed later.
3.48 +
3.49 + self.content_type = None
3.50 +
3.51 + # The response is created here but must be modified later.
3.52 + # NOTE: It is unfortunate that Django wants to initialise the response
3.53 + # NOTE: with the content type immediately.
3.54 +
3.55 + self.response = HttpResponse()
3.56 + self.content = StringIO()
3.57 +
3.58 + def commit(self):
3.59 +
3.60 + "Commit the transaction by finishing some things off."
3.61 +
3.62 + self.content.seek(0)
3.63 + self.response.content = self.content.read()
3.64 +
3.65 + # Server-related methods.
3.66 +
3.67 + def get_server_name(self):
3.68 +
3.69 + "Returns the server name."
3.70 +
3.71 + return self.request.META.get("SERVER_NAME")
3.72 +
3.73 + def get_server_port(self):
3.74 +
3.75 + "Returns the server port as a string."
3.76 +
3.77 + return self.request.META.get("SERVER_PORT")
3.78 +
3.79 + # Request-related methods.
3.80 +
3.81 + def get_request_stream(self):
3.82 +
3.83 + """
3.84 + Returns the request stream for the transaction.
3.85 + """
3.86 +
3.87 + # Unfortunately, we get given a string from Django. Thus, we need to
3.88 + # create a stream around that string.
3.89 +
3.90 + return StringIO(self.request.raw_post_data)
3.91 +
3.92 + def get_request_method(self):
3.93 +
3.94 + """
3.95 + Returns the request method.
3.96 + """
3.97 +
3.98 + return self.request.META.get("REQUEST_METHOD")
3.99 +
3.100 + def get_headers(self):
3.101 +
3.102 + """
3.103 + Returns all request headers as a dictionary-like object mapping header
3.104 + names to values.
3.105 + """
3.106 +
3.107 + return Environment.get_headers(self.request.META)
3.108 +
3.109 + def get_header_values(self, key):
3.110 +
3.111 + """
3.112 + Returns a list of all request header values associated with the given
3.113 + 'key'. Note that according to RFC 2616, 'key' is treated as a
3.114 + case-insensitive string.
3.115 + """
3.116 +
3.117 + return self.convert_to_list(self.get_headers().get(key))
3.118 +
3.119 + def get_content_type(self):
3.120 +
3.121 + """
3.122 + Returns the content type specified on the request, along with the
3.123 + charset employed.
3.124 + """
3.125 +
3.126 + return self.parse_content_type(self.request.META.get("CONTENT_TYPE"))
3.127 +
3.128 + def get_content_charsets(self):
3.129 +
3.130 + """
3.131 + Returns the character set preferences.
3.132 +
3.133 + NOTE: Not decently supported.
3.134 + """
3.135 +
3.136 + return self.parse_content_preferences(None)
3.137 +
3.138 + def get_content_languages(self):
3.139 +
3.140 + """
3.141 + Returns extracted language information from the transaction.
3.142 +
3.143 + NOTE: Not decently supported.
3.144 + """
3.145 +
3.146 + return self.parse_content_preferences(None)
3.147 +
3.148 + def get_path(self, encoding=None):
3.149 +
3.150 + """
3.151 + Returns the entire path from the request as a Unicode object. Any "URL
3.152 + encoded" character values in the part of the path before the query
3.153 + string will be decoded and presented as genuine characters; the query
3.154 + string will remain "URL encoded", however.
3.155 +
3.156 + If the optional 'encoding' is set, use that in preference to the default
3.157 + encoding to convert the path into a form not containing "URL encoded"
3.158 + character values.
3.159 + """
3.160 +
3.161 + return decode_value(self.request.get_full_path(), encoding)
3.162 +
3.163 + def get_path_without_query(self, encoding=None):
3.164 +
3.165 + """
3.166 + Returns the entire path from the request minus the query string as a
3.167 + Unicode object containing genuine characters (as opposed to "URL
3.168 + encoded" character values).
3.169 +
3.170 + If the optional 'encoding' is set, use that in preference to the default
3.171 + encoding to convert the path into a form not containing "URL encoded"
3.172 + character values.
3.173 + """
3.174 +
3.175 + path = self.get_path(encoding)
3.176 + return path.split("?")[0]
3.177 +
3.178 + def get_path_info(self, encoding=None):
3.179 +
3.180 + """
3.181 + Returns the "path info" (the part of the URL after the resource name
3.182 + handling the current request) from the request as a Unicode object
3.183 + containing genuine characters (as opposed to "URL encoded" character
3.184 + values).
3.185 +
3.186 + If the optional 'encoding' is set, use that in preference to the default
3.187 + encoding to convert the path into a form not containing "URL encoded"
3.188 + character values.
3.189 + """
3.190 +
3.191 + path_info = self.request.META.get("PATH_INFO") or ""
3.192 + return decode_value(path_info, encoding)
3.193 +
3.194 + def get_query_string(self):
3.195 +
3.196 + """
3.197 + Returns the query string from the path in the request.
3.198 + """
3.199 +
3.200 + return self.request.META.get("QUERY_STRING") or ""
3.201 +
3.202 + # Higher level request-related methods.
3.203 +
3.204 + def get_fields_from_path(self, encoding=None):
3.205 +
3.206 + """
3.207 + Extracts fields (or request parameters) from the path specified in the
3.208 + transaction. The underlying framework may refuse to supply fields from
3.209 + the path if handling a POST transaction. The optional 'encoding'
3.210 + parameter specifies the character encoding of the query string for cases
3.211 + where the default encoding is to be overridden.
3.212 +
3.213 + Returns a dictionary mapping field names to lists of values (even if a
3.214 + single value is associated with any given field name).
3.215 + """
3.216 +
3.217 + return self._get_fields(self.request.GET, encoding)
3.218 +
3.219 + def get_fields_from_body(self, encoding=None):
3.220 +
3.221 + """
3.222 + Extracts fields (or request parameters) from the message body in the
3.223 + transaction. The optional 'encoding' parameter specifies the character
3.224 + encoding of the message body for cases where no such information is
3.225 + available, but where the default encoding is to be overridden.
3.226 +
3.227 + Returns a dictionary mapping field names to lists of values (even if a
3.228 + single value is associated with any given field name). Each value is
3.229 + either a Unicode object (representing a simple form field, for example)
3.230 + or a WebStack.Helpers.Request.FileContent object (representing a file
3.231 + upload form field).
3.232 + """
3.233 +
3.234 + fields = {}
3.235 + self._update_fields(fields, self._get_fields(self.request.POST, encoding))
3.236 + self._update_fields(fields, self._get_files())
3.237 + return fields
3.238 +
3.239 + def _get_fields(self, source, encoding=None):
3.240 + fields = {}
3.241 + for name in source.keys():
3.242 + name = decode_value(name, encoding)
3.243 + fields[name] = []
3.244 + for value in source.getlist(name):
3.245 + value = decode_value(value, encoding)
3.246 + fields[name].append(value)
3.247 + return fields
3.248 +
3.249 + def _get_files(self):
3.250 + files = {}
3.251 + for name, file in self.request.FILES.items():
3.252 + files[name] = [FileContent(file.get("content", ""), {
3.253 + "Content-Type" : file.get("content-type", ""),
3.254 + "Content-Disposition" : "%s; filename=%s" % (name, file.get("filename", ""))
3.255 + })]
3.256 + return files
3.257 +
3.258 + def get_fields(self, encoding=None):
3.259 +
3.260 + """
3.261 + Extracts fields (or request parameters) from both the path specified in
3.262 + the transaction as well as the message body. The optional 'encoding'
3.263 + parameter specifies the character encoding of the message body for cases
3.264 + where no such information is available, but where the default encoding
3.265 + is to be overridden.
3.266 +
3.267 + Returns a dictionary mapping field names to lists of values (even if a
3.268 + single value is associated with any given field name). Each value is
3.269 + either a Unicode object (representing a simple form field, for example)
3.270 + or a WebStack.Helpers.Request.FileContent object (representing a file
3.271 + upload form field).
3.272 +
3.273 + Where a given field name is used in both the path and message body to
3.274 + specify values, the values from both sources will be combined into a
3.275 + single list associated with that field name.
3.276 + """
3.277 +
3.278 + fields = {}
3.279 + fields.update(self.get_fields_from_path(encoding))
3.280 + self._update_fields(fields, self.get_fields_from_body(encoding))
3.281 + return fields
3.282 +
3.283 + def _update_fields(self, fields, new_fields):
3.284 + for name, values in new_fields.items():
3.285 + if not fields.has_key(name):
3.286 + fields[name] = values
3.287 + else:
3.288 + fields[name] += values
3.289 +
3.290 + def get_user(self):
3.291 +
3.292 + """
3.293 + Extracts user information from the transaction.
3.294 +
3.295 + Returns a username as a string or None if no user is defined.
3.296 + """
3.297 +
3.298 + if self.user is not None:
3.299 + return self.user
3.300 +
3.301 + if hasattr(self.request.user, "username"):
3.302 + return self.request.user.username
3.303 + else:
3.304 + return None
3.305 +
3.306 + def get_cookies(self):
3.307 +
3.308 + """
3.309 + Obtains cookie information from the request.
3.310 +
3.311 + Returns a dictionary mapping cookie names to cookie objects.
3.312 + """
3.313 +
3.314 + return self.process_cookies(self.request.COOKIES, using_strings=1)
3.315 +
3.316 + def get_cookie(self, cookie_name):
3.317 +
3.318 + """
3.319 + Obtains cookie information from the request.
3.320 +
3.321 + Returns a cookie object for the given 'cookie_name' or None if no such
3.322 + cookie exists.
3.323 + """
3.324 +
3.325 + value = self.request.COOKIES.get(self.encode_cookie_value(cookie_name))
3.326 + if value is not None:
3.327 + return Cookie(cookie_name, self.decode_cookie_value(value))
3.328 + else:
3.329 + return None
3.330 +
3.331 + # Response-related methods.
3.332 +
3.333 + def get_response_stream(self):
3.334 +
3.335 + """
3.336 + Returns the response stream for the transaction.
3.337 + """
3.338 +
3.339 + # Unicode can upset this operation. Using either the specified charset
3.340 + # or a default encoding.
3.341 +
3.342 + encoding = self.get_response_stream_encoding()
3.343 + return ConvertingStream(self.content, encoding)
3.344 +
3.345 + def get_response_stream_encoding(self):
3.346 +
3.347 + """
3.348 + Returns the response stream encoding.
3.349 + """
3.350 +
3.351 + if self.content_type:
3.352 + encoding = self.content_type.charset
3.353 + else:
3.354 + encoding = None
3.355 + return encoding or self.default_charset
3.356 +
3.357 + def get_response_code(self):
3.358 +
3.359 + """
3.360 + Get the response code associated with the transaction. If no response
3.361 + code is defined, None is returned.
3.362 + """
3.363 +
3.364 + return self.response.status_code
3.365 +
3.366 + def set_response_code(self, response_code):
3.367 +
3.368 + """
3.369 + Set the 'response_code' using a numeric constant defined in the HTTP
3.370 + specification.
3.371 + """
3.372 +
3.373 + self.response.status_code = response_code
3.374 +
3.375 + def set_header_value(self, header, value):
3.376 +
3.377 + """
3.378 + Set the HTTP 'header' with the given 'value'.
3.379 + """
3.380 +
3.381 + self.response.headers[header] = value
3.382 +
3.383 + def set_content_type(self, content_type):
3.384 +
3.385 + """
3.386 + Sets the 'content_type' for the response.
3.387 + """
3.388 +
3.389 + self.content_type = content_type
3.390 + self.response.headers["Content-Type"] = str(content_type)
3.391 +
3.392 + # Higher level response-related methods.
3.393 +
3.394 + def set_cookie(self, cookie):
3.395 +
3.396 + """
3.397 + Stores the given 'cookie' object in the response.
3.398 + """
3.399 +
3.400 + self.set_cookie_value(cookie.name, cookie.value)
3.401 +
3.402 + def set_cookie_value(self, name, value, path=None, expires=None):
3.403 +
3.404 + """
3.405 + Stores a cookie with the given 'name' and 'value' in the response.
3.406 +
3.407 + The optional 'path' is a string which specifies the scope of the cookie,
3.408 + and the optional 'expires' parameter is a value compatible with the
3.409 + time.time function, and indicates the expiry date/time of the cookie.
3.410 + """
3.411 +
3.412 + self.response.set_cookie(self.encode_cookie_value(name), self.encode_cookie_value(value), path=path, expires=expires)
3.413 +
3.414 + def delete_cookie(self, cookie_name):
3.415 +
3.416 + """
3.417 + Adds to the response a request that the cookie with the given
3.418 + 'cookie_name' be deleted/discarded by the client.
3.419 + """
3.420 +
3.421 + #self.response.delete_cookie(self.encode_cookie_value(cookie_name))
3.422 +
3.423 + # Create a special cookie, given that we do not know whether the browser
3.424 + # has been sent the cookie or not.
3.425 + # NOTE: Magic discovered in Webware.
3.426 +
3.427 + name = self.encode_cookie_value(cookie_name)
3.428 + self.response.set_cookie(name, "", path="/", expires=0, max_age=0)
3.429 +
3.430 + # Session-related methods.
3.431 +
3.432 + def get_session(self, create=1):
3.433 +
3.434 + """
3.435 + Gets a session corresponding to an identifier supplied in the
3.436 + transaction.
3.437 +
3.438 + If no session has yet been established according to information
3.439 + provided in the transaction then the optional 'create' parameter
3.440 + determines whether a new session will be established.
3.441 +
3.442 + Where no session has been established and where 'create' is set to 0
3.443 + then None is returned. In all other cases, a session object is created
3.444 + (where appropriate) and returned.
3.445 + """
3.446 +
3.447 + # NOTE: Dubious access to a more dictionary-like object.
3.448 +
3.449 + if create:
3.450 + self.request.session["_hack"] = "created"
3.451 + return Session(self.request.session)
3.452 +
3.453 + def expire_session(self):
3.454 +
3.455 + """
3.456 + Expires any session established according to information provided in the
3.457 + transaction.
3.458 + """
3.459 +
3.460 + # NOTE: Not trivially supported!
3.461 +
3.462 +class Session:
3.463 + def __init__(self, session):
3.464 + self.session = session
3.465 + def __getattr__(self, name):
3.466 + return getattr(self.session, name)
3.467 + def keys(self):
3.468 + return self.session._session.keys()
3.469 + def values(self):
3.470 + return self.session._session.values()
3.471 + def items(self):
3.472 + return self.session._session.items()
3.473 +
3.474 +# vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/WebStack/Generic.py Sat Jan 14 01:51:20 2006 +0000
4.2 +++ b/WebStack/Generic.py Sat Jan 14 01:52:43 2006 +0000
4.3 @@ -54,6 +54,17 @@
4.4
4.5 default_charset = "iso-8859-1"
4.6
4.7 + # The default path info is provided here, although the manipulated virtual
4.8 + # path info is an instance attribute set through instances of subclasses of
4.9 + # this class.
4.10 +
4.11 + path_info = None
4.12 +
4.13 + # The default user is provided here, although the manipulated user is an
4.14 + # instance attribute set through instances of subclasses of this class.
4.15 +
4.16 + user = None
4.17 +
4.18 def commit(self):
4.19
4.20 """
4.21 @@ -382,7 +393,8 @@
4.22 Returns a dictionary mapping field names to lists of values (even if a
4.23 single value is associated with any given field name). Each value is
4.24 either a Unicode object (representing a simple form field, for example)
4.25 - or a plain string (representing a file upload form field, for example).
4.26 + or a WebStack.Helpers.Request.FileContent object (representing a file
4.27 + upload form field).
4.28 """
4.29
4.30 raise NotImplementedError, "get_fields_from_body"
4.31 @@ -399,7 +411,8 @@
4.32 Returns a dictionary mapping field names to lists of values (even if a
4.33 single value is associated with any given field name). Each value is
4.34 either a Unicode object (representing a simple form field, for example)
4.35 - or a plain string (representing a file upload form field, for example).
4.36 + or a WebStack.Helpers.Request.FileContent object (representing a file
4.37 + upload form field).
4.38
4.39 Where a given field name is used in both the path and message body to
4.40 specify values, the values from both sources will be combined into a
5.1 --- a/WebStack/JavaServlet.py Sat Jan 14 01:51:20 2006 +0000
5.2 +++ b/WebStack/JavaServlet.py Sat Jan 14 01:52:43 2006 +0000
5.3 @@ -102,8 +102,6 @@
5.4 self.request = request
5.5 self.response = response
5.6 self.status = None
5.7 - self.user = None
5.8 - self.path_info = None
5.9
5.10 # Remember the cookies received in the request.
5.11 # NOTE: Discarding much of the information received.
5.12 @@ -326,7 +324,8 @@
5.13 Returns a dictionary mapping field names to lists of values (even if a
5.14 single value is associated with any given field name). Each value is
5.15 either a Unicode object (representing a simple form field, for example)
5.16 - or a plain string (representing a file upload form field, for example).
5.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
5.18 + upload form field).
5.19 """
5.20
5.21 # There may not be a reliable means of extracting only the fields
5.22 @@ -374,7 +373,8 @@
5.23 Returns a dictionary mapping field names to lists of values (even if a
5.24 single value is associated with any given field name). Each value is
5.25 either a Unicode object (representing a simple form field, for example)
5.26 - or a plain string (representing a file upload form field, for example).
5.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
5.28 + upload form field).
5.29
5.30 Where a given field name is used in both the path and message body to
5.31 specify values, the values from both sources will be combined into a
6.1 --- a/WebStack/ModPython.py Sat Jan 14 01:51:20 2006 +0000
6.2 +++ b/WebStack/ModPython.py Sat Jan 14 01:52:43 2006 +0000
6.3 @@ -56,8 +56,6 @@
6.4 self.trans = trans
6.5 self.response_code = apache.OK
6.6 self.content_type = None
6.7 - self.user = None
6.8 - self.path_info = None
6.9
6.10 # Support non-framework cookies.
6.11
6.12 @@ -263,7 +261,8 @@
6.13 Returns a dictionary mapping field names to lists of values (even if a
6.14 single value is associated with any given field name). Each value is
6.15 either a Unicode object (representing a simple form field, for example)
6.16 - or a plain string (representing a file upload form field, for example).
6.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
6.18 + upload form field).
6.19
6.20 The mod_python.util.FieldStorage class may augment the fields from the
6.21 body with fields found in the path.
6.22 @@ -308,7 +307,8 @@
6.23 Returns a dictionary mapping field names to lists of values (even if a
6.24 single value is associated with any given field name). Each value is
6.25 either a Unicode object (representing a simple form field, for example)
6.26 - or a plain string (representing a file upload form field, for example).
6.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
6.28 + upload form field).
6.29
6.30 Where a given field name is used in both the path and message body to
6.31 specify values, the values from both sources will be combined into a
7.1 --- a/WebStack/Twisted.py Sat Jan 14 01:51:20 2006 +0000
7.2 +++ b/WebStack/Twisted.py Sat Jan 14 01:52:43 2006 +0000
7.3 @@ -39,8 +39,6 @@
7.4
7.5 self.trans = trans
7.6 self.content_type = None
7.7 - self.user = None
7.8 - self.path_info = None
7.9
7.10 # Special objects retained throughout the transaction.
7.11
7.12 @@ -239,7 +237,11 @@
7.13 Returns a dictionary mapping field names to lists of values (even if a
7.14 single value is associated with any given field name). Each value is
7.15 either a Unicode object (representing a simple form field, for example)
7.16 - or a plain string (representing a file upload form field, for example).
7.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
7.18 + upload form field).
7.19 +
7.20 + NOTE: Twisted does not currently support file uploads correctly and a
7.21 + NOTE: Unicode object will be returned for such fields instead.
7.22 """
7.23
7.24 # There may not be a reliable means of extracting only the fields
7.25 @@ -282,7 +284,11 @@
7.26 Returns a dictionary mapping field names to lists of values (even if a
7.27 single value is associated with any given field name). Each value is
7.28 either a Unicode object (representing a simple form field, for example)
7.29 - or a plain string (representing a file upload form field, for example).
7.30 + or a WebStack.Helpers.Request.FileContent object (representing a file
7.31 + upload form field).
7.32 +
7.33 + NOTE: Twisted does not currently support file uploads correctly and a
7.34 + NOTE: Unicode object will be returned for such fields instead.
7.35
7.36 Where a given field name is used in both the path and message body to
7.37 specify values, the values from both sources will be combined into a
8.1 --- a/WebStack/WSGI.py Sat Jan 14 01:51:20 2006 +0000
8.2 +++ b/WebStack/WSGI.py Sat Jan 14 01:52:43 2006 +0000
8.3 @@ -52,8 +52,6 @@
8.4 self.content = StringIO()
8.5 self.headers_out = {}
8.6 self.cookies_out = SimpleCookie()
8.7 - self.user = None
8.8 - self.path_info = None
8.9
8.10 # Define the incoming cookies.
8.11
8.12 @@ -274,7 +272,8 @@
8.13 Returns a dictionary mapping field names to lists of values (even if a
8.14 single value is associated with any given field name). Each value is
8.15 either a Unicode object (representing a simple form field, for example)
8.16 - or a plain string (representing a file upload form field, for example).
8.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
8.18 + upload form field).
8.19 """
8.20
8.21 encoding = encoding or self.get_content_type().charset or self.default_charset
8.22 @@ -309,7 +308,8 @@
8.23 Returns a dictionary mapping field names to lists of values (even if a
8.24 single value is associated with any given field name). Each value is
8.25 either a Unicode object (representing a simple form field, for example)
8.26 - or a plain string (representing a file upload form field, for example).
8.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
8.28 + upload form field).
8.29
8.30 Where a given field name is used in both the path and message body to
8.31 specify values, the values from both sources will be combined into a
9.1 --- a/WebStack/Webware.py Sat Jan 14 01:51:20 2006 +0000
9.2 +++ b/WebStack/Webware.py Sat Jan 14 01:52:43 2006 +0000
9.3 @@ -39,8 +39,6 @@
9.4
9.5 self.trans = trans
9.6 self.content_type = None
9.7 - self.user = None
9.8 - self.path_info = None
9.9
9.10 # Server-related methods.
9.11
9.12 @@ -248,7 +246,8 @@
9.13 Returns a dictionary mapping field names to lists of values (even if a
9.14 single value is associated with any given field name). Each value is
9.15 either a Unicode object (representing a simple form field, for example)
9.16 - or a plain string (representing a file upload form field, for example).
9.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
9.18 + upload form field).
9.19 """
9.20
9.21 all_fields = self._get_fields(encoding)
9.22 @@ -283,7 +282,8 @@
9.23 Returns a dictionary mapping field names to lists of values (even if a
9.24 single value is associated with any given field name). Each value is
9.25 either a Unicode object (representing a simple form field, for example)
9.26 - or a plain string (representing a file upload form field, for example).
9.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
9.28 + upload form field).
9.29
9.30 Where a given field name is used in both the path and message body to
9.31 specify values, the values from both sources will be combined into a
10.1 --- a/WebStack/Zope.py Sat Jan 14 01:51:20 2006 +0000
10.2 +++ b/WebStack/Zope.py Sat Jan 14 01:52:43 2006 +0000
10.3 @@ -56,8 +56,6 @@
10.4 # Attributes which may be changed later.
10.5
10.6 self.content_type = None
10.7 - self.user = None
10.8 - self.path_info = None
10.9
10.10 # Server-related methods.
10.11
10.12 @@ -247,7 +245,8 @@
10.13 Returns a dictionary mapping field names to lists of values (even if a
10.14 single value is associated with any given field name). Each value is
10.15 either a Unicode object (representing a simple form field, for example)
10.16 - or a plain string (representing a file upload form field, for example).
10.17 + or a WebStack.Helpers.Request.FileContent object (representing a file
10.18 + upload form field).
10.19 """
10.20
10.21 all_fields = self._get_fields(encoding)
10.22 @@ -287,7 +286,8 @@
10.23 Returns a dictionary mapping field names to lists of values (even if a
10.24 single value is associated with any given field name). Each value is
10.25 either a Unicode object (representing a simple form field, for example)
10.26 - or a plain string (representing a file upload form field, for example).
10.27 + or a WebStack.Helpers.Request.FileContent object (representing a file
10.28 + upload form field).
10.29
10.30 Where a given field name is used in both the path and message body to
10.31 specify values, the values from both sources will be combined into a
10.32 @@ -300,7 +300,7 @@
10.33 return self._get_fields(encoding)
10.34 else:
10.35 fields = {}
10.36 - fields.update(self.get_fields_from_path())
10.37 + fields.update(self.get_fields_from_path(encoding))
10.38 for name, values in self._get_fields(encoding).items():
10.39 if not fields.has_key(name):
10.40 fields[name] = values
11.1 --- a/WebStack/__init__.py Sat Jan 14 01:51:20 2006 +0000
11.2 +++ b/WebStack/__init__.py Sat Jan 14 01:52:43 2006 +0000
11.3 @@ -20,6 +20,6 @@
11.4 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
11.5 """
11.6
11.7 -__version__ = "1.1.2"
11.8 +__version__ = "1.2"
11.9
11.10 # vim: tabstop=4 expandtab shiftwidth=4