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
Labels
Merge Requests
140
Merge Requests
140
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
c1fba44c
Commit
c1fba44c
authored
Mar 10, 2021
by
Aurel
Committed by
Arnaud Fontaine
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip : update patches & import for zope4
parent
3db45131
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
30 deletions
+33
-30
product/ERP5Type/CopySupport.py
product/ERP5Type/CopySupport.py
+8
-10
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+2
-3
product/ERP5Type/patches/Restricted.py
product/ERP5Type/patches/Restricted.py
+21
-15
product/ZSQLCatalog/ZSQLCatalog.py
product/ZSQLCatalog/ZSQLCatalog.py
+2
-2
No files found.
product/ERP5Type/CopySupport.py
View file @
c1fba44c
...
...
@@ -21,8 +21,6 @@ from AccessControl.Permission import Permission
from
OFS.ObjectManager
import
ObjectManager
from
OFS.CopySupport
import
CopyContainer
as
OriginalCopyContainer
from
OFS.CopySupport
import
CopyError
from
OFS.CopySupport
import
eNotSupported
,
eNoItemsSpecified
,
eNoData
from
OFS.CopySupport
import
eNotFound
,
eInvalid
from
OFS.CopySupport
import
_cb_encode
,
_cb_decode
,
cookie_path
from
OFS.CopySupport
import
sanity_check
from
Products.ERP5Type
import
Permissions
...
...
@@ -70,7 +68,7 @@ class CopyContainer:
return
OriginalCopyContainer
.
manage_copyObjects
(
self
,
ids
,
REQUEST
,
RESPONSE
)
if
uids
is
None
and
REQUEST
is
not
None
:
r
eturn
eNoItemsSpecified
r
aise
BadRequest
(
'No items specified'
)
elif
uids
is
None
:
raise
ValueError
(
'uids must be specified'
)
...
...
@@ -80,7 +78,7 @@ class CopyContainer:
for
uid
in
uids
:
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
if
not
ob
.
cb_isCopyable
():
raise
CopyError
(
eNotSupported
%
uid
)
raise
CopyError
(
'Not Supported'
)
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
m
.
dump
())
cp
=
(
0
,
oblist
)
...
...
@@ -185,7 +183,7 @@ class CopyContainer:
# Use default methode
return
OriginalCopyContainer
.
manage_cutObjects
(
self
,
ids
,
REQUEST
)
if
uids
is
None
and
REQUEST
is
not
None
:
r
eturn
eNoItemsSpecified
r
aise
BadRequest
(
'No items specified'
)
elif
uids
is
None
:
raise
ValueError
(
'uids must be specified'
)
...
...
@@ -195,7 +193,7 @@ class CopyContainer:
for
uid
in
uids
:
ob
=
self
.
getPortalObject
().
portal_catalog
.
getObject
(
uid
)
if
not
ob
.
cb_isMoveable
():
raise
CopyError
(
eNotSupported
%
id
)
raise
CopyError
(
'Not Supported'
)
m
=
Moniker
.
Moniker
(
ob
)
oblist
.
append
(
m
.
dump
())
cp
=
(
1
,
oblist
)
# 0->1 This is the difference with manage_copyObject
...
...
@@ -439,7 +437,7 @@ class CopyContainer:
try
:
cp
=
_cb_decode
(
cp
)
except
:
raise
CopyError
(
eInvalid
)
raise
CopyError
(
"Clipboard Error"
)
oblist
=
[]
op
=
cp
[
0
]
app
=
self
.
getPhysicalRoot
()
...
...
@@ -448,7 +446,7 @@ class CopyContainer:
try
:
ob
=
m
.
bind
(
app
)
except
:
raise
CopyError
(
eNotFound
)
raise
CopyError
(
'Item Not Found'
)
self
.
_verifyObjectPaste
(
ob
,
validate_src
=
op
+
1
)
oblist
.
append
(
ob
)
result
=
[]
...
...
@@ -475,7 +473,7 @@ class CopyContainer:
)[
op
]
for
ob
in
oblist
:
if
not
getattr
(
ob
,
is_doable_id
)():
raise
CopyError
(
eNotSupported
%
escape
(
ob
.
getId
())
)
raise
CopyError
(
'Not Supported'
)
try
:
ob
.
_notifyOfCopyTo
(
self
,
op
=
op
)
except
:
...
...
@@ -595,7 +593,7 @@ class CopyContainer:
elif
REQUEST
is
not
None
and
'__cp'
in
REQUEST
:
cp
=
REQUEST
[
'__cp'
]
if
cp
is
None
:
raise
CopyError
(
eNoData
)
raise
CopyError
(
"No Data"
)
op
,
result
=
self
.
__duplicate
(
cp
,
duplicate
=
False
,
...
...
product/ERP5Type/patches/DA.py
View file @
c1fba44c
...
...
@@ -17,11 +17,10 @@ import re
try
:
from
IOBTree
import
Bucket
except
:
Bucket
=
lambda
:{}
from
Shared.DC.ZRDB.Aqueduct
import
decodestring
,
parse
from
Shared.DC.ZRDB.DA
import
DA
,
DatabaseError
,
SQLMethodTracebackSupplement
from
Shared.DC.ZRDB.DA
import
DA
,
DatabaseError
,
SQLMethodTracebackSupplement
,
getBrain
from
Shared.DC.ZRDB
import
RDB
from
Shared.DC.ZRDB.Results
import
Results
from
App.Extensions
import
getBrain
from
AccessControl
import
ClassSecurityInfo
,
getSecurityManager
from
AccessControl
import
ClassSecurityInfo
,
getSecurityManager
from
Products.ERP5Type.Globals
import
InitializeClass
from
Acquisition
import
aq_base
,
aq_parent
from
zLOG
import
LOG
,
INFO
,
ERROR
...
...
product/ERP5Type/patches/Restricted.py
View file @
c1fba44c
...
...
@@ -16,26 +16,32 @@ import copy
import
sys
import
types
from
RestrictedPython.
RestrictionMutator
import
RestrictionMutato
r
from
RestrictedPython.
transformer
import
RestrictingNodeTransforme
r
_MARKER
=
[]
def
checkNameLax
(
self
,
node
,
name
=
_MARKER
):
"""
Verifies that a name being assigned is safe
.
def
checkNameLax
(
self
,
node
,
name
,
allow_magic_methods
=
False
):
"""
Check names if they are allowed
.
In ERP5 we are much more lax that than in Zope's original restricted
python and allow to using names starting with _, because we rely on
runtime checks to prevent access to forbidden attributes from objects.
We don't allow defining attributes ending with __roles__ though.
If ``allow_magic_methods is True`` names in `ALLOWED_FUNC_NAMES`
are additionally allowed although their names start with `_`.
"""
if
name
is
_MARKER
:
# we use same implementation for checkName and checkAttrName which access
# the name in different ways ( see RestrictionMutator 3.6.0 )
name
=
node
.
attrname
if
name
is
None
:
return
if
name
.
endswith
(
'__roles__'
):
self
.
error
(
node
,
'"%s" is an invalid variable name because '
'it ends with "__roles__".'
%
name
)
'it ends with "__roles__".'
%
name
)
elif
name
in
FORBIDDEN_FUNC_NAMES
:
self
.
error
(
node
,
'"{name}" is a reserved name.'
.
format
(
name
=
name
))
RestrictionMutator
.
checkName
=
RestrictionMutator
.
checkAttrName
=
checkNameLax
RestrictingNodeTransformer
.
check_name
=
checkNameLax
# XXX we might want to pach visit_Attribute too
from
Acquisition
import
aq_acquire
...
...
@@ -49,17 +55,17 @@ from AccessControl.ZopeGuards import (safe_builtins, _marker, Unauthorized,
# TODO: add buffer/bytearray
def
add_builtins
(
**
kw
):
assert
not
set
(
safe_builtins
).
intersection
(
kw
)
assert
not
set
(
safe_builtins
).
intersection
(
kw
)
,
"%r intersect %r
\
n
%r"
%
(
safe_builtins
,
kw
,
set
(
safe_builtins
).
intersection
(
kw
))
safe_builtins
.
update
(
kw
)
del
safe_builtins
[
'dict'
]
del
safe_builtins
[
'list'
]
add_builtins
(
Ellipsis
=
Ellipsis
,
NotImplemented
=
NotImplemented
,
dict
=
dict
,
list
=
list
,
set
=
set
,
frozenset
=
frozenset
)
dict
=
dict
,
list
=
list
)
#
, set=set, frozenset=frozenset)
add_builtins
(
bin
=
bin
,
classmethod
=
classmethod
,
format
=
format
,
object
=
object
,
property
=
property
,
s
lice
=
slice
,
s
taticmethod
=
staticmethod
,
super
=
super
,
type
=
type
)
property
=
property
,
staticmethod
=
staticmethod
,
super
=
super
,
type
=
type
)
# slice=slice,
def
guarded_next
(
iterator
,
default
=
_marker
):
"""next(iterator[, default])
...
...
@@ -81,7 +87,7 @@ def guarded_next(iterator, default=_marker):
if
default
is
_marker
:
raise
return
default
add_builtins
(
next
=
guarded_next
)
#
add_builtins(next=guarded_next)
_safe_class_attribute_dict
=
{}
import
inspect
...
...
@@ -237,7 +243,7 @@ from AccessControl.ZopeGuards import _dict_white_list
# (closure) directly to ignore defaultdict like dict/list
from
RestrictedPython.Guards
import
full_write_guard
ContainerAssertions
[
defaultdict
]
=
_check_access_wrapper
(
defaultdict
,
_dict_white_list
)
full_write_guard
.
func_closure
[
1
].
cell_contents
.
__self__
[
defaultdict
]
=
True
#XXX
full_write_guard.func_closure[1].cell_contents.__self__[defaultdict] = True
ContainerAssertions
[
OrderedDict
]
=
_check_access_wrapper
(
OrderedDict
,
_dict_white_list
)
OrderedDict
.
__guarded_setitem__
=
OrderedDict
.
__setitem__
.
__func__
...
...
product/ZSQLCatalog/ZSQLCatalog.py
View file @
c1fba44c
...
...
@@ -27,7 +27,7 @@ from Acquisition import Implicit, aq_base
from
Persistence
import
Persistent
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
Eval
from
AccessControl.Permission
import
name_trans
from
AccessControl.Permission
import
getPermissionIdentifier
from
AccessControl.Permissions
import
import_export_objects
,
\
manage_zcatalog_entries
from
.SQLCatalog
import
CatalogError
...
...
@@ -1364,7 +1364,7 @@ InitializeClass(ZCatalog)
def
p_name
(
name
):
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
return
getPermissionIdentifier
(
name
)
def
absattr
(
attr
):
if
callable
(
attr
):
return
attr
()
...
...
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