Commit 474917d0 authored by Jim Fulton's avatar Jim Fulton

Added logic to return status code from publish method.

This is needed by the Bobo server.
parent 86eb9ee9
...@@ -516,7 +516,7 @@ Publishing a module using the ILU Requestor (future) ...@@ -516,7 +516,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.24 1996/10/29 19:21:43 jim Exp $""" $Id: Publish.py,v 1.25 1996/11/06 14:27:09 jim Exp $"""
#' #'
# Copyright # Copyright
# #
...@@ -569,6 +569,10 @@ $Id: Publish.py,v 1.24 1996/10/29 19:21:43 jim Exp $""" ...@@ -569,6 +569,10 @@ $Id: Publish.py,v 1.24 1996/10/29 19:21:43 jim Exp $"""
# (540) 371-6909 # (540) 371-6909
# #
# $Log: Publish.py,v $ # $Log: Publish.py,v $
# Revision 1.25 1996/11/06 14:27:09 jim
# Added logic to return status code from publish method.
# This is needed by the Bobo server.
#
# Revision 1.24 1996/10/29 19:21:43 jim # Revision 1.24 1996/10/29 19:21:43 jim
# Changed rule (and terminology) for acquiring authorization data # Changed rule (and terminology) for acquiring authorization data
# so that a subobject can aquire data from a container even if an # so that a subobject can aquire data from a container even if an
...@@ -674,7 +678,7 @@ $Id: Publish.py,v 1.24 1996/10/29 19:21:43 jim Exp $""" ...@@ -674,7 +678,7 @@ $Id: Publish.py,v 1.24 1996/10/29 19:21:43 jim Exp $"""
# #
# #
# #
__version__='$Revision: 1.24 $'[11:-2] __version__='$Revision: 1.25 $'[11:-2]
def main(): def main():
...@@ -760,6 +764,12 @@ class ModulePublisher: ...@@ -760,6 +764,12 @@ class ModulePublisher:
raise 'Unauthorized', v raise 'Unauthorized', v
self.forbiddenError() self.forbiddenError()
def get_request_data(self,request_params):
try: request_params=request_params()
except: pass
for key in request_params.keys():
self.request[key]=request_params[key]
def publish(self, module_name, published='web_objects', def publish(self, module_name, published='web_objects',
imported_modules={}, module_dicts={},debug=0): imported_modules={}, module_dicts={},debug=0):
...@@ -801,6 +811,12 @@ class ModulePublisher: ...@@ -801,6 +811,12 @@ class ModulePublisher:
try: realm=theModule.__realm__ try: realm=theModule.__realm__
except: realm=None except: realm=None
# Get request data from outermost environment:
try:
request_params=theModule.__request_data__
self.get_request_data(request_params)
except: pass
# Get initial group data: # Get initial group data:
default_inherited_groups={None:None} default_inherited_groups={None:None}
inherited_groups=default_inherited_groups inherited_groups=default_inherited_groups
...@@ -883,15 +899,7 @@ class ModulePublisher: ...@@ -883,15 +899,7 @@ class ModulePublisher:
except: pass except: pass
try: try:
request_params=getattr(subobject,'__request_data__') request_params=getattr(subobject,'__request_data__')
self.get_request_data(request_params)
# bleh, test gets around Python bug:
if not (type(request_params) is types.MethodType and
type(subobject) is types.ClassType):
try: request_params=request_params()
except: pass
for key in request_params.keys():
self.request[key]=request_params[key]
except: pass except: pass
except AttributeError: except AttributeError:
try: try:
...@@ -904,10 +912,7 @@ class ModulePublisher: ...@@ -904,10 +912,7 @@ class ModulePublisher:
try: try:
request_params=getattr(subobject,'__request_data__') request_params=getattr(subobject,'__request_data__')
try: request_params=request_params() self.get_request_data(request_params)
except: pass
for key in request_params.keys():
self.request[key]=request_params[key]
except: pass except: pass
try: try:
groups=subobject.__allow_groups__ groups=subobject.__allow_groups__
...@@ -1418,6 +1423,7 @@ def publish_module(module_name, ...@@ -1418,6 +1423,7 @@ def publish_module(module_name,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
environ=os.environ, debug=0): environ=os.environ, debug=0):
must_die=0 must_die=0
status=200
try: try:
response=Response(stdout=stdout, stderr=stderr) response=Response(stdout=stdout, stderr=stderr)
publisher = CGIModulePublisher(stdin=stdin, stdout=stdout, publisher = CGIModulePublisher(stdin=stdin, stdout=stdout,
...@@ -1434,10 +1440,13 @@ def publish_module(module_name, ...@@ -1434,10 +1440,13 @@ def publish_module(module_name,
must_die=1 must_die=1
response.exception(must_die) response.exception(must_die)
except: except:
status=response.getStatus()
response.exception() response.exception()
if response: response=str(response) if response:
response=str(response)
if response: stdout.write(response) if response: stdout.write(response)
if must_die: if must_die:
raise sys.exc_type, sys.exc_value, sys.exc_traceback raise sys.exc_type, sys.exc_value, sys.exc_traceback
sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None
return status
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