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
dbe61774
Commit
dbe61774
authored
Apr 26, 2006
by
Lennart Regebro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup.
parent
c30fca1e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
88 deletions
+11
-88
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+9
-79
lib/python/ZServer/HTTPServer.py
lib/python/ZServer/HTTPServer.py
+2
-8
lib/python/ZServer/PubCore/ZServerPublisher.py
lib/python/ZServer/PubCore/ZServerPublisher.py
+0
-1
No files found.
lib/python/ZPublisher/Publish.py
View file @
dbe61774
...
...
@@ -21,6 +21,8 @@ from Request import Request
from
maybe_lock
import
allocate_lock
from
mapply
import
mapply
from
zExceptions
import
Redirect
from
ZServer.HTTPResponse
import
ZServerHTTPResponse
from
cStringIO
import
StringIO
class
Retry
(
Exception
):
"""Raise this to retry a request
...
...
@@ -172,28 +174,21 @@ from HTTPRequest import HTTPRequest
from
ZServer.HTTPResponse
import
make_response
class
WSGIPublisherApplication
(
object
):
"""A WSGI application implementation for the zope publisher
"""A WSGI application implementation for the zope
2
publisher
Instances of this class can be used as a WSGI application object.
The class relies on a properly initialized request factory.
"""
#implements(interfaces.IWSGIApplication)
def
__init__
(
self
,
response
):
self
.
response
=
response
def
__call__
(
self
,
environ
,
start_response
):
"""See zope.app.wsgi.interfaces.IWSGIApplication"""
from
ZServer.HTTPResponse
import
ZServerHTTPResponse
,
is_proxying_match
,
proxying_connection_re
from
ZServer.medusa
import
http_server
from
cStringIO
import
StringIO
response
=
ZServerHTTPResponse
(
stdout
=
environ
[
'wsgi.output'
],
stderr
=
StringIO
())
response
.
_http_version
=
environ
[
'SERVER_PROTOCOL'
].
split
(
'/'
)[
1
]
response
.
_http_connection
=
environ
[
'CONNECTION_TYPE'
]
response
.
_server_version
=
environ
[
'SERVER_SOFTWARE'
]
request
=
HTTP
Request
(
environ
[
'wsgi.input'
],
environ
,
response
)
request
=
Request
(
environ
[
'wsgi.input'
],
environ
,
response
)
# Let's support post-mortem debugging
handle_errors
=
environ
.
get
(
'wsgi.handleErrors'
,
True
)
...
...
@@ -231,10 +226,9 @@ def fakeWrite(body):
def
publish_module_standard
(
module_name
,
stdin
=
sys
.
stdin
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,
environ
=
os
.
environ
,
debug
=
0
,
request
=
None
,
response
=
None
):
# The WSGI way!
# The WSGI way!
def
wsgi_start_response
(
status
,
response_headers
,
exc_info
=
None
):
# I don't understand what to do here. Start writing? At what?
return
fakeWrite
must_die
=
0
...
...
@@ -245,6 +239,8 @@ def publish_module_standard(module_name,
else
:
env
=
request
if
not
env
.
has_key
(
'CONNECTION_TYPE'
):
print
env
env
[
'wsgi.input'
]
=
sys
.
stdin
env
[
'wsgi.errors'
]
=
sys
.
stderr
env
[
'wsgi.version'
]
=
(
1
,
0
)
...
...
@@ -255,7 +251,7 @@ def publish_module_standard(module_name,
if
not
env
.
has_key
(
'wsgi.output'
):
env
[
'wsgi.output'
]
=
stdout
application
=
WSGIPublisherApplication
(
None
)
application
=
WSGIPublisherApplication
()
body
=
application
(
env
,
wsgi_start_response
)
env
[
'wsgi.output'
].
write
(
body
[
0
])
env
[
'wsgi.output'
].
close
()
...
...
@@ -280,72 +276,6 @@ def publish_module_standard(module_name,
return
status
def
publish_module_standard_old
(
module_name
,
stdin
=
sys
.
stdin
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,
environ
=
os
.
environ
,
debug
=
0
,
request
=
None
,
response
=
None
):
must_die
=
0
status
=
200
after_list
=
[
None
]
try
:
try
:
if
response
is
None
:
response
=
Response
(
stdout
=
stdout
,
stderr
=
stderr
)
else
:
stdout
=
response
.
stdout
if
request
is
None
:
request
=
Request
(
stdin
,
environ
,
response
)
# make sure that the request we hand over has the
# default layer/skin set on it; subsequent code that
# wants to look up views will likely depend on it
setDefaultSkin
(
request
)
response
=
publish
(
request
,
module_name
,
after_list
,
debug
=
debug
)
except
SystemExit
,
v
:
must_die
=
sys
.
exc_info
()
request
.
response
.
exception
(
must_die
)
except
ImportError
,
v
:
if
isinstance
(
v
,
tuple
)
and
len
(
v
)
==
3
:
must_die
=
v
elif
hasattr
(
sys
,
'exc_info'
):
must_die
=
sys
.
exc_info
()
else
:
must_die
=
SystemExit
,
v
,
sys
.
exc_info
()[
2
]
request
.
response
.
exception
(
1
,
v
)
except
:
request
.
response
.
exception
()
status
=
response
.
getStatus
()
if
response
:
outputBody
=
getattr
(
response
,
'outputBody'
,
None
)
if
outputBody
is
not
None
:
outputBody
()
else
:
response
=
str
(
response
)
if
response
:
stdout
.
write
(
response
)
# The module defined a post-access function, call it
if
after_list
[
0
]
is
not
None
:
after_list
[
0
]()
finally
:
if
request
is
not
None
:
request
.
close
()
if
must_die
:
# Try to turn exception value into an exit code.
try
:
if
hasattr
(
must_die
[
1
],
'code'
):
code
=
must_die
[
1
].
code
else
:
code
=
int
(
must_die
[
1
])
except
:
code
=
must_die
[
1
]
and
1
or
0
if
hasattr
(
request
.
response
,
'_requestShutdown'
):
request
.
response
.
_requestShutdown
(
code
)
try
:
raise
must_die
[
0
],
must_die
[
1
],
must_die
[
2
]
finally
:
must_die
=
None
return
status
_l
=
allocate_lock
()
def
get_module_info
(
module_name
,
modules
=
{},
acquire
=
_l
.
acquire
,
...
...
lib/python/ZServer/HTTPServer.py
View file @
dbe61774
...
...
@@ -43,6 +43,7 @@ from cStringIO import StringIO
from
PubCore
import
handle
from
HTTPResponse
import
make_response
from
HTTPResponse
import
ChannelPipe
,
is_proxying_match
,
proxying_connection_re
from
ZPublisher.HTTPRequest
import
HTTPRequest
from
App.config
import
getConfiguration
...
...
@@ -261,9 +262,7 @@ class zhttp_handler:
s
=
0
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
#import pdb;pdb.set_trace()
env
=
self
.
get_environment
(
request
)
from
HTTPResponse
import
ChannelPipe
,
is_proxying_match
,
proxying_connection_re
env
[
'wsgi.output'
]
=
ChannelPipe
(
request
)
version
=
request
.
version
if
version
==
'1.0'
and
is_proxying_match
(
request
.
request
):
...
...
@@ -279,11 +278,6 @@ class zhttp_handler:
request
.
header
).
lower
()
env
[
'server_version'
]
=
request
.
channel
.
server
.
SERVER_IDENT
#zresponse=make_response(request,env)
#if self._force_connection_close:
#zresponse._http_connection = 'close'
#zrequest=HTTPRequest(sin, env, zresponse)
request
.
channel
.
current_request
=
None
request
.
channel
.
queue
.
append
((
self
.
module_name
,
env
,
None
))
request
.
channel
.
work
()
...
...
lib/python/ZServer/PubCore/ZServerPublisher.py
View file @
dbe61774
...
...
@@ -22,5 +22,4 @@ class ZServerPublisher:
request
=
request
,
response
=
response
)
finally
:
#response._finish()
request
=
response
=
None
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