Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
erp5
Commits
d630a237
Commit
d630a237
authored
Mar 06, 2023
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for py3
parent
9f9294a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
product/ERP5/bin/zopewsgitw.py
product/ERP5/bin/zopewsgitw.py
+12
-9
No files found.
product/ERP5/bin/zopewsgitw.py
View file @
d630a237
...
@@ -95,7 +95,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
...
@@ -95,7 +95,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
else
path_info
):
else
path_info
):
start_response
(
'200 OK'
,
((
'Content-type'
,
'text/plain'
),))
start_response
(
'200 OK'
,
((
'Content-type'
,
'text/plain'
),))
return
[
dump_threads
()]
return
[
dump_threads
()]
original_wsgi_input
=
environ
[
'wsgi.input'
]
original_wsgi_input
=
environ
[
'wsgi.input'
]
if
not
hasattr
(
original_wsgi_input
,
'seek'
):
if
not
hasattr
(
original_wsgi_input
,
'seek'
):
# Convert environ['wsgi.input'] to a file-like object.
# Convert environ['wsgi.input'] to a file-like object.
...
@@ -123,7 +122,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
...
@@ -123,7 +122,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
)
)
return
[
msg
]
return
[
msg
]
new_wsgi_input
.
seek
(
0
)
new_wsgi_input
.
seek
(
0
)
if
int
(
environ
[
'SERVER_PORT'
])
in
webdav_ports
:
if
int
(
environ
[
'SERVER_PORT'
])
in
webdav_ports
:
# Munge the request to ensure that we call manage_FTPGet.
# Munge the request to ensure that we call manage_FTPGet.
...
@@ -137,7 +135,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
...
@@ -137,7 +135,6 @@ def app_wrapper(large_file_threshold=10<<20, webdav_ports=()):
path_info
=
posixpath
.
join
(
path_info
,
'manage_DAVget'
)
path_info
=
posixpath
.
join
(
path_info
,
'manage_DAVget'
)
path_info
=
posixpath
.
normpath
(
path_info
)
path_info
=
posixpath
.
normpath
(
path_info
)
environ
[
'PATH_INFO'
]
=
path_info
environ
[
'PATH_INFO'
]
=
path_info
return
publish_module
(
environ
,
start_response
)
return
publish_module
(
environ
,
start_response
)
return
app
return
app
...
@@ -256,9 +253,10 @@ def runwsgi():
...
@@ -256,9 +253,10 @@ def runwsgi():
from
twisted.web.wsgi
import
WSGIResource
from
twisted.web.wsgi
import
WSGIResource
from
twisted.internet
import
protocol
,
reactor
,
endpoints
from
twisted.internet
import
protocol
,
reactor
,
endpoints
from
twisted.web
import
server
as
twisted_server
from
twisted.web
import
server
as
twisted_server
from
io
import
StringIO
import
urllib
import
urllib
from
Products.ERP5Type.Log
import
log
# I modified runwsgi() without thinking carefully.
# I modified runwsgi() without thinking carefully.
# Very dirty code.
# Very dirty code.
def
runwsgitw
():
def
runwsgitw
():
...
@@ -370,10 +368,11 @@ def runwsgitw():
...
@@ -370,10 +368,11 @@ def runwsgitw():
# Make env for a dummy wsgi request
# Make env for a dummy wsgi request
# But I really do not know how env should be.
# But I really do not know how env should be.
# it is just a workaround.
# it is just a workaround.
data
=
data
.
decode
()
# data is b"", we want normal str
# Please check PEP for wsgi.
# Please check PEP for wsgi.
env
=
{}
env
=
{}
stdin
=
String
IO
()
stdin
=
Bytes
IO
()
stderr
=
String
IO
()
stderr
=
Bytes
IO
()
env
[
'wsgi.input'
]
=
stdin
env
[
'wsgi.input'
]
=
stdin
env
[
'wsgi.errors'
]
=
stderr
env
[
'wsgi.errors'
]
=
stderr
env
[
'wsgi.version'
]
=
(
1
,
0
)
env
[
'wsgi.version'
]
=
(
1
,
0
)
...
@@ -383,11 +382,13 @@ def runwsgitw():
...
@@ -383,11 +382,13 @@ def runwsgitw():
env
[
'wsgi.url_schema'
]
=
'http'
env
[
'wsgi.url_schema'
]
=
'http'
env
[
'REQUEST_METHOD'
]
=
'GET'
env
[
'REQUEST_METHOD'
]
=
'GET'
env
[
'PATH_INFO'
]
=
'/erp5/'
+
data
[:
-
2
]
# data has \r\n
env
[
'PATH_INFO'
]
=
'/erp5/'
+
data
[:
-
2
]
# data has \r\n
env
[
'SERVER_NAME'
]
=
'localhost'
env
[
'SERVER_PORT'
]
=
'2261'
env
[
'SERVER_PORT'
]
=
'2261'
env
[
'SERVER_NAME'
]
=
'localhost'
env
[
'REMOTE_ADDR'
]
=
ip
env
[
'SERVER_PROTOCOL'
]
=
'HTTP/1.0'
env
[
'SERVER_PROTOCOL'
]
=
'HTTP/1.0'
result
=
translogger
(
env
,
start_response
)
result
=
translogger
(
env
,
start_response
)
self
.
transport
.
write
(
'
\
n
'
.
join
(
result
))
# We need to send b"" to transport
self
.
transport
.
write
(
b"
\
n
"
.
join
(
result
))
class
EchoFactory
(
protocol
.
Factory
):
class
EchoFactory
(
protocol
.
Factory
):
def
buildProtocol
(
self
,
addr
):
def
buildProtocol
(
self
,
addr
):
...
@@ -397,7 +398,9 @@ def runwsgitw():
...
@@ -397,7 +398,9 @@ def runwsgitw():
endpoints
.
serverFromString
(
reactor
,
"tcp:%s:interface=%s"
%
(
port
,
ip
)).
listen
(
twisted_server
.
Site
(
resource
))
endpoints
.
serverFromString
(
reactor
,
"tcp:%s:interface=%s"
%
(
port
,
ip
)).
listen
(
twisted_server
.
Site
(
resource
))
# Add a echo server, this is the key of the POC.
# Add a echo server, this is the key of the POC.
endpoints
.
serverFromString
(
reactor
,
"tcp:2261:interface=10.0.244.187"
).
listen
(
EchoFactory
())
# We use the same IP as normal erp5 server, but we switch
# to a different port.
endpoints
.
serverFromString
(
reactor
,
"tcp:2261:interface=%s"
%
ip
).
listen
(
EchoFactory
())
# Start main loop.
# Start main loop.
reactor
.
run
()
reactor
.
run
()
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