Commit 62fefe19 authored by Jim Fulton's avatar Jim Fulton

Added BODY and BODYFILE keys to the requests (rather than getting

BODY directly on init, which is too expensive).
parent c87aa172
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
from string import join, split, find, rfind, lower, upper from string import join, split, find, rfind, lower, upper
from urllib import quote from urllib import quote
...@@ -117,6 +117,7 @@ class BaseRequest: ...@@ -117,6 +117,7 @@ class BaseRequest:
collection of variable to value mappings. collection of variable to value mappings.
""" """
_file=None
common={} # Common request data common={} # Common request data
_auth=None _auth=None
...@@ -153,6 +154,20 @@ class BaseRequest: ...@@ -153,6 +154,20 @@ class BaseRequest:
if v is not _marker: return v if v is not _marker: return v
v=self.common.get(key, default) v=self.common.get(key, default)
if v is not _marker: return v if v is not _marker: return v
if key=='BODY' and self._file is not None:
p=self._file.tell()
self._file.seek(0)
v=self._file.read()
self._file.seek(p)
self.other[key]=v
return v
if key=='BODYFILE' and self._file is not None:
v=self._file
self.other[key]=v
return v
raise KeyError, key raise KeyError, key
__getattr__=get=__getitem__ __getattr__=get=__getitem__
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import regex, sys, os, string import regex, sys, os, string
from string import lower, atoi, rfind, split, strip, join, upper, find from string import lower, atoi, rfind, split, strip, join, upper, find
...@@ -212,7 +212,7 @@ class HTTPRequest(BaseRequest): ...@@ -212,7 +212,7 @@ class HTTPRequest(BaseRequest):
meth, self.args = xmlrpc.parse_input(fs.value) meth, self.args = xmlrpc.parse_input(fs.value)
response=xmlrpc.response(response) response=xmlrpc.response(response)
else: else:
form['BODY']=fs.value self._file=fs.file
else: else:
fslist=fs.list fslist=fs.list
tuple_items={} tuple_items={}
...@@ -638,21 +638,35 @@ class HTTPRequest(BaseRequest): ...@@ -638,21 +638,35 @@ class HTTPRequest(BaseRequest):
if key=='REQUEST': return self if key=='REQUEST': return self
if key[:1]=='B' and BASEmatch(key) >= 0: if key[:1]=='B':
n=ord(key[4])-ord('0') if BASEmatch(key) >= 0:
if n: n=ord(key[4])-ord('0')
if self.environ.get('SCRIPT_NAME',''): n=n-1 if n:
if len(self.steps) < n: if self.environ.get('SCRIPT_NAME',''): n=n-1
raise KeyError, key if len(self.steps) < n:
raise KeyError, key
v=self.script
while v[-1:]=='/': v=v[:-1] v=self.script
v=join([v]+self.steps[:n],'/') while v[-1:]=='/': v=v[:-1]
else: v=join([v]+self.steps[:n],'/')
v=self.base else:
while v[-1:]=='/': v=v[:-1] v=self.base
other[key]=v while v[-1:]=='/': v=v[:-1]
return v other[key]=v
return v
if key=='BODY' and self._file is not None:
p=self._file.tell()
self._file.seek(0)
v=self._file.read()
self._file.seek(p)
self.other[key]=v
return v
if key=='BODYFILE' and self._file is not None:
v=self._file
self.other[key]=v
return v
v=self.common.get(key, default) v=self.common.get(key, default)
if v is not _marker: return v if v is not _marker: return v
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment