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
Leo Le Bouter
erp5
Commits
db5e05dc
Commit
db5e05dc
authored
Jul 27, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
property_recordable: create '_recorded_property_dict' only if required
parent
1162ce93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
23 deletions
+19
-23
product/ERP5/mixin/property_recordable.py
product/ERP5/mixin/property_recordable.py
+19
-23
No files found.
product/ERP5/mixin/property_recordable.py
View file @
db5e05dc
...
...
@@ -61,21 +61,22 @@ class PropertyRecordableMixin:
id -- ID of the property
"""
try
:
property_info
=
[
x
for
x
in
self
.
getPropertyMap
()
\
if
x
[
'id'
]
==
id
][
0
]
except
IndexError
:
for
property_info
in
self
.
getPropertyMap
():
if
property_info
[
'id'
]
==
id
:
if
property_info
[
'type'
]
in
list_types
:
value
=
self
.
getPropertyList
(
id
)
else
:
value
=
self
.
getProperty
(
id
)
break
else
:
if
id
in
self
.
getBaseCategoryList
():
value
=
self
.
getPropertyList
(
id
)
else
:
# should be local property
value
=
self
.
getProperty
(
id
)
else
:
if
property_info
[
'type'
]
in
list_types
:
value
=
self
.
getPropertyList
(
id
)
else
:
value
=
self
.
getProperty
(
id
)
recorded_property_dict
=
self
.
_getRecordedPropertyDict
()
recorded_property_dict
[
id
]
=
value
try
:
self
.
_getRecordedPropertyDict
()[
id
]
=
value
except
AttributeError
:
self
.
_recorded_property_dict
=
PersistentMapping
({
id
:
value
})
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'clearRecordedProperty'
)
...
...
@@ -84,11 +85,7 @@ class PropertyRecordableMixin:
Clears a previously recorded property from
the property record.
"""
recorded_property_dict
=
self
.
_getRecordedPropertyDict
()
try
:
del
(
recorded_property_dict
[
id
])
except
KeyError
:
pass
self
.
_getRecordedPropertyDict
({}).
pop
(
id
,
None
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getRecordedPropertyIdList'
)
...
...
@@ -97,7 +94,7 @@ class PropertyRecordableMixin:
Returns the list of property IDs which have
been recorded.
"""
return
(
self
.
_getRecordedPropertyDict
().
keys
()
)
return
self
.
_getRecordedPropertyDict
({}).
keys
(
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'isPropertyRecorded'
)
...
...
@@ -108,7 +105,7 @@ class PropertyRecordableMixin:
id -- ID of the property
"""
return
self
.
_getRecordedPropertyDict
().
has_key
(
id
)
return
id
in
self
.
_getRecordedPropertyDict
(()
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getRecordedProperty'
)
...
...
@@ -128,10 +125,9 @@ class PropertyRecordableMixin:
which recorded properties in its context.
"""
context
=
self
.
asContext
()
context
.
edit
(
**
dict
(
self
.
_getRecordedPropertyDict
()))
# BBB: cast to dict is required for Python < 2.6
context
.
edit
(
**
dict
(
self
.
_getRecordedPropertyDict
(())))
return
context
def
_getRecordedPropertyDict
(
self
):
if
getattr
(
aq_base
(
self
),
'_recorded_property_dict'
,
None
)
is
None
:
self
.
_recorded_property_dict
=
PersistentMapping
()
return
self
.
_recorded_property_dict
def
_getRecordedPropertyDict
(
self
,
*
args
):
return
getattr
(
aq_base
(
self
),
'_recorded_property_dict'
,
*
args
)
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