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
6fe74245
Commit
6fe74245
authored
Sep 13, 1996
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
dd8f0382
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
245 additions
and
15 deletions
+245
-15
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+35
-11
lib/python/ZPublisher/Response.py
lib/python/ZPublisher/Response.py
+16
-4
lib/python/ZPublisher/Test.py
lib/python/ZPublisher/Test.py
+194
-0
No files found.
lib/python/ZPublisher/Publish.py
View file @
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.1
8 1996/08/30 23:40:40 jfulton
Exp $"""
$Id: Publish.py,v 1.1
9 1996/09/13 22:51:35 jim
Exp $"""
#'
#'
# Copyright
# Copyright
#
#
...
@@ -570,6 +570,9 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
...
@@ -570,6 +570,9 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
# (540) 371-6909
# (540) 371-6909
#
#
# $Log: Publish.py,v $
# $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
# Revision 1.18 1996/08/30 23:40:40 jfulton
# Fixed bug in argument marshalling!!!
# Fixed bug in argument marshalling!!!
#
#
...
@@ -650,7 +653,7 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
...
@@ -650,7 +653,7 @@ $Id: Publish.py,v 1.18 1996/08/30 23:40:40 jfulton Exp $"""
#
#
#
#
#
#
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
9
$'
[
11
:
-
2
]
def
main
():
def
main
():
...
@@ -737,7 +740,7 @@ class ModulePublisher:
...
@@ -737,7 +740,7 @@ class ModulePublisher:
self
.
forbiddenError
()
self
.
forbiddenError
()
def
publish
(
self
,
module_name
,
published
=
'web_objects'
,
def
publish
(
self
,
module_name
,
published
=
'web_objects'
,
imported_modules
=
{},
module_dicts
=
{}):
imported_modules
=
{},
module_dicts
=
{}
,
debug
=
0
):
# First check for "cancel" redirect:
# First check for "cancel" redirect:
cancel
=
''
cancel
=
''
...
@@ -815,14 +818,26 @@ class ModulePublisher:
...
@@ -815,14 +818,26 @@ class ModulePublisher:
URL
=
self
.
script
URL
=
self
.
script
parents
=
[]
parents
=
[]
# sad_pathetic_persistence_hack:
try
:
setstate
=
object
.
__dict__
[
'_p_setstate'
]
except
:
setstate
=
None
if
setstate
:
setstate
(
object
)
while
path
:
while
path
:
sad_pathetic_persistence_hack
(
object
)
#
sad_pathetic_persistence_hack(object)
entry_name
,
path
=
path
[
0
],
path
[
1
:]
entry_name
,
path
=
path
[
0
],
path
[
1
:]
URL
=
"%s/%s"
%
(
URL
,
entry_name
)
URL
=
"%s/%s"
%
(
URL
,
entry_name
)
default_realm_name
=
"%s.%s"
%
(
entry_name
,
default_realm_name
)
default_realm_name
=
"%s.%s"
%
(
entry_name
,
default_realm_name
)
if
entry_name
:
if
entry_name
:
try
:
try
:
subobject
=
getattr
(
object
,
entry_name
)
subobject
=
getattr
(
object
,
entry_name
)
# sad_pathetic_persistence_hack:
try
:
setstate
=
subobject
.
__dict__
[
'_p_setstate'
]
except
:
setstate
=
None
if
setstate
:
setstate
(
subobject
)
try
:
try
:
groups
=
subobject
.
__allow_groups__
groups
=
subobject
.
__allow_groups__
inherited_groups
=
allow_group_composition
(
inherited_groups
=
allow_group_composition
(
...
@@ -857,6 +872,12 @@ class ModulePublisher:
...
@@ -857,6 +872,12 @@ class ModulePublisher:
except
AttributeError
:
except
AttributeError
:
try
:
try
:
subobject
=
object
[
entry_name
]
subobject
=
object
[
entry_name
]
# sad_pathetic_persistence_hack:
try
:
setstate
=
subobject
.
__dict__
[
'_p_setstate'
]
except
:
setstate
=
None
if
setstate
:
setstate
(
subobject
)
try
:
try
:
request_params
=
getattr
(
subobject
,
'__request_data__'
)
request_params
=
getattr
(
subobject
,
'__request_data__'
)
try
:
request_params
=
request_params
()
try
:
request_params
=
request_params
()
...
@@ -888,7 +909,7 @@ class ModulePublisher:
...
@@ -888,7 +909,7 @@ class ModulePublisher:
realm
=
object
[
entry_name
+
'__realm__'
]
realm
=
object
[
entry_name
+
'__realm__'
]
realm_name
=
default_realm_name
realm_name
=
default_realm_name
except
:
pass
except
:
pass
except
(
TypeError
,
AttributeError
,
KeyError
):
except
(
TypeError
,
AttributeError
,
KeyError
)
,
mess
:
if
not
path
and
entry_name
==
'help'
and
doc
:
if
not
path
and
entry_name
==
'help'
and
doc
:
object
=
doc
object
=
doc
entry_name
,
subobject
=
(
entry_name
,
subobject
=
(
...
@@ -899,7 +920,7 @@ class ModulePublisher:
...
@@ -899,7 +920,7 @@ class ModulePublisher:
'<pre>
\
n
%s
\
n
</pre>'
%
doc
)
'<pre>
\
n
%s
\
n
</pre>'
%
doc
)
)
)
else
:
else
:
self
.
notFoundError
(
entry_name
)
self
.
notFoundError
(
"%s: %s"
%
(
entry_name
,
mess
)
)
if
published
:
if
published
:
# Bypass simple checks the first time
# Bypass simple checks the first time
published
=
None
published
=
None
...
@@ -993,9 +1014,8 @@ class ModulePublisher:
...
@@ -993,9 +1014,8 @@ class ModulePublisher:
raise
'BadRequest'
,
(
'<strong>Invalid entry for %s </strong>'
raise
'BadRequest'
,
(
'<strong>Invalid entry for %s </strong>'
%
argument_name
)
%
argument_name
)
if
debug
:
result
=
self
.
call_object
(
object
,
tuple
(
args
))
if
args
:
result
=
apply
(
object
,
tuple
(
args
))
else
:
result
=
apply
(
object
,
tuple
(
args
))
else
:
result
=
object
()
if
result
and
result
is
not
response
:
response
.
setBody
(
result
)
if
result
and
result
is
not
response
:
response
.
setBody
(
result
)
...
@@ -1003,6 +1023,10 @@ class ModulePublisher:
...
@@ -1003,6 +1023,10 @@ class ModulePublisher:
return
response
return
response
def
call_object
(
self
,
object
,
args
):
result
=
apply
(
object
,
args
)
return
result
def
sad_pathetic_persistence_hack
(
object
):
def
sad_pathetic_persistence_hack
(
object
):
try
:
setstate
=
object
.
__dict__
[
'_p_setstate'
]
try
:
setstate
=
object
.
__dict__
[
'_p_setstate'
]
except
:
return
except
:
return
...
@@ -1352,7 +1376,7 @@ class CGIModulePublisher(ModulePublisher):
...
@@ -1352,7 +1376,7 @@ class CGIModulePublisher(ModulePublisher):
def
publish_module
(
module_name
,
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
):
environ
=
os
.
environ
,
debug
=
0
):
must_die
=
0
must_die
=
0
try
:
try
:
response
=
Response
(
stdout
=
stdout
,
stderr
=
stderr
)
response
=
Response
(
stdout
=
stdout
,
stderr
=
stderr
)
...
@@ -1360,7 +1384,7 @@ def publish_module(module_name,
...
@@ -1360,7 +1384,7 @@ def publish_module(module_name,
stderr
=
stderr
,
stderr
=
stderr
,
environ
=
environ
)
environ
=
environ
)
response
=
publisher
.
response
response
=
publisher
.
response
response
=
publisher
.
publish
(
module_name
)
response
=
publisher
.
publish
(
module_name
,
debug
=
debug
)
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
...
...
lib/python/ZPublisher/Response.py
View file @
6fe74245
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
__doc__
=
'''CGI Response Output formatter
__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
#
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# 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 $'''
...
@@ -55,6 +55,9 @@ $Id: Response.py,v 1.9 1996/08/30 23:28:29 jfulton Exp $'''
# (540) 371-6909
# (540) 371-6909
#
#
# $Log: Response.py,v $
# $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
# Revision 1.9 1996/08/30 23:28:29 jfulton
# Added code to map 300 redirects to 302.
# 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 $'''
...
@@ -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
import
string
,
types
,
sys
,
regex
,
regsub
...
@@ -544,8 +547,6 @@ class Response:
...
@@ -544,8 +547,6 @@ class Response:
if
not
headers
.
has_key
(
'content-type'
)
and
self
.
status
==
200
:
if
not
headers
.
has_key
(
'content-type'
)
and
self
.
status
==
200
:
self
.
setStatus
(
'nocontent'
)
self
.
setStatus
(
'nocontent'
)
def
upcase
(
s
):
return
string
.
upper
(
s
[:
1
])
+
s
[
1
:]
headersl
=
map
(
headersl
=
map
(
lambda
k
,
d
=
headers
,
upcase
=
upcase
:
lambda
k
,
d
=
headers
,
upcase
=
upcase
:
"%s: %s"
%
(
upcase
(
k
),
d
[
k
]),
"%s: %s"
%
(
upcase
(
k
),
d
[
k
]),
...
@@ -590,6 +591,17 @@ class Response:
...
@@ -590,6 +591,17 @@ class Response:
write
(
'
\
n
\
n
'
)
write
(
'
\
n
\
n
'
)
write
(
body
)
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
():
def
main
():
print
Response
(
'hello world'
)
print
Response
(
'hello world'
)
print
'-'
*
70
print
'-'
*
70
...
...
lib/python/ZPublisher/Test.py
0 → 100644
View file @
6fe74245
#!/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
()
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