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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
13257f24
Commit
13257f24
authored
Nov 30, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: PERF: improve ERP5PersistentMapping performance
parent
4da760e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
24 deletions
+13
-24
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
+13
-24
No files found.
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
View file @
13257f24
...
...
@@ -43,15 +43,9 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
except
KeyError
:
raise
AttributeError
(
name
)
def
__len__
(
self
):
return
self
.
objectCount
()
def
_initPersistentObjects
(
self
,
object_id
=
None
):
def
_initPersistentObjects
(
self
):
self
.
_cleanup
()
if
object_id
is
None
:
self
.
__init__
(
self
.
id
)
else
:
self
.
__init__
(
object_id
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'get'
)
def
get
(
self
,
name
,
default
=
None
):
...
...
@@ -92,12 +86,12 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
def
objectCount
(
self
):
return
len
(
self
.
_object_dict
)
__len__
=
objectCount
def
objectItems
(
self
,
spec
=
None
):
assert
(
spec
is
None
)
return
self
.
_object_dict
.
items
()
def
objectIds_d
(
self
,
t
=
None
):
assert
(
t
is
None
)
return
objectIds
(
self
,
t
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -110,6 +104,7 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
if
spec
is
not
None
:
if
isinstance
(
spec
,
str
):
spec
=
(
spec
,)
# XXX(WORKFLOW): remove this and use portal_type only
# hack to get the portal type for a specified meta_type
portal_type
=
[
meta_type
[
5
:]
for
meta_type
in
spec
if
meta_type
.
startswith
(
'ERP5 '
)]
...
...
@@ -120,13 +115,14 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
if
portal_type
is
not
None
:
if
isinstance
(
portal_type
,
str
):
portal_type
=
(
portal_type
,)
object_list
=
filter
(
lambda
x
:
x
.
getPortalType
()
in
portal_type
,
object_list
)
object_list
=
[
x
for
x
in
object_list
if
x
.
getPortalType
()
in
portal_type
]
if
checked_permission
is
not
None
:
checkPermission
=
getSecurityManager
().
checkPermission
object_list
=
[
o
for
o
in
object_list
if
checkPermission
(
checked_permission
,
o
)]
return
[
x
.
__of__
(
self
)
for
x
in
sortValueList
(
object_list
,
sort_on
,
sort_order
,
**
kw
)]
return
[
x
.
__of__
(
self
)
for
x
in
sortValueList
(
object_list
,
sort_on
,
sort_order
,
**
kw
)]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'keys'
,
'items'
,
'values'
)
...
...
@@ -142,12 +138,9 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
id
=
v
# If an object by the given id already exists, remove it.
if
id
in
self
:
if
self
.
has_key
(
id
)
:
self
.
_delObject
(
id
)
if
not
suppress_events
:
notify
(
ObjectWillBeAddedEvent
(
ob
,
self
,
id
))
self
.
_setOb
(
id
,
ob
)
ob
=
self
.
_getOb
(
id
)
...
...
@@ -165,15 +158,11 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
if
userid
is
not
None
:
ob
.
manage_setLocalRoles
(
userid
,
[
'Owner'
])
if
not
suppress_events
:
notify
(
ObjectAddedEvent
(
ob
,
self
,
id
))
notifyContainerModified
(
self
)
compatibilityCall
(
'manage_afterAdd'
,
ob
,
ob
,
self
)
return
id
def
_cleanup
(
self
):
# XXX(WORKFLOW): just do something on _object_dict, create another function
# for conversion
cleaned
=
False
for
attribute
in
(
'_tree'
,
'_mt_index'
,
'_count'
):
try
:
...
...
@@ -214,6 +203,6 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
return
()
def
_checkId
(
self
,
id
,
allow_dup
=
0
):
if
self
.
_object_dict
is
not
None
and
not
allow_dup
and
id
in
self
.
_object_dict
:
if
not
allow_dup
and
self
.
has_key
(
id
)
:
raise
BadRequestException
(
'The id "%s" is invalid--'
'it is already in use.'
%
id
)
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