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
Frederic Thoma
erp5
Commits
73e6d592
Commit
73e6d592
authored
Sep 12, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WSGI: do not use zserver threads for automatic creation of ERP5 site
parent
ac31e8c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
16 deletions
+25
-16
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+25
-16
No files found.
product/ERP5/ERP5Site.py
View file @
73e6d592
...
@@ -2429,18 +2429,16 @@ def initialize(self):
...
@@ -2429,18 +2429,16 @@ def initialize(self):
for
_
in
self
.
getApp
().
objectIds
(
meta_type
):
for
_
in
self
.
getApp
().
objectIds
(
meta_type
):
return
return
# We defer the call to manage_addERP5Site via
ZServer.PubCor
e because:
# We defer the call to manage_addERP5Site via
TimerServic
e because:
# - we use ZPublisher so that get_request() works
# - we use ZPublisher so that get_request() works
# (see
new_publish in Localizer.patches
)
# (see
Localizer patch
)
# - we want errors to be logged correctly
# - we want errors to be logged correctly
# (see Zope2.zpublisher_exception_hook in Zope2.App.startup)
# (see Zope2.zpublisher_exception_hook in Zope2.App.startup)
import
inspect
,
time
import
inspect
,
sys
,
time
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
cStringIO
import
StringIO
from
App.ZApplication
import
ZApplicationWrapper
from
Products.ZMySQLDA.db
import
DB
,
OperationalError
from
Products.ZMySQLDA.db
import
DB
,
OperationalError
from
ZPublisher
import
HTTPRequest
,
HTTPResponse
def
addERP5Site
(
REQUEST
):
from
ZServer.PubCore
import
handle
def
addERP5Site
():
default_kw
=
inspect
.
getcallargs
(
manage_addERP5Site
,
None
,
''
)
default_kw
=
inspect
.
getcallargs
(
manage_addERP5Site
,
None
,
''
)
db
=
(
kw
.
get
(
'erp5_sql_connection_string'
)
or
db
=
(
kw
.
get
(
'erp5_sql_connection_string'
)
or
default_kw
[
'erp5_sql_connection_string'
])
default_kw
[
'erp5_sql_connection_string'
])
...
@@ -2459,15 +2457,18 @@ def initialize(self):
...
@@ -2459,15 +2457,18 @@ def initialize(self):
try
:
try
:
with
DB
(
db
).
lock
():
with
DB
(
db
).
lock
():
transaction
.
begin
()
transaction
.
begin
()
app
=
request
[
'PARENTS'
][
0
]
=
request
[
'PARENTS'
][
0
]()
app
=
REQUEST
[
'PARENTS'
][
0
]
if
isinstance
(
app
,
ZApplicationWrapper
):
# BBB: With ZServer, it is not loaded yet.
app
=
REQUEST
[
'PARENTS'
][
0
]
=
app
()
for
_
in
app
.
objectIds
(
meta_type
):
for
_
in
app
.
objectIds
(
meta_type
):
return
return
uf
=
app
.
acl_users
uf
=
app
.
acl_users
user
=
uf
.
getUser
(
kw
[
'owner'
])
user
=
uf
.
getUser
(
kw
[
'owner'
])
if
not
user
.
has_role
(
'Manager'
):
if
not
user
.
has_role
(
'Manager'
):
response
.
unauthorized
()
REQUEST
.
RESPONSE
.
unauthorized
()
newSecurityManager
(
None
,
user
.
__of__
(
uf
))
newSecurityManager
(
None
,
user
.
__of__
(
uf
))
manage_addERP5Site
(
app
.
__of__
(
RequestContainer
(
REQUEST
=
request
)),
manage_addERP5Site
(
app
.
__of__
(
RequestContainer
(
REQUEST
=
REQUEST
)),
**
{
k
:
kw
.
get
(
k
,
v
)
for
k
,
v
in
default_kw
.
iteritems
()
**
{
k
:
kw
.
get
(
k
,
v
)
for
k
,
v
in
default_kw
.
iteritems
()
if
isinstance
(
v
,
str
)})
if
isinstance
(
v
,
str
)})
transaction
.
get
().
note
(
'Created '
+
meta_type
)
transaction
.
get
().
note
(
'Created '
+
meta_type
)
...
@@ -2484,11 +2485,19 @@ def initialize(self):
...
@@ -2484,11 +2485,19 @@ def initialize(self):
'MySQL error while trying to create ERP5 site. Retrying...'
,
'MySQL error while trying to create ERP5 site. Retrying...'
,
error
=
1
)
error
=
1
)
time
.
sleep
(
5
)
time
.
sleep
(
5
)
response
=
HTTPResponse
.
HTTPResponse
(
stdout
=
StringIO
())
try
:
response
.
_finish
=
lambda
:
None
TimerServer
=
sys
.
modules
[
'Products.TimerService.timerserver.TimerServer'
]
request
=
HTTPRequest
.
HTTPRequest
(
except
KeyError
:
StringIO
(),
dict
(
REQUEST_METHOD
=
'GET'
,
SERVER_URL
=
''
),
response
)
try
:
# BBB
request
.
traverse
=
lambda
*
args
,
**
kw
:
addERP5Site
TimerServer
=
sys
.
modules
[
'timerserver.TimerServer'
]
handle
(
'Zope2'
,
request
,
response
)
except
KeyError
:
# There's no point installing ERP5 automatically
# if there's no timer service configured.
return
TimerRequest
=
TimerServer
.
TimerRequest
def
traverse
(
*
args
,
**
kw
):
del
TimerRequest
.
traverse
return
addERP5Site
TimerRequest
.
traverse
=
traverse
AppInitializer
.
initialize
=
initialize
AppInitializer
.
initialize
=
initialize
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