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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
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:
...
@@ -61,21 +61,22 @@ class PropertyRecordableMixin:
id -- ID of the property
id -- ID of the property
"""
"""
try
:
for
property_info
in
self
.
getPropertyMap
():
property_info
=
[
x
for
x
in
self
.
getPropertyMap
()
\
if
property_info
[
'id'
]
==
id
:
if
x
[
'id'
]
==
id
][
0
]
if
property_info
[
'type'
]
in
list_types
:
except
IndexError
:
value
=
self
.
getPropertyList
(
id
)
else
:
value
=
self
.
getProperty
(
id
)
break
else
:
if
id
in
self
.
getBaseCategoryList
():
if
id
in
self
.
getBaseCategoryList
():
value
=
self
.
getPropertyList
(
id
)
value
=
self
.
getPropertyList
(
id
)
else
:
# should be local property
else
:
# should be local property
value
=
self
.
getProperty
(
id
)
value
=
self
.
getProperty
(
id
)
else
:
try
:
if
property_info
[
'type'
]
in
list_types
:
self
.
_getRecordedPropertyDict
()[
id
]
=
value
value
=
self
.
getPropertyList
(
id
)
except
AttributeError
:
else
:
self
.
_recorded_property_dict
=
PersistentMapping
({
id
:
value
})
value
=
self
.
getProperty
(
id
)
recorded_property_dict
=
self
.
_getRecordedPropertyDict
()
recorded_property_dict
[
id
]
=
value
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'clearRecordedProperty'
)
'clearRecordedProperty'
)
...
@@ -84,11 +85,7 @@ class PropertyRecordableMixin:
...
@@ -84,11 +85,7 @@ class PropertyRecordableMixin:
Clears a previously recorded property from
Clears a previously recorded property from
the property record.
the property record.
"""
"""
recorded_property_dict
=
self
.
_getRecordedPropertyDict
()
self
.
_getRecordedPropertyDict
({}).
pop
(
id
,
None
)
try
:
del
(
recorded_property_dict
[
id
])
except
KeyError
:
pass
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getRecordedPropertyIdList'
)
'getRecordedPropertyIdList'
)
...
@@ -97,7 +94,7 @@ class PropertyRecordableMixin:
...
@@ -97,7 +94,7 @@ class PropertyRecordableMixin:
Returns the list of property IDs which have
Returns the list of property IDs which have
been recorded.
been recorded.
"""
"""
return
(
self
.
_getRecordedPropertyDict
().
keys
()
)
return
self
.
_getRecordedPropertyDict
({}).
keys
(
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'isPropertyRecorded'
)
'isPropertyRecorded'
)
...
@@ -108,7 +105,7 @@ class PropertyRecordableMixin:
...
@@ -108,7 +105,7 @@ class PropertyRecordableMixin:
id -- ID of the property
id -- ID of the property
"""
"""
return
self
.
_getRecordedPropertyDict
().
has_key
(
id
)
return
id
in
self
.
_getRecordedPropertyDict
(()
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getRecordedProperty'
)
'getRecordedProperty'
)
...
@@ -128,10 +125,9 @@ class PropertyRecordableMixin:
...
@@ -128,10 +125,9 @@ class PropertyRecordableMixin:
which recorded properties in its context.
which recorded properties in its context.
"""
"""
context
=
self
.
asContext
()
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
return
context
def
_getRecordedPropertyDict
(
self
):
def
_getRecordedPropertyDict
(
self
,
*
args
):
if
getattr
(
aq_base
(
self
),
'_recorded_property_dict'
,
None
)
is
None
:
return
getattr
(
aq_base
(
self
),
'_recorded_property_dict'
,
*
args
)
self
.
_recorded_property_dict
=
PersistentMapping
()
return
self
.
_recorded_property_dict
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