Commit 6fe74245 authored by Jim Fulton's avatar Jim Fulton

*** empty log message ***

parent dd8f0382
......@@ -517,7 +517,7 @@ Publishing a module using the ILU Requestor (future)
o Configure the web server to call module_name@server_name with
the requestor.
$Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
$Id: Publish.py,v 1.19 1996/09/13 22:51:35 jim Exp $"""
#'
# Copyright
#
......@@ -570,6 +570,9 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
# (540) 371-6909
#
# $Log: Publish.py,v $
# Revision 1.19 1996/09/13 22:51:35 jim
# *** empty log message ***
#
# Revision 1.18 1996/08/30 23:40:40 jfulton
# Fixed bug in argument marshalling!!!
#
......@@ -650,7 +653,7 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
#
#
#
__version__='$Revision: 1.18 $'[11:-2]
__version__='$Revision: 1.19 $'[11:-2]
def main():
......@@ -737,7 +740,7 @@ class ModulePublisher:
self.forbiddenError()
def publish(self, module_name, published='web_objects',
imported_modules={}, module_dicts={}):
imported_modules={}, module_dicts={},debug=0):
# First check for "cancel" redirect:
cancel=''
......@@ -815,14 +818,26 @@ class ModulePublisher:
URL=self.script
parents=[]
# sad_pathetic_persistence_hack:
try: setstate=object.__dict__['_p_setstate']
except: setstate=None
if setstate: setstate(object)
while path:
sad_pathetic_persistence_hack(object)
# sad_pathetic_persistence_hack(object)
entry_name,path=path[0], path[1:]
URL="%s/%s" % (URL,entry_name)
default_realm_name="%s.%s" % (entry_name,default_realm_name)
if entry_name:
try:
subobject=getattr(object,entry_name)
# sad_pathetic_persistence_hack:
try: setstate=subobject.__dict__['_p_setstate']
except: setstate=None
if setstate: setstate(subobject)
try:
groups=subobject.__allow_groups__
inherited_groups=allow_group_composition(
......@@ -857,6 +872,12 @@ class ModulePublisher:
except AttributeError:
try:
subobject=object[entry_name]
# sad_pathetic_persistence_hack:
try: setstate=subobject.__dict__['_p_setstate']
except: setstate=None
if setstate: setstate(subobject)
try:
request_params=getattr(subobject,'__request_data__')
try: request_params=request_params()
......@@ -888,7 +909,7 @@ class ModulePublisher:
realm=object[entry_name+'__realm__']
realm_name=default_realm_name
except: pass
except (TypeError,AttributeError,KeyError):
except (TypeError,AttributeError,KeyError), mess:
if not path and entry_name=='help' and doc:
object=doc
entry_name, subobject = (
......@@ -899,7 +920,7 @@ class ModulePublisher:
'<pre>\n%s\n</pre>' % doc)
)
else:
self.notFoundError(entry_name)
self.notFoundError("%s: %s" % (entry_name,mess))
if published:
# Bypass simple checks the first time
published=None
......@@ -993,9 +1014,8 @@ class ModulePublisher:
raise 'BadRequest', ('<strong>Invalid entry for %s </strong>'
% argument_name)
if args: result=apply(object,tuple(args))
else: result=object()
if debug: result=self.call_object(object,tuple(args))
else: result=apply(object,tuple(args))
if result and result is not response: response.setBody(result)
......@@ -1003,6 +1023,10 @@ class ModulePublisher:
return response
def call_object(self,object,args):
result=apply(object,args)
return result
def sad_pathetic_persistence_hack(object):
try: setstate=object.__dict__['_p_setstate']
except: return
......@@ -1352,7 +1376,7 @@ class CGIModulePublisher(ModulePublisher):
def publish_module(module_name,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
environ=os.environ):
environ=os.environ, debug=0):
must_die=0
try:
response=Response(stdout=stdout, stderr=stderr)
......@@ -1360,7 +1384,7 @@ def publish_module(module_name,
stderr=stderr,
environ=environ)
response = publisher.response
response = publisher.publish(module_name)
response = publisher.publish(module_name,debug=debug)
except ImportError, v:
sys.exc_type, sys.exc_value, sys.exc_traceback = v
must_die=1
......
......@@ -3,7 +3,7 @@
__doc__='''CGI Response Output formatter
$Id: Response.py,v 1.9 1996/08/30 23:28:29 jfulton Exp $'''
$Id: Response.py,v 1.10 1996/09/13 22:52:10 jim Exp $'''
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
......@@ -55,6 +55,9 @@ $Id: Response.py,v 1.9 1996/08/30 23:28:29 jfulton Exp $'''
# (540) 371-6909
#
# $Log: Response.py,v $
# Revision 1.10 1996/09/13 22:52:10 jim
# *** empty log message ***
#
# Revision 1.9 1996/08/30 23:28:29 jfulton
# Added code to map 300 redirects to 302.
#
......@@ -100,7 +103,7 @@ $Id: Response.py,v 1.9 1996/08/30 23:28:29 jfulton Exp $'''
#
#
#
__version__='$Revision: 1.9 $'[11:-2]
__version__='$Revision: 1.10 $'[11:-2]
import string, types, sys, regex, regsub
......@@ -544,8 +547,6 @@ class Response:
if not headers.has_key('content-type') and self.status == 200:
self.setStatus('nocontent')
def upcase(s): return string.upper(s[:1])+s[1:]
headersl=map(
lambda k,d=headers, upcase=upcase:
"%s: %s" % (upcase(k),d[k]),
......@@ -590,6 +591,17 @@ class Response:
write('\n\n')
write(body)
def upcase(s):
s=string.upper(s[:1])+s[1:]
l=string.find(s,'-')
if l > 0:
l=l+1
return s[:l]+upcase(s[l:])
else:
return s
def main():
print Response('hello world')
print '-' * 70
......
#!/usr/local/bin/python
# $What$
__doc__='''Bobo test script
Usage:
bobo [options] module_path [path_info]
Options:
-u username=password
$Id: Test.py,v 1.1 1996/09/13 22:51:52 jim Exp $'''
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved. Copyright in this software is owned by DCLC,
# unless otherwise indicated. Permission to use, copy and
# distribute this software is hereby granted, provided that the
# above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear. Note that
# any product, process or technology described in this software
# may be the subject of other Intellectual Property rights
# reserved by Digital Creations, L.C. and are not licensed
# hereunder.
#
# Trademarks
#
# Digital Creations & DCLC, are trademarks of Digital Creations, L.C..
# All other trademarks are owned by their respective companies.
#
# No Warranty
#
# The software is provided "as is" without warranty of any kind,
# either express or implied, including, but not limited to, the
# implied warranties of merchantability, fitness for a particular
# purpose, or non-infringement. This software could include
# technical inaccuracies or typographical errors. Changes are
# periodically made to the software; these changes will be
# incorporated in new editions of the software. DCLC may make
# improvements and/or changes in this software at any time
# without notice.
#
# Limitation Of Liability
#
# In no event will DCLC be liable for direct, indirect, special,
# incidental, economic, cover, or consequential damages arising
# out of the use of or inability to use this software even if
# advised of the possibility of such damages. Some states do not
# allow the exclusion or limitation of implied warranties or
# limitation of liability for incidental or consequential
# damages, so the above limitation or exclusion may not apply to
# you.
#
#
# If you have questions regarding this software,
# contact:
#
# Jim Fulton, jim@digicool.com
#
# (540) 371-6909
#
# $Log: Test.py,v $
# Revision 1.1 1996/09/13 22:51:52 jim
# *** empty log message ***
#
#
#
__version__='$Revision: 1.1 $'[11:-2]
#! /usr/local/bin/python
import sys,traceback
from cgi_module_publisher import publish_module
o=open('/dev/null','w')
def main():
import sys, os, getopt, string
try:
optlist,args=getopt.getopt(sys.argv[1:], 'du:p:')
if len(args) > 2: raise TypeError, None
if len(args) == 2: path_info=args[1]
except:
sys.stderr.write(__doc__)
sys.exit(-1)
profile=u=debug=None
for opt,val in optlist:
if opt=='-d':
debug=1
if opt=='-u':
u=val
elif opt=='-p':
profile=val
publish(args[0],path_info,u=u,p=profile,d=debug)
def publish(script,path_info,u=None,p=None,d=None):
import sys, os, getopt, string
profile=p
debug=d
env={'SERVER_NAME':'bobo.server',
'SERVER_PORT':'80',
'REQUEST_METHOD':'GET',
'REMOTE_ADDR': '204.183.226.81 ',
'REMOTE_HOST': 'bobo.remote.host',
'HTTP_USER_AGENT': 'Bobo/%s' % __version__,
'HTTP_HOST': 'ninny.digicool.com:8081 ',
'SERVER_SOFTWARE': 'Bobo/%s' % __version__,
'SERVER_PROTOCOL': 'HTTP/1.0 ',
'HTTP_ACCEPT': 'image/gif, image/x-xbitmap, image/jpeg, */* ',
'SERVER_HOSTNAME': 'bobo.server.host',
'GATEWAY_INTERFACE': 'CGI/1.1 ',
}
env['SCRIPT_NAME']=script
p=string.split(path_info,'?')
if len(p)==1: env['PATH_INFO'] = p[0]
elif len(p)==2: [env['PATH_INFO'], env['QUERY_STRING']]=p
else: raise TypeError, ''
if u:
import base64
env['HTTP_AUTHORIZATION']="Basic %s" % base64.encodestring(u)
dir,file=os.path.split(script)
sys.path[0:0]=[dir]
if profile:
import __main__
from profile import run
__main__.publish_module=publish_module
__main__.file=file
__main__.env=env
print profile
if profile: run('publish_module(file, environ=env)',profile)
else: run('publish_module(file, environ=env)')
elif debug:
import cgi_module_publisher
from cgi_module_publisher import ModulePublisher
import pdb
class Pdb(pdb.Pdb):
def do_pub(self,arg):
if hasattr(self,'done_pub'):
print 'pub already done.'
else:
self.do_s('')
self.do_s('')
self.do_c('')
self.done_pub=1
def do_ob(self,arg):
if hasattr(self,'done_ob'):
print 'ob already done.'
else:
self.do_pub('')
self.do_c('')
self.done_ob=1
import codehack
db=Pdb()
code=ModulePublisher.publish.im_func.func_code
lineno = codehack.getlineno(code)
filename = code.co_filename
db.set_break(filename,lineno)
code=ModulePublisher.call_object.im_func.func_code
lineno = codehack.getlineno(code)
filename = code.co_filename
db.set_break(filename,lineno)
db.prompt='pdb> '
# db.set_continue()
print '''Type "s<cr>c<cr>" to jump to beginning of real
publishing process. Then type c<ret> to jub to
published object call.'''
db.run('publish_module(file,environ=env,debug=1)',
cgi_module_publisher.__dict__,
{'file':file, 'env':env})
else:
publish_module(file, environ=env)
if __name__ == "__main__": main()
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