1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: cgi_client.py,v 1.105 2002-02-20 05:52:10 richard Exp $
18+ # $Id: cgi_client.py,v 1.106 2002-02-21 06:23:00 richard Exp $
1919
2020__doc__ = """
2121WWW request handler (also used in the stand-alone server).
@@ -52,6 +52,11 @@ def __init__(self, instance, request, env, form=None):
5252 self .env = env
5353 self .path = env ['PATH_INFO' ]
5454 self .split_path = self .path .split ('/' )
55+ url = self .env ['SCRIPT_NAME' ] + '/'
56+ machine = self .env ['SERVER_NAME' ]
57+ port = self .env ['SERVER_PORT' ]
58+ if port != '80' : machine = machine + ':' + port
59+ self .base = urlparse .urlunparse (('http' , machine , url , None ,None ,None ))
5560
5661 if form is None :
5762 self .form = cgi .FieldStorage (environ = env )
@@ -80,7 +85,7 @@ def header(self, headers={'Content-Type':'text/html'}):
8085 if self .debug :
8186 self .headers_sent = headers
8287
83- single_submit_script = '''
88+ global_javascript = '''
8489<script language="javascript">
8590submitted = false;
8691function submit_once() {
@@ -91,15 +96,14 @@ def header(self, headers={'Content-Type':'text/html'}):
9196 submitted = true;
9297 return 1;
9398}
99+ function help_window(helpurl) {
100+ helpwin = window.open(%(base)s + helpurl, 'HelpWindow',
101+ 'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
102+ }
94103</script>
95104'''
96105
97106 def pagehead (self , title , message = None ):
98- url = self .env ['SCRIPT_NAME' ] + '/'
99- machine = self .env ['SERVER_NAME' ]
100- port = self .env ['SERVER_PORT' ]
101- if port != '80' : machine = machine + ':' + port
102- base = urlparse .urlunparse (('http' , machine , url , None , None , None ))
103107 if message is not None :
104108 message = _ ('<div class="system-msg">%(message)s</div>' )% locals ()
105109 else :
@@ -127,12 +131,12 @@ def pagehead(self, title, message=None):
127131''' )
128132 else :
129133 add_links = ''
130- single_submit_script = self .single_submit_script
134+ global_javascript = self .global_javascript % self . __dict__
131135 self .write (_ ('''<html><head>
132136<title>%(title)s</title>
133137<style type="text/css">%(style)s</style>
134138</head>
135- %(single_submit_script )s
139+ %(global_javascript )s
136140<body bgcolor=#ffffff>
137141%(message)s
138142<table width=100%% border=0 cellspacing=0 cellpadding=2>
@@ -1160,11 +1164,6 @@ class ExtendedClient(Client):
11601164 default_index_filterspec = {'status' : ['1' , '2' , '3' , '4' , '5' , '6' , '7' ]}
11611165
11621166 def pagehead (self , title , message = None ):
1163- url = self .env ['SCRIPT_NAME' ] + '/' #self.env.get('PATH_INFO', '/')
1164- machine = self .env ['SERVER_NAME' ]
1165- port = self .env ['SERVER_PORT' ]
1166- if port != '80' : machine = machine + ':' + port
1167- base = urlparse .urlunparse (('http' , machine , url , None , None , None ))
11681167 if message is not None :
11691168 message = _ ('<div class="system-msg">%(message)s</div>' )% locals ()
11701169 else :
@@ -1194,12 +1193,12 @@ def pagehead(self, title, message=None):
11941193''' )
11951194 else :
11961195 add_links = ''
1197- single_submit_script = self .single_submit_script
1196+ global_javascript = self .global_javascript % self . __dict__
11981197 self .write (_ ('''<html><head>
11991198<title>%(title)s</title>
12001199<style type="text/css">%(style)s</style>
12011200</head>
1202- %(single_submit_script )s
1201+ %(global_javascript )s
12031202<body bgcolor=#ffffff>
12041203%(message)s
12051204<table width=100%% border=0 cellspacing=0 cellpadding=2>
@@ -1299,6 +1298,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
12991298
13001299#
13011300# $Log: not supported by cvs2svn $
1301+ # Revision 1.105 2002/02/20 05:52:10 richard
1302+ # better error handling
1303+ #
13021304# Revision 1.104 2002/02/20 05:45:17 richard
13031305# Use the csv module for generating the form entry so it's correct.
13041306# [also noted the sf.net feature request id in the change log]
0 commit comments