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
c30fca1e
Commit
c30fca1e
authored
Apr 26, 2006
by
Lennart Regebro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A first attempt to tear the ZServer away from the ZPublisher, and put a wsgi
interface inbetween.
parent
88301ada
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
154 additions
and
25 deletions
+154
-25
lib/python/Testing/ZopeTestCase/framework.py
lib/python/Testing/ZopeTestCase/framework.py
+1
-1
lib/python/Testing/ZopeTestCase/testPlaceless.py
lib/python/Testing/ZopeTestCase/testPlaceless.py
+1
-1
lib/python/Testing/ZopeTestCase/testSkeleton.py
lib/python/Testing/ZopeTestCase/testSkeleton.py
+1
-1
lib/python/Testing/ZopeTestCase/threadutils.py
lib/python/Testing/ZopeTestCase/threadutils.py
+1
-1
lib/python/Testing/ZopeTestCase/zopedoctest/framework.py
lib/python/Testing/ZopeTestCase/zopedoctest/framework.py
+1
-1
lib/python/Testing/ZopeTestCase/zopedoctest/testAuthHeaderTest.py
...on/Testing/ZopeTestCase/zopedoctest/testAuthHeaderTest.py
+1
-1
lib/python/Testing/ZopeTestCase/zopedoctest/testWarningsTest.py
...thon/Testing/ZopeTestCase/zopedoctest/testWarningsTest.py
+1
-1
lib/python/Testing/ZopeTestCase/zopedoctest/testZopeDocTest.py
...ython/Testing/ZopeTestCase/zopedoctest/testZopeDocTest.py
+1
-1
lib/python/ZPublisher/HTTPRequest.py
lib/python/ZPublisher/HTTPRequest.py
+6
-6
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+113
-2
lib/python/ZServer/HTTPResponse.py
lib/python/ZServer/HTTPResponse.py
+3
-3
lib/python/ZServer/HTTPServer.py
lib/python/ZServer/HTTPServer.py
+23
-5
lib/python/ZServer/PubCore/ZServerPublisher.py
lib/python/ZServer/PubCore/ZServerPublisher.py
+1
-1
No files found.
lib/python/Testing/ZopeTestCase/framework.py
View file @
c30fca1e
...
@@ -43,7 +43,7 @@ The following code should be at the top of every test module:
...
@@ -43,7 +43,7 @@ The following code should be at the top of every test module:
if __name__ == '__main__':
if __name__ == '__main__':
framework()
framework()
$Id
:
$
$Id$
"""
"""
__version__
=
'0.2.4'
__version__
=
'0.2.4'
...
...
lib/python/Testing/ZopeTestCase/testPlaceless.py
View file @
c30fca1e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Placeless setup tests
"""Placeless setup tests
$Id
:
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/testSkeleton.py
View file @
c30fca1e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Skeleton ZopeTestCase
"""Skeleton ZopeTestCase
$Id
:
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/threadutils.py
View file @
c30fca1e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
"""Parts of ZServer support are in this module so they can
"""Parts of ZServer support are in this module so they can
be imported more selectively.
be imported more selectively.
$Id
: threadutils.py,v 1.6 2004/08/19 15:31:26 shh42 Exp
$
$Id$
"""
"""
from
threading
import
Thread
from
threading
import
Thread
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/framework.py
View file @
c30fca1e
...
@@ -43,7 +43,7 @@ The following code should be at the top of every test module:
...
@@ -43,7 +43,7 @@ The following code should be at the top of every test module:
if __name__ == '__main__':
if __name__ == '__main__':
framework()
framework()
$Id
:
$
$Id$
"""
"""
__version__
=
'0.2.4'
__version__
=
'0.2.4'
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/testAuthHeaderTest.py
View file @
c30fca1e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Test for auth_header
"""Test for auth_header
$Id
: testAuthHeaderTest.py,v 1.2 2005/03/26 18:07:08 shh42 Exp
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/testWarningsTest.py
View file @
c30fca1e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Example doctest
"""Example doctest
$Id
: testWarningsTest.py,v 1.2 2005/03/26 18:07:08 shh42 Exp
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/testZopeDocTest.py
View file @
c30fca1e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Example Zope doctest
"""Example Zope doctest
$Id
: testZopeDocTest.py,v 1.2 2005/03/26 18:07:08 shh42 Exp
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
...
lib/python/ZPublisher/HTTPRequest.py
View file @
c30fca1e
lib/python/ZPublisher/Publish.py
View file @
c30fca1e
...
@@ -21,7 +21,6 @@ from Request import Request
...
@@ -21,7 +21,6 @@ from Request import Request
from
maybe_lock
import
allocate_lock
from
maybe_lock
import
allocate_lock
from
mapply
import
mapply
from
mapply
import
mapply
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
from
zope.app.publication.browser
import
setDefaultSkin
class
Retry
(
Exception
):
class
Retry
(
Exception
):
"""Raise this to retry a request
"""Raise this to retry a request
...
@@ -169,10 +168,122 @@ def publish(request, module_name, after_list, debug=0,
...
@@ -169,10 +168,122 @@ def publish(request, module_name, after_list, debug=0,
transactions_manager
.
abort
()
transactions_manager
.
abort
()
raise
raise
from
HTTPRequest
import
HTTPRequest
from
ZServer.HTTPResponse
import
make_response
class
WSGIPublisherApplication
(
object
):
"""A WSGI application implementation for the zope 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
=
HTTPRequest
(
environ
[
'wsgi.input'
],
environ
,
response
)
# Let's support post-mortem debugging
handle_errors
=
environ
.
get
(
'wsgi.handleErrors'
,
True
)
try
:
response
=
publish
(
request
,
'Zope2'
,
after_list
=
[
None
],
debug
=
handle_errors
)
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
:
# Start the WSGI server response
start_response
(
response
.
getHeader
(
'status'
),
response
.
headers
.
items
())
result
=
str
(
response
)
# Return the result body iterable.
request
.
close
()
#response._finish(0)
return
(
result
,)
def
fakeWrite
(
body
):
raise
NotImplementedError
(
"Zope 2's HTTP Server does not support the WSGI write() function."
)
def
publish_module_standard
(
module_name
,
def
publish_module_standard
(
module_name
,
stdin
=
sys
.
stdin
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,
stdin
=
sys
.
stdin
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,
environ
=
os
.
environ
,
debug
=
0
,
request
=
None
,
response
=
None
):
environ
=
os
.
environ
,
debug
=
0
,
request
=
None
,
response
=
None
):
# 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
status
=
200
after_list
=
[
None
]
if
request
is
None
:
env
=
environ
.
copy
()
else
:
env
=
request
env
[
'wsgi.input'
]
=
sys
.
stdin
env
[
'wsgi.errors'
]
=
sys
.
stderr
env
[
'wsgi.version'
]
=
(
1
,
0
)
env
[
'wsgi.multithread'
]
=
True
env
[
'wsgi.multiprocess'
]
=
True
env
[
'wsgi.run_once'
]
=
True
env
[
'wsgi.url_scheme'
]
=
env
[
'SERVER_PROTOCOL'
].
split
(
'/'
)[
0
]
if
not
env
.
has_key
(
'wsgi.output'
):
env
[
'wsgi.output'
]
=
stdout
application
=
WSGIPublisherApplication
(
None
)
body
=
application
(
env
,
wsgi_start_response
)
env
[
'wsgi.output'
].
write
(
body
[
0
])
env
[
'wsgi.output'
].
close
()
# The module defined a post-access function, call it
if
after_list
[
0
]
is
not
None
:
after_list
[
0
]()
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
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
must_die
=
0
status
=
200
status
=
200
after_list
=
[
None
]
after_list
=
[
None
]
...
...
lib/python/ZServer/HTTPResponse.py
View file @
c30fca1e
...
@@ -194,7 +194,7 @@ class ZServerHTTPResponse(HTTPResponse):
...
@@ -194,7 +194,7 @@ class ZServerHTTPResponse(HTTPResponse):
_retried_response
=
None
_retried_response
=
None
def
_finish
(
self
):
def
_finish
(
self
,
close_output
=
1
):
if
self
.
_retried_response
:
if
self
.
_retried_response
:
try
:
try
:
self
.
_retried_response
.
_finish
()
self
.
_retried_response
.
_finish
()
...
@@ -209,6 +209,7 @@ class ZServerHTTPResponse(HTTPResponse):
...
@@ -209,6 +209,7 @@ class ZServerHTTPResponse(HTTPResponse):
self
.
_tempfile
=
None
self
.
_tempfile
=
None
stdout
.
finish
(
self
)
stdout
.
finish
(
self
)
if
close_output
:
stdout
.
close
()
stdout
.
close
()
self
.
stdout
=
None
# need to break cycle?
self
.
stdout
=
None
# need to break cycle?
...
@@ -318,7 +319,6 @@ proxying_connection_re = re.compile ('Proxy-Connection: (.*)', re.IGNORECASE)
...
@@ -318,7 +319,6 @@ proxying_connection_re = re.compile ('Proxy-Connection: (.*)', re.IGNORECASE)
def
make_response
(
request
,
headers
):
def
make_response
(
request
,
headers
):
"Simple http response factory"
"Simple http response factory"
# should this be integrated into the HTTPResponse constructor?
# should this be integrated into the HTTPResponse constructor?
response
=
ZServerHTTPResponse
(
stdout
=
ChannelPipe
(
request
),
stderr
=
StringIO
())
response
=
ZServerHTTPResponse
(
stdout
=
ChannelPipe
(
request
),
stderr
=
StringIO
())
response
.
_http_version
=
request
.
version
response
.
_http_version
=
request
.
version
if
request
.
version
==
'1.0'
and
is_proxying_match
(
request
.
request
):
if
request
.
version
==
'1.0'
and
is_proxying_match
(
request
.
request
):
...
...
lib/python/ZServer/HTTPServer.py
View file @
c30fca1e
...
@@ -261,13 +261,31 @@ class zhttp_handler:
...
@@ -261,13 +261,31 @@ class zhttp_handler:
s
=
0
s
=
0
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
DebugLogger
.
log
(
'I'
,
id
(
request
),
s
)
#import pdb;pdb.set_trace()
env
=
self
.
get_environment
(
request
)
env
=
self
.
get_environment
(
request
)
zresponse
=
make_response
(
request
,
env
)
from
HTTPResponse
import
ChannelPipe
,
is_proxying_match
,
proxying_connection_re
if
self
.
_force_connection_close
:
env
[
'wsgi.output'
]
=
ChannelPipe
(
request
)
zresponse
.
_http_connection
=
'close'
version
=
request
.
version
zrequest
=
HTTPRequest
(
sin
,
env
,
zresponse
)
if
version
==
'1.0'
and
is_proxying_match
(
request
.
request
):
# a request that was made as if this zope was an http 1.0 proxy.
# that means we have to use some slightly different http
# headers to manage persistent connections.
connection_re
=
proxying_connection_re
else
:
# a normal http request
connection_re
=
CONNECTION
env
[
'http_connection'
]
=
get_header
(
connection_re
,
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
.
current_request
=
None
request
.
channel
.
queue
.
append
((
self
.
module_name
,
zrequest
,
zrespons
e
))
request
.
channel
.
queue
.
append
((
self
.
module_name
,
env
,
Non
e
))
request
.
channel
.
work
()
request
.
channel
.
work
()
def
status
(
self
):
def
status
(
self
):
...
...
lib/python/ZServer/PubCore/ZServerPublisher.py
View file @
c30fca1e
...
@@ -22,5 +22,5 @@ class ZServerPublisher:
...
@@ -22,5 +22,5 @@ class ZServerPublisher:
request
=
request
,
request
=
request
,
response
=
response
)
response
=
response
)
finally
:
finally
:
response
.
_finish
()
#
response._finish()
request
=
response
=
None
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