Commit a838d256 authored by Jim Fulton's avatar Jim Fulton

Changes to make shutdown methods work properly. Now shutdown methods

can simply sys.exit(0).

Added on-line documentation and debugging support to bobo.
parent 6fe74245
...@@ -517,7 +517,7 @@ Publishing a module using the ILU Requestor (future) ...@@ -517,7 +517,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.19 1996/09/13 22:51:35 jim Exp $""" $Id: Publish.py,v 1.20 1996/09/16 14:43:27 jim Exp $"""
#' #'
# Copyright # Copyright
# #
...@@ -570,6 +570,12 @@ $Id: Publish.py,v 1.19 1996/09/13 22:51:35 jim Exp $""" ...@@ -570,6 +570,12 @@ $Id: Publish.py,v 1.19 1996/09/13 22:51:35 jim Exp $"""
# (540) 371-6909 # (540) 371-6909
# #
# $Log: Publish.py,v $ # $Log: Publish.py,v $
# Revision 1.20 1996/09/16 14:43:27 jim
# Changes to make shutdown methods work properly. Now shutdown methods
# can simply sys.exit(0).
#
# Added on-line documentation and debugging support to bobo.
#
# Revision 1.19 1996/09/13 22:51:35 jim # Revision 1.19 1996/09/13 22:51:35 jim
# *** empty log message *** # *** empty log message ***
# #
...@@ -653,7 +659,7 @@ $Id: Publish.py,v 1.19 1996/09/13 22:51:35 jim Exp $""" ...@@ -653,7 +659,7 @@ $Id: Publish.py,v 1.19 1996/09/13 22:51:35 jim Exp $"""
# #
# #
# #
__version__='$Revision: 1.19 $'[11:-2] __version__='$Revision: 1.20 $'[11:-2]
def main(): def main():
...@@ -1024,7 +1030,7 @@ class ModulePublisher: ...@@ -1024,7 +1030,7 @@ class ModulePublisher:
return response return response
def call_object(self,object,args): def call_object(self,object,args):
result=apply(object,args) result=apply(object,args) # Type s<cr> to step into published object.
return result return result
def sad_pathetic_persistence_hack(object): def sad_pathetic_persistence_hack(object):
...@@ -1385,6 +1391,9 @@ def publish_module(module_name, ...@@ -1385,6 +1391,9 @@ def publish_module(module_name,
environ=environ) environ=environ)
response = publisher.response response = publisher.response
response = publisher.publish(module_name,debug=debug) response = publisher.publish(module_name,debug=debug)
except SystemExit:
must_die=1
response.exception(must_die)
except ImportError, v: except ImportError, v:
sys.exc_type, sys.exc_value, sys.exc_traceback = v sys.exc_type, sys.exc_value, sys.exc_traceback = v
must_die=1 must_die=1
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
__doc__='''CGI Response Output formatter __doc__='''CGI Response Output formatter
$Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $''' $Id: Response.py,v 1.11 1996/09/16 14:43:25 jim Exp $'''
# Copyright # Copyright
# #
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne # Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...@@ -55,6 +55,12 @@ $Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $''' ...@@ -55,6 +55,12 @@ $Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $'''
# (540) 371-6909 # (540) 371-6909
# #
# $Log: Response.py,v $ # $Log: Response.py,v $
# Revision 1.11 1996/09/16 14:43:25 jim
# Changes to make shutdown methods work properly. Now shutdown methods
# can simply sys.exit(0).
#
# Added on-line documentation and debugging support to bobo.
#
# Revision 1.10 1996/09/13 22:52:10 jim # Revision 1.10 1996/09/13 22:52:10 jim
# *** empty log message *** # *** empty log message ***
# #
...@@ -103,7 +109,7 @@ $Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $''' ...@@ -103,7 +109,7 @@ $Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $'''
# #
# #
# #
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import string, types, sys, regex, regsub import string, types, sys, regex, regsub
...@@ -454,6 +460,7 @@ class Response: ...@@ -454,6 +460,7 @@ class Response:
n = n+1 n = n+1
result.append(string.joinfields( result.append(string.joinfields(
traceback.format_exception_only(etype, value), ' ')) traceback.format_exception_only(etype, value), ' '))
sys.exc_type,sys.exc_value,sys.exc_traceback=etype,value,tb
return result return result
def _traceback(self,t,v,tb): def _traceback(self,t,v,tb):
...@@ -487,10 +494,16 @@ class Response: ...@@ -487,10 +494,16 @@ class Response:
b=v b=v
if fatal: if fatal:
return self.setBody( if t is SystemExit and v==0:
(str(t), return self.setBody(
'Sorry, a SERIOUS APPLICATION ERROR occurred.<p>' (str(t),
+ self._traceback(t,v,tb))) 'This application has exited normally.<p>'
+ self._traceback(t,v,tb)))
else:
return self.setBody(
(str(t),
'Sorry, a SERIOUS APPLICATION ERROR occurred.<p>'
+ self._traceback(t,v,tb)))
if type(b) is not types.StringType or regex.search('[ \t\n]',b) < 0: if type(b) is not types.StringType or regex.search('[ \t\n]',b) < 0:
return self.setBody( return self.setBody(
......
...@@ -9,10 +9,42 @@ Usage: ...@@ -9,10 +9,42 @@ Usage:
Options: Options:
-u username=password -u username:password
Supply HTTP authorization information
$Id: Test.py,v 1.1 1996/09/13 22:51:52 jim Exp $''' -p profiler_data_file
Run under profiler control, generating the profiler
data file, profiler_data_file.
-d
Run in debug mode. With this option, bobo will run
under Python debugger control. Two useful breakpoints
are set. The first is at the beginning of the module
publishing code. Steping through this code shows how
bobo finds objects and obtains certain meta-data. The
second breakpoint is at the point just before the published
object is called. To jump to the second breakpoint, you must
enter 's' followed by a carriage return to step into the
module, then enter a 'c' followed by a carriage return to
jump to the first breakpoint and then another 'c' followed by
a carriage return to jump to the point where the object is
called. Finally, enter 's' followed a carriage return.
For example, to debug a published object (such as a method)
spam the following might be entered::
bobo -d /prj/lib/python/mymod container/spam
s
c
c
s
$Id: Test.py,v 1.2 1996/09/16 14:43:26 jim Exp $
'''
# Copyright # Copyright
# #
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne # Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...@@ -64,12 +96,18 @@ $Id: Test.py,v 1.1 1996/09/13 22:51:52 jim Exp $''' ...@@ -64,12 +96,18 @@ $Id: Test.py,v 1.1 1996/09/13 22:51:52 jim Exp $'''
# (540) 371-6909 # (540) 371-6909
# #
# $Log: Test.py,v $ # $Log: Test.py,v $
# Revision 1.2 1996/09/16 14:43:26 jim
# Changes to make shutdown methods work properly. Now shutdown methods
# can simply sys.exit(0).
#
# Added on-line documentation and debugging support to bobo.
#
# Revision 1.1 1996/09/13 22:51:52 jim # Revision 1.1 1996/09/13 22:51:52 jim
# *** empty log message *** # *** empty log message ***
# #
# #
# #
__version__='$Revision: 1.1 $'[11:-2] __version__='$Revision: 1.2 $'[11:-2]
#! /usr/local/bin/python #! /usr/local/bin/python
...@@ -85,7 +123,7 @@ def main(): ...@@ -85,7 +123,7 @@ def main():
try: try:
optlist,args=getopt.getopt(sys.argv[1:], 'du:p:') optlist,args=getopt.getopt(sys.argv[1:], 'du:p:')
if len(args) > 2: raise TypeError, None if len(args) > 2 or len(args) < 1: raise TypeError, None
if len(args) == 2: path_info=args[1] if len(args) == 2: path_info=args[1]
except: except:
sys.stderr.write(__doc__) sys.stderr.write(__doc__)
...@@ -178,12 +216,12 @@ def publish(script,path_info,u=None,p=None,d=None): ...@@ -178,12 +216,12 @@ def publish(script,path_info,u=None,p=None,d=None):
code=ModulePublisher.call_object.im_func.func_code code=ModulePublisher.call_object.im_func.func_code
lineno = codehack.getlineno(code) lineno = codehack.getlineno(code)
filename = code.co_filename filename = code.co_filename
db.set_break(filename,lineno) db.set_break(filename,lineno+1)
db.prompt='pdb> ' db.prompt='pdb> '
# db.set_continue() # db.set_continue()
print '''Type "s<cr>c<cr>" to jump to beginning of real print '''Type "s<cr>c<cr>" to jump to beginning of real
publishing process. Then type c<ret> to jub to publishing process. Then type c<ret> to jump to
published object call.''' published object call.'''
db.run('publish_module(file,environ=env,debug=1)', db.run('publish_module(file,environ=env,debug=1)',
cgi_module_publisher.__dict__, cgi_module_publisher.__dict__,
......
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