Commit 2418690b authored by Jim Fulton's avatar Jim Fulton

Fixed bugs:

  - object[entryname] can fail with attribute as well as type error
  - flatten didn't work with multiple values\
  - inserted base was not absolute

Added transaction support.
parent 1c1d9186
...@@ -444,7 +444,7 @@ Publishing a module using the ILU Requestor (future) ...@@ -444,7 +444,7 @@ Publishing a module using the ILU Requestor (future)
o Configure the web server to call module_name@server_name with o Configure the web server to call module_name@server_name with
the requestor. the requestor.
$Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $""" $Id: Publish.py,v 1.9 1996/07/23 19:59:29 jfulton Exp $"""
#' #'
# Copyright # Copyright
# #
...@@ -497,6 +497,15 @@ $Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $""" ...@@ -497,6 +497,15 @@ $Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $"""
# (540) 371-6909 # (540) 371-6909
# #
# $Log: Publish.py,v $ # $Log: Publish.py,v $
# Revision 1.9 1996/07/23 19:59:29 jfulton
# Fixed bugs:
#
# - object[entryname] can fail with attribute as well as type error
# - flatten didn't work with multiple values\
# - inserted base was not absolute
#
# Added transaction support.
#
# Revision 1.8 1996/07/18 14:59:54 jfulton # Revision 1.8 1996/07/18 14:59:54 jfulton
# Fixed bug in getting web_objects. # Fixed bug in getting web_objects.
# #
...@@ -526,7 +535,7 @@ $Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $""" ...@@ -526,7 +535,7 @@ $Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $"""
# #
# #
# #
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
def main(): def main():
...@@ -693,12 +702,12 @@ class ModulePublisher: ...@@ -693,12 +702,12 @@ class ModulePublisher:
except: except:
try: realm=object[entry_name+'__realm__'] try: realm=object[entry_name+'__realm__']
except: pass except: pass
except TypeError: except (TypeError,AttributeError):
if not path and entry_name=='help' and doc: if not path and entry_name=='help' and doc:
object=doc object=doc
entry_name, subobject = ( entry_name, subobject = (
'__doc__', self.html '__doc__', self.html
('Documentation for' + ('Documentation for ' +
((self.env('PATH_INFO') or ((self.env('PATH_INFO') or
('/'+self.module_name))[1:]), ('/'+self.module_name))[1:]),
'<pre>\n%s\n</pre>' % doc) '<pre>\n%s\n</pre>' % doc)
...@@ -758,9 +767,17 @@ class ModulePublisher: ...@@ -758,9 +767,17 @@ class ModulePublisher:
self.badRequestError(argument_name) self.badRequestError(argument_name)
# Attempt to start a transaction:
try:
transaction=get_transaction()
transaction.begin()
except: transaction=None
if args: result=apply(object,tuple(args)) if args: result=apply(object,tuple(args))
else: result=object() else: result=object()
if transaction: transaction.commit()
if result and result is not response: response.setBody(result) if result and result is not response: response.setBody(result)
return response return response
...@@ -780,7 +797,7 @@ def str_field(v): ...@@ -780,7 +797,7 @@ def str_field(v):
except: pass except: pass
return v return v
def flatten_field(v,converter): def flatten_field(v,converter=None):
if type(v) is types.ListType: if type(v) is types.ListType:
if len(v) > 1: return map(flatten_field,v) if len(v) > 1: return map(flatten_field,v)
v=v[0] v=v[0]
...@@ -873,7 +890,7 @@ class Request: ...@@ -873,7 +890,7 @@ class Request:
categories. The search order is environment variables, categories. The search order is environment variables,
other variables, form data, and then cookies. other variables, form data, and then cookies.
""" """ #"
try: try:
v= self.environ[key] v= self.environ[key]
if self.special_names.has_key(key) or key[:5] == 'HTTP_': if self.special_names.has_key(key) or key[:5] == 'HTTP_':
...@@ -967,10 +984,15 @@ class CGIModulePublisher(ModulePublisher): ...@@ -967,10 +984,15 @@ class CGIModulePublisher(ModulePublisher):
self.stdout=stdout self.stdout=stdout
self.stderr=stderr self.stderr=stderr
b=string.strip(self.environ['SCRIPT_NAME']) b=string.strip(self.environ['SCRIPT_NAME'])
if b[-1]=='/': b=b[:-1] while b and b[-1]=='/': b=b[:-1]
p = string.rfind(b,'/') p = string.rfind(b,'/')
if p >= 0: self.base=b[:p+1] if p >= 0: b=b[:p+1]
else: self.base='' else: b=''
while b and b[0]=='/': b=b[1:]
try: server_url= string.strip(self.environ['SERVER_URL' ])
except: server_url='http://'+string.strip(self.environ['SERVER_NAME'])
self.base="%s/%s" % (server_url,b)
def publish_module(module_name, def publish_module(module_name,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
......
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