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
Paul Graydon
erp5
Commits
e702bb69
Commit
e702bb69
authored
Sep 29, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: remove ZServer dependency.
parent
cf589e81
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
3 additions
and
556 deletions
+3
-556
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+0
-2
product/DeadlockDebugger/dumper.py
product/DeadlockDebugger/dumper.py
+0
-4
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+0
-6
product/ERP5Type/patches/Publish.py
product/ERP5Type/patches/Publish.py
+0
-405
product/ERP5Type/patches/http_server.py
product/ERP5Type/patches/http_server.py
+0
-83
product/ERP5Type/tests/ProcessingNodeTestCase.py
product/ERP5Type/tests/ProcessingNodeTestCase.py
+3
-32
product/ERP5Type/tests/runUnitTest.py
product/ERP5Type/tests/runUnitTest.py
+0
-5
product/Localizer/patches.py
product/Localizer/patches.py
+0
-7
product/TimerService/timerserver/__init__.py
product/TimerService/timerserver/__init__.py
+0
-12
No files found.
product/CMFActivity/ActivityTool.py
View file @
e702bb69
...
...
@@ -106,14 +106,12 @@ instancehome = getConfiguration().instancehome
if
instancehome
is
not
None
:
log_directory
=
os
.
path
.
join
(
instancehome
,
'log'
)
if
os
.
path
.
isdir
(
log_directory
):
from
Signals
import
Signals
from
ZConfig.components.logger.loghandler
import
FileHandler
log_file_handler
=
FileHandler
(
os
.
path
.
join
(
log_directory
,
'CMFActivity.log'
))
# Default zope log format string borrowed from
# ZConfig/components/logger/factory.xml, but without the extra "------"
# line separating entries.
log_file_handler
.
setFormatter
(
logging
.
Formatter
(
"%(asctime)s %(levelname)s %(name)s %(message)s"
,
"%Y-%m-%dT%H:%M:%S"
))
Signals
.
registerZopeSignals
([
log_file_handler
])
activity_logger
.
addHandler
(
log_file_handler
)
activity_logger
.
propagate
=
0
...
...
product/DeadlockDebugger/dumper.py
View file @
e702bb69
...
...
@@ -114,7 +114,3 @@ def match(self, request):
return
1
else
:
return
0
if
six
.
PY2
:
from
ZServer.HTTPServer
import
zhttp_handler
zhttp_handler
.
match
=
match
product/ERP5Type/ZopePatch.py
View file @
e702bb69
...
...
@@ -61,9 +61,6 @@ from Products.ERP5Type.patches import PersistentMapping
from
Products.ERP5Type.patches
import
DateTimePatch
from
Products.ERP5Type.patches
import
PythonScript
from
Products.ERP5Type.patches
import
MailHost
if
six
.
PY2
:
# No more ZServer
from
Products.ERP5Type.patches
import
http_server
from
Products.ERP5Type.patches
import
memcache_client
from
Products.ERP5Type.patches
import
StateChangeInfoPatch
from
Products.ERP5Type.patches
import
transforms
...
...
@@ -94,9 +91,6 @@ from Products.ERP5Type.patches import OFSFile
from
Products.ERP5Type.patches
import
ZSQLMethod
from
Products.ERP5Type.patches
import
MimetypesRegistry
from
Products.ERP5Type.patches
import
users
if
six
.
PY2
:
# No ZServer
from
Products.ERP5Type.patches
import
Publish
from
Products.ERP5Type.patches
import
WSGITask
if
six
.
PY2
:
# XXX-zope4py3: urllib2 removed (see future/backports/urllib/request.py)
...
...
product/ERP5Type/patches/Publish.py
deleted
100644 → 0
View file @
cf589e81
This diff is collapsed.
Click to expand it.
product/ERP5Type/patches/http_server.py
deleted
100644 → 0
View file @
cf589e81
# This code is taken from the medusa in zope 2.8.
#
# The license term should be this one:
#
# Medusa is Copyright 1996-2000, Sam Rushing <rushing@nightmare.com>
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that both that copyright notice and this permission
# notice appear in supporting documentation, and that the name of Sam
# Rushing not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.
# Author: Sam Rushing <rushing@nightmare.com>
# Copyright 1996-2000 by Sam Rushing
# All Rights Reserved.
from
ZServer.medusa.http_server
import
http_request
import
ZPublisher.HTTPRequest
import
string
import
base64
import
time
from
six.moves.urllib.parse
import
quote
def
log
(
self
,
bytes
):
addr
=
self
.
channel
.
addr
[
0
]
# Frontend-facing proxy is responsible for sanitising
# HTTP_X_FORWARDED_FOR, and only trusted accesses should bypass
# that proxy. So trust first entry.
#
# <patch>
if
ZPublisher
.
HTTPRequest
.
trusted_proxies
==
(
'0.0.0.0'
,):
# Magic value to enable this functionality
forwarded_for
=
(
self
.
get_header
(
'x-forwarded-for'
)
or
''
).
split
(
','
,
1
)[
0
].
strip
()
if
forwarded_for
:
addr
=
forwarded_for
# </patch>
user_agent
=
self
.
get_header
(
'user-agent'
)
if
not
user_agent
:
user_agent
=
''
referer
=
self
.
get_header
(
'referer'
)
if
not
referer
:
referer
=
''
auth
=
self
.
get_header
(
'Authorization'
)
name
=
'Anonymous'
if
auth
is
not
None
:
if
string
.
lower
(
auth
[:
6
])
==
'basic '
:
try
:
decoded
=
base64
.
decodestring
(
auth
[
6
:])
except
base64
.
binascii
.
Error
:
decoded
=
''
t
=
string
.
split
(
decoded
,
':'
,
1
)
if
len
(
t
)
<
2
:
name
=
'Unknown (bad auth string)'
else
:
name
=
t
[
0
]
# Originally, an unquoted request string was logged, but
# it only confuses log analysis programs! Note that Apache
# HTTP Server never unquote URIs in the access log.
t
=
self
.
request
.
split
(
' '
)
quoted_request
=
'%s %s %s'
%
(
t
[
0
],
quote
(
' '
.
join
(
t
[
1
:
-
1
])),
t
[
-
1
])
self
.
channel
.
server
.
logger
.
log
(
# <patch>
addr
,
# </patch>
'- %s [%s] "%s" %d %d "%s" "%s"
\
n
'
%
(
name
,
self
.
log_date_string
(
time
.
time
()),
# <patch>
quoted_request
,
# </patch>
self
.
reply_code
,
bytes
,
referer
,
user_agent
)
)
http_request
.
log
=
log
product/ERP5Type/tests/ProcessingNodeTestCase.py
View file @
e702bb69
...
...
@@ -3,7 +3,6 @@ import errno, logging, mock, os, socket, time
import
itertools
from
threading
import
Thread
from
UserDict
import
IterableUserDict
import
Lifetime
import
transaction
from
Testing
import
ZopeTestCase
from
ZODB.POSException
import
ConflictError
...
...
@@ -142,21 +141,13 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
"""
_server_address
=
None
# (host, port) of the http server if it was started, None otherwise
@
staticmethod
def
asyncore_loop
():
try
:
Lifetime
.
lifetime_loop
()
except
KeyboardInterrupt
:
pass
Lifetime
.
graceful_shutdown_loop
()
def
startZServer
(
self
,
verbose
=
False
):
"""Start HTTP ZServer in background"""
if
self
.
_server_address
is
None
:
from
Products.ERP5Type.tests.runUnitTest
import
log_directory
log
=
os
.
path
.
join
(
log_directory
,
"Z2.log"
)
message
=
"Running %s server at %s:%s
\
n
"
if
int
(
os
.
environ
.
get
(
'erp5_wsgi'
,
0
))
:
if
True
:
from
Products.ERP5.bin.zopewsgi
import
app_wrapper
,
createServer
sockets
=
[]
server_type
=
'HTTP'
...
...
@@ -198,23 +189,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
t
=
Thread
(
target
=
hs
.
run
)
t
.
setDaemon
(
1
)
t
.
start
()
else
:
_print
=
lambda
hs
:
verbose
and
ZopeTestCase
.
_print
(
message
%
(
hs
.
server_protocol
,
hs
.
server_name
,
hs
.
server_port
))
try
:
hs
=
createZServer
(
log
)
except
RuntimeError
as
e
:
ZopeTestCase
.
_print
(
str
(
e
))
else
:
ProcessingNodeTestCase
.
_server_address
=
hs
.
server_name
,
hs
.
server_port
_print
(
hs
)
try
:
_print
(
createZServer
(
log
,
zserver_type
=
'webdav'
))
except
RuntimeError
as
e
:
ZopeTestCase
.
_print
(
'Could not start webdav zserver: %s
\
n
'
%
e
)
t
=
Thread
(
target
=
Lifetime
.
loop
)
t
.
setDaemon
(
1
)
t
.
start
()
from
Products.CMFActivity
import
ActivityTool
# Reset, in case that getServerAddress was already called,
# in which case, the value was ('', '')
...
...
@@ -307,9 +281,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
ZopeTestCase
.
_print
(
' %i'
%
message_count
)
old_message_count
=
message_count
portal_activities
.
process_timer
(
None
,
None
)
if
Lifetime
.
_shutdown_phase
:
# XXX CMFActivity contains bare excepts
raise
KeyboardInterrupt
message_list
=
getMessageList
()
message_count
=
len
(
message_list
)
if
time
.
time
()
>=
deadline
or
message_count
and
any
(
x
.
processing_node
==
-
2
...
...
@@ -377,7 +348,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
def
processing_node
(
self
):
"""Main loop for nodes that process activities"""
try
:
while
not
Lifetime
.
_shutdown_phas
e
:
while
Tru
e
:
time
.
sleep
(.
3
)
transaction
.
begin
()
try
:
...
...
@@ -408,7 +379,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
timerserver_thread
=
None
try
:
while
not
Lifetime
.
_shutdown_phas
e
:
while
Tru
e
:
time
.
sleep
(.
3
)
transaction
.
begin
()
try
:
...
...
product/ERP5Type/tests/runUnitTest.py
View file @
e702bb69
...
...
@@ -463,9 +463,6 @@ class DebugTestResult:
self
.
result
=
result
def
_start_debugger
(
self
,
tb
):
import
Lifetime
if
Lifetime
.
_shutdown_phase
:
return
try
:
# try ipython if available
import
IPython
...
...
@@ -624,11 +621,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
TestRunner
=
unittest
.
TextTestRunner
import
Lifetime
from
Zope2.custom_zodb
import
Storage
,
save_mysql
,
\
node_pid_list
,
neo_cluster
,
zeo_server_pid
,
wcfs_server
def
shutdown
(
signum
,
frame
,
signum_set
=
set
()):
Lifetime
.
shutdown
(
0
)
signum_set
.
add
(
signum
)
if
node_pid_list
is
None
and
len
(
signum_set
)
>
1
:
# in case of ^C, a child should also receive a SIGHUP from the parent,
...
...
product/Localizer/patches.py
View file @
e702bb69
...
...
@@ -69,13 +69,6 @@ def get_new_publish(zope_publish):
if
patch
is
False
:
patch
=
True
if
six
.
PY2
:
# ZServer-specific patch
# Apply the patch TODO: zope4py2 is this really needed ?
from
ZPublisher
import
Publish
Publish
.
publish
=
get_new_publish
(
Publish
.
publish
)
# PATCH 2: Accept
#
# Adds the variable AcceptLanguage to the REQUEST. It provides a higher
...
...
product/TimerService/timerserver/__init__.py
View file @
e702bb69
import
six
if
six
.
PY2
:
from
ZServer.datatypes
import
ServerFactory
class
TimerServerFactory
(
ServerFactory
):
def
__init__
(
self
,
section
):
ServerFactory
.
__init__
(
self
)
self
.
interval
=
section
.
interval
def
create
(
self
):
from
.TimerServer
import
TimerServer
return
TimerServer
(
self
.
module
,
self
.
interval
)
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