diff -ur -xdemo.cgi -x'*.patch' /scratch/quixote/Quixote-1.0b1/http_request.py ./http_request.py --- /scratch/quixote/Quixote-1.0b1/http_request.py 2004-04-12 11:52:00.000000000 -0400 +++ ./http_request.py 2004-04-18 15:56:47.000000000 -0400 @@ -73,8 +73,8 @@ To access environment variables associated with the request, use get_environ(): eg. request.get_environ('SERVER_PORT', 80). - To access form variables, use get_form_var(), eg. - request.get_form_var("name"). + To access form variables (aka request parameters), use + get_parameter(), eg. request.get_parameter("name"). To access cookies, use get_cookie(). @@ -98,7 +98,7 @@ self.content_type = get_content_type(environ) else: self.content_type = content_type - self.form = {} + self.parameters = {} self.session = None self.response = HTTPResponse() self.start_time = None @@ -131,16 +131,26 @@ path = path[len(script):] self.environ['PATH_INFO'] = path - def add_form_value (self, key, value): - if self.form.has_key(key): - found = self.form[key] + def __getattr__(self, attr): + # For backwards compatibility with Quixote 1.0b1 and earlier. + if attr == 'form': + return self.parameters + else: + raise AttributeError(attr) + + def add_parameter (self, key, value): + if self.parameters.has_key(key): + found = self.parameters[key] if type(found) is ListType: found.append(value) else: found = [found, value] - self.form[key] = found + self.parameters[key] = found else: - self.form[key] = value + self.parameters[key] = value + + # For backwards compatibility with Quixote 1.0b1 and earlier. + add_form_value = add_parameter def process_inputs (self): """Process request inputs. @@ -162,7 +172,7 @@ fs = FieldStorage(fp=fp, environ=self.environ, keep_blank_values=1) if fs.list: for item in fs.list: - self.add_form_value(item.name, item.value) + self.add_parameter(item.name, item.value) def get_header (self, name, default=None): """get_header(name : string, default : string = None) -> string @@ -185,8 +195,11 @@ def get_cookie (self, cookie_name, default=None): return self.cookies.get(cookie_name, default) - def get_form_var (self, var_name, default=None): - return self.form.get(var_name, default) + def get_parameter (self, name, default=None): + return self.parameters.get(name, default) + + # For backwards compatibility with Quixote 1.0b1 and earlier. + get_form_var = get_parameter def get_method (self): """Returns the HTTP method for this request @@ -194,7 +207,7 @@ return self.environ.get('REQUEST_METHOD', 'GET') def formiter (self): - return self.form.iteritems() + return self.parameters.iteritems() # The following environment variables are useful for reconstructing # the original URL, all of which are specified by CGI 1.1: @@ -336,7 +349,7 @@ lines = ["

form

", ""] - for k,v in self.form.items(): + for k,v in self.parameters.items(): lines.append(row_fmt % (html_quote(k), html_quote(v))) lines += ["
", "

cookies

", @@ -358,7 +371,7 @@ row='%-15s %s' result.append("Form:") - L = self.form.items() ; L.sort() + L = self.parameters.items() ; L.sort() for k,v in L: result.append(row % (k,v)) diff -ur -xdemo.cgi -x'*.patch' /scratch/quixote/Quixote-1.0b1/upload.py ./upload.py --- /scratch/quixote/Quixote-1.0b1/upload.py 2004-04-12 11:52:00.000000000 -0400 +++ ./upload.py 2004-04-18 16:07:53.000000000 -0400 @@ -238,16 +238,16 @@ HTTPUploadRequest then creates an Upload object which contains the various filenames for this upload. - Other form variables are stored as usual in the 'form' dictionary, - to be fetched later with get_form_var(). Uploaded files can also be - accessed via get_form_var(), which returns the Upload object created + Other form variables are stored as usual in the 'parameters' dictionary, + to be fetched later with get_parameter(). Uploaded files can also be + accessed via get_parameter(), which returns the Upload object created at upload-time, rather than a string. Eg. if your upload form contains this: then, when processing the form, you might do this: - upload = request.get_form_var("upload") + upload = request.get_parameter("upload") after which you could open the uploaded file immediately: file = open(upload.tmp_filename) @@ -306,7 +306,7 @@ upload = Upload(filename) self.check_upload_dir() done = upload.receive(file, boundary, self.upload_dir) - self.add_form_value(name, upload) + self.add_parameter(name, upload) return done def handle_regular_var (self, name, file, boundary): @@ -316,8 +316,7 @@ value = lines[0] else: value = "\n".join(lines) - self.add_form_value(name, value) - #form_vars.append((name, value)) + self.add_parameter(name, value) return done def parse_body (self, file, boundary):