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
19a2e5ff
Commit
19a2e5ff
authored
Jan 25, 2023
by
Jérome Perrin
Committed by
Nikola Balog
Sep 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust full_write_guard patch for RestrictedPython 5 (Zope4)
parent
1cfe5bf3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
product/Wendelin/__init__.py
product/Wendelin/__init__.py
+31
-10
No files found.
product/Wendelin/__init__.py
View file @
19a2e5ff
...
@@ -43,17 +43,38 @@ allow_module('wendelin.bigarray.array_zodb')
...
@@ -43,17 +43,38 @@ allow_module('wendelin.bigarray.array_zodb')
import
sklearn.linear_model
import
sklearn.linear_model
allow_class
(
sklearn
.
linear_model
.
LinearRegression
)
allow_class
(
sklearn
.
linear_model
.
LinearRegression
)
# Modify 'safetype' dict in full_write_guard function
# allow write access to ndarray, DataFrame, ZBigArray and RAMArray objects
# of RestrictedPython (closure) directly To allow
def
allow_full_write
(
t
):
# write access to ndarray, DataFrame, ZBigArray and RAMArray objects
"""Allow setting and deleting items and attributes for this type.
from
RestrictedPython.Guards
import
full_write_guard
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
np
.
ndarray
]
=
True
This supports both RestrictedPython-3.6.0, where the safetype is implemented as:
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
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
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
)
allow_type
(
ZBigArray
)
from
wendelin.bigarray.array_ram
import
RAMArray
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
)
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