Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
Nikola Balog
wendelin
Commits
e543b8b8
Commit
e543b8b8
authored
Mar 05, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Zope4 Support
Add Zope4 support, while keeping Zope2 support for now See merge request
!110
parents
08ac1304
1595f4e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
20 deletions
+42
-20
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+11
-7
product/Wendelin/__init__.py
product/Wendelin/__init__.py
+31
-13
No files found.
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
e543b8b8
...
...
@@ -23,6 +23,7 @@
from
cStringIO
import
StringIO
import
base64
import
binascii
from
httplib
import
NO_CONTENT
import
msgpack
import
numpy
as
np
import
string
...
...
@@ -37,6 +38,14 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
removeZODBPythonScript
from
wendelin.bigarray.array_zodb
import
ZBigArray
from
App.version_txt
import
getZopeVersion
if
getZopeVersion
()
<
(
4
,
):
# BBB Zope2
# Zope set http status code 204 for empty response, but
# on Zope 2 this is not correctly reflected in ERP5TypeTestCase.publish,
# for such responses the status is set to 200 (but for "real" requests
# it is set to 204, this only affected the testing)
NO_CONTENT
=
200
def
getRandomString
():
return
'test_%s'
%
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
\
...
...
@@ -98,12 +107,7 @@ class Test(ERP5TypeTestCase):
publish_kw
=
dict
(
user
=
'ERP5TypeTestCase'
,
env
=
env
,
request_method
=
'POST'
,
stdin
=
StringIO
(
body
))
response
=
self
.
publish
(
path
,
**
publish_kw
)
# Due to inconsistencies in the Zope framework,
# a normal instance returns 204. As explained at
# http://blog.ploeh.dk/2013/04/30/rest-lesson-learned-avoid-204-responses/
# turning 200 into 204 automatically when the body is empty is questionable.
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEqual
(
NO_CONTENT
,
response
.
getStatus
())
# at every ingestion if no specialised Data Ingestion exists it is created
# thus it is needed to wait for server side activities to be processed
self
.
tic
()
...
...
@@ -389,7 +393,7 @@ class Test(ERP5TypeTestCase):
request_method
=
'POST'
,
stdin
=
StringIO
(
body
))
response
=
self
.
publish
(
path
,
**
publish_kw
)
self
.
assertEqual
(
200
,
response
.
getStatus
())
self
.
assertEqual
(
NO_CONTENT
,
response
.
getStatus
())
self
.
tic
()
...
...
product/Wendelin/__init__.py
View file @
e543b8b8
...
...
@@ -40,23 +40,41 @@ allow_module('scipy')
allow_module
(
'wendelin.bigarray.array_zodb'
)
allow_type
(
np
.
timedelta64
)
allow_type
(
type
(
np
.
c_
))
import
sklearn.linear_model
allow_class
(
sklearn
.
linear_model
.
LinearRegression
)
# Modify 'safetype' dict in full_write_guard function
# of RestrictedPython (closure) directly To allow
# write access to ndarray, DataFrame, ZBigArray and RAMArray objects
from
RestrictedPython.Guards
import
full_write_guard
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
np
.
ndarray
]
=
True
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
np
.
core
.
records
.
recarray
]
=
True
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
np
.
core
.
records
.
record
]
=
True
# allow write access to ndarray, DataFrame, ZBigArray and RAMArray objects
def
allow_full_write
(
t
):
"""Allow setting and deleting items and attributes for this type.
This supports both RestrictedPython-3.6.0, where the safetype is implemented as:
safetype = {dict: True, list: True}.has_key
...
safetype(t)
and RestrictedPython-5.1, where the safetype is implemented as:
safetypes = {dict, list}
...
safetype(t)
"""
from
RestrictedPython.Guards
import
full_write_guard
safetype
=
full_write_guard
.
__closure__
[
1
].
cell_contents
if
isinstance
(
safetype
,
set
):
# 5.1
safetype
.
add
(
t
)
else
:
# 3.6
safetype
.
__self__
.
update
({
t
:
True
})
allow_full_write
(
np
.
ndarray
)
allow_full_write
(
np
.
core
.
records
.
recarray
)
allow_full_write
(
np
.
core
.
records
.
record
)
from
wendelin.bigarray.array_zodb
import
ZBigArray
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
ZBigArray
]
=
True
allow_full_write
(
ZBigArray
)
allow_type
(
ZBigArray
)
from
wendelin.bigarray.array_ram
import
RAMArray
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
RAMArray
]
=
True
allow_full_write
(
RAMArray
)
allow_type
(
RAMArray
)
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