Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
b27b4557
Commit
b27b4557
authored
Apr 11, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added -e option to specify environment variables.
parent
0327c057
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
29 deletions
+67
-29
lib/python/ZPublisher/Test.py
lib/python/ZPublisher/Test.py
+67
-29
No files found.
lib/python/ZPublisher/Test.py
View file @
b27b4557
...
@@ -23,6 +23,10 @@ Options
...
@@ -23,6 +23,10 @@ Options
-u username:password -- Supply HTTP authorization information
-u username:password -- Supply HTTP authorization information
-e name=value -- Supply environment variables. Use a
seperate -e option for each variable
specified.
-p profiler_data_file -- Run under profiler control,
-p profiler_data_file -- Run under profiler control,
generating the profiler
generating the profiler
data file, profiler_data_file.
data file, profiler_data_file.
...
@@ -31,6 +35,9 @@ Options
...
@@ -31,6 +35,9 @@ Options
complete a request, in
complete a request, in
milliseconds.
milliseconds.
-r n -- Specify a repeat count for timing or
profiling.
-d -- Run in debug mode. With this
-d -- Run in debug mode. With this
option, bobo will run under Python
option, bobo will run under Python
debugger control. Two useful
debugger control. Two useful
...
@@ -65,7 +72,7 @@ Examples
...
@@ -65,7 +72,7 @@ Examples
s
s
$Id: Test.py,v 1.
8 1997/04/10 13:48:5
6 jim Exp $
$Id: Test.py,v 1.
9 1997/04/11 13:35:0
6 jim Exp $
'''
'''
# Copyright
# Copyright
#
#
...
@@ -119,7 +126,7 @@ $Id: Test.py,v 1.8 1997/04/10 13:48:56 jim Exp $
...
@@ -119,7 +126,7 @@ $Id: Test.py,v 1.8 1997/04/10 13:48:56 jim Exp $
#
#
#
#
#
#
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
#! /usr/local/bin/python
#! /usr/local/bin/python
...
@@ -132,7 +139,7 @@ def main():
...
@@ -132,7 +139,7 @@ def main():
global
repeat_count
global
repeat_count
try
:
try
:
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'dtu:p:r:'
)
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'dtu:p:r:
e:
'
)
if
len
(
args
)
>
2
or
len
(
args
)
<
1
:
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
:
...
@@ -140,6 +147,7 @@ def main():
...
@@ -140,6 +147,7 @@ def main():
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
profile
=
u
=
debug
=
timeit
=
None
profile
=
u
=
debug
=
timeit
=
None
env
=
{}
for
opt
,
val
in
optlist
:
for
opt
,
val
in
optlist
:
if
opt
==
'-d'
:
if
opt
==
'-d'
:
debug
=
1
debug
=
1
...
@@ -151,13 +159,17 @@ def main():
...
@@ -151,13 +159,17 @@ def main():
profile
=
val
profile
=
val
elif
opt
==
'-r'
:
elif
opt
==
'-r'
:
repeat_count
=
string
.
atoi
(
val
)
repeat_count
=
string
.
atoi
(
val
)
elif
opt
==
'-e'
:
opt
=
string
.
find
(
val
,
'='
)
if
opt
<=
0
:
raise
'Invalid argument to -e'
,
val
env
[
val
[:
opt
]]
=
val
[
opt
+
1
:]
if
(
debug
or
0
)
+
(
timeit
or
0
)
+
(
profile
and
1
or
0
)
>
1
:
if
(
debug
or
0
)
+
(
timeit
or
0
)
+
(
profile
and
1
or
0
)
>
1
:
raise
'Invalid options'
,
'only one of -p, -t, and -d are allowed'
raise
'Invalid options'
,
'only one of -p, -t, and -d are allowed'
module
=
args
[
0
]
module
=
args
[
0
]
publish
(
module
,
path_info
,
u
=
u
,
p
=
profile
,
d
=
debug
,
t
=
timeit
)
publish
(
module
,
path_info
,
u
=
u
,
p
=
profile
,
d
=
debug
,
t
=
timeit
,
e
=
env
)
...
@@ -189,7 +201,7 @@ def run(statement, *args):
...
@@ -189,7 +201,7 @@ def run(statement, *args):
return
prof
.
print_stats
()
return
prof
.
print_stats
()
def
publish
(
script
,
path_info
,
u
=
None
,
p
=
None
,
d
=
None
,
t
=
None
):
def
publish
(
script
,
path_info
,
u
=
None
,
p
=
None
,
d
=
None
,
t
=
None
,
e
=
{}
):
import
sys
,
os
,
getopt
,
string
import
sys
,
os
,
getopt
,
string
...
@@ -199,19 +211,19 @@ def publish(script,path_info,u=None,p=None,d=None,t=None):
...
@@ -199,19 +211,19 @@ def publish(script,path_info,u=None,p=None,d=None,t=None):
if
script
[
0
]
==
'+'
:
script
=
'../../lib/python/'
+
script
[
1
:]
if
script
[
0
]
==
'+'
:
script
=
'../../lib/python/'
+
script
[
1
:]
env
=
{
'SERVER_NAME'
:
'bobo.server'
,
env
=
e
'SERVER_PORT'
:
'80'
,
env
[
'SERVER_NAME'
]
=
'bobo.server'
'REQUEST_METHOD'
:
'GET'
,
env
[
'SERVER_PORT'
]
=
'80'
'REMOTE_ADDR'
:
'204.183.226.81 '
,
env
[
'REQUEST_METHOD'
]
=
'GET'
'REMOTE_HOST'
:
'bobo.remote.host'
,
env
[
'REMOTE_ADDR'
]
=
'204.183.226.81 '
'HTTP_USER_AGENT'
:
'Bobo/%s'
%
__version__
,
env
[
'REMOTE_HOST'
]
=
'bobo.remote.host'
'HTTP_HOST'
:
'ninny.digicool.com:8081 '
,
env
[
'HTTP_USER_AGENT'
]
=
'Bobo/%s'
%
__version__
'SERVER_SOFTWARE'
:
'Bobo/%s'
%
__version__
,
env
[
'HTTP_HOST'
]
=
'ninny.digicool.com:8081 '
'SERVER_PROTOCOL'
:
'HTTP/1.0 '
,
env
[
'SERVER_SOFTWARE'
]
=
'Bobo/%s'
%
__version__
'HTTP_ACCEPT'
:
'image/gif, image/x-xbitmap, image/jpeg, */* '
,
env
[
'SERVER_PROTOCOL'
]
=
'HTTP/1.0 '
'SERVER_HOSTNAME'
:
'bobo.server.host'
,
env
[
'HTTP_ACCEPT'
]
=
'image/gif, image/x-xbitmap, image/jpeg, */* '
'GATEWAY_INTERFACE'
:
'CGI/1.1 '
,
env
[
'SERVER_HOSTNAME'
]
=
'bobo.server.host'
}
env
[
'GATEWAY_INTERFACE'
]
=
'CGI/1.1 '
env
[
'SCRIPT_NAME'
]
=
script
env
[
'SCRIPT_NAME'
]
=
script
p
=
string
.
split
(
path_info
,
'?'
)
p
=
string
.
split
(
path_info
,
'?'
)
if
len
(
p
)
==
1
:
env
[
'PATH_INFO'
]
=
p
[
0
]
if
len
(
p
)
==
1
:
env
[
'PATH_INFO'
]
=
p
[
0
]
...
@@ -268,21 +280,44 @@ def publish(script,path_info,u=None,p=None,d=None,t=None):
...
@@ -268,21 +280,44 @@ def publish(script,path_info,u=None,p=None,d=None,t=None):
import
codehack
import
codehack
db
=
Pdb
()
db
=
Pdb
()
code
=
ModulePublisher
.
publish
.
im_func
.
func_code
def
fbreak
(
db
,
meth
,
codehack
=
codehack
):
lineno
=
codehack
.
getlineno
(
code
)
try
:
meth
=
meth
.
im_func
filename
=
code
.
co_filename
except
AttributeError
:
pass
db
.
set_break
(
filename
,
lineno
)
code
=
meth
.
func_code
lineno
=
codehack
.
getlineno
(
code
)
filename
=
code
.
co_filename
db
.
set_break
(
filename
,
lineno
)
fbreak
(
db
,
ModulePublisher
.
publish
)
fbreak
(
db
,
ModulePublisher
.
call_object
)
fbreak
(
db
,
cgi_module_publisher
.
new_find_object
)
fbreak
(
db
,
cgi_module_publisher
.
old_find_object
)
dbdata
=
{
'breakpoints'
:(),
'env'
:{}}
b
=
''
try
:
b
=
open
(
'.bobodb'
,
'r'
).
read
()
except
:
pass
if
b
:
exec
b
in
dbdata
for
b
in
dbdata
[
'breakpoints'
]:
if
type
(
b
)
is
type
(()):
apply
(
db
.
set_break
,
b
)
else
:
fbreak
(
db
,
b
)
for
k
,
v
in
dbdata
[
'env'
].
items
():
env
[
k
]
=
v
code
=
ModulePublisher
.
call_object
.
im_func
.
func_code
lineno
=
codehack
.
getlineno
(
code
)
filename
=
code
.
co_filename
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
(
publishing process. Then type c<ret> to jump to
'* Type "s<cr>c<cr>" to jump to beginning of real publishing process.
\
n
'
published object call.'''
'* Then type c<cr> to jump to the beginning of the URL traversal
\
n
'
' algorithm.
\
n
'
'* Then type c<cr> to jump to 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__
,
{
'file'
:
file
,
'env'
:
env
})
{
'file'
:
file
,
'env'
:
env
})
...
@@ -299,6 +334,9 @@ if __name__ == "__main__": main()
...
@@ -299,6 +334,9 @@ if __name__ == "__main__": main()
#
#
# $Log: Test.py,v $
# $Log: Test.py,v $
# Revision 1.9 1997/04/11 13:35:06 jim
# Added -e option to specify environment variables.
#
# Revision 1.8 1997/04/10 13:48:56 jim
# Revision 1.8 1997/04/10 13:48:56 jim
# Modified profiling to use repeat_count.
# Modified profiling to use repeat_count.
#
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment