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 @@
# 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 urllib import quote
......@@ -117,6 +117,7 @@ class BaseRequest:
collection of variable to value mappings.
"""
_file=None
common={} # Common request data
_auth=None
......@@ -153,6 +154,20 @@ class BaseRequest:
if v is not _marker: return v
v=self.common.get(key, default)
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
__getattr__=get=__getitem__
......
......@@ -83,7 +83,7 @@
#
##############################################################################
__version__='$Revision: 1.10 $'[11:-2]
__version__='$Revision: 1.11 $'[11:-2]
import regex, sys, os, string
from string import lower, atoi, rfind, split, strip, join, upper, find
......@@ -212,7 +212,7 @@ class HTTPRequest(BaseRequest):
meth, self.args = xmlrpc.parse_input(fs.value)
response=xmlrpc.response(response)
else:
form['BODY']=fs.value
self._file=fs.file
else:
fslist=fs.list
tuple_items={}
......@@ -638,21 +638,35 @@ class HTTPRequest(BaseRequest):
if key=='REQUEST': return self
if key[:1]=='B' and BASEmatch(key) >= 0:
n=ord(key[4])-ord('0')
if n:
if self.environ.get('SCRIPT_NAME',''): n=n-1
if len(self.steps) < n:
raise KeyError, key
v=self.script
while v[-1:]=='/': v=v[:-1]
v=join([v]+self.steps[:n],'/')
else:
v=self.base
while v[-1:]=='/': v=v[:-1]
other[key]=v
return v
if key[:1]=='B':
if BASEmatch(key) >= 0:
n=ord(key[4])-ord('0')
if n:
if self.environ.get('SCRIPT_NAME',''): n=n-1
if len(self.steps) < n:
raise KeyError, key
v=self.script
while v[-1:]=='/': v=v[:-1]
v=join([v]+self.steps[:n],'/')
else:
v=self.base
while v[-1:]=='/': v=v[:-1]
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)
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