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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
2f683b4e
Commit
2f683b4e
authored
May 15, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify related accessors
parent
de579ea9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
157 deletions
+33
-157
product/ERP5Type/Accessor/RelatedValue.py
product/ERP5Type/Accessor/RelatedValue.py
+28
-157
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+5
-0
No files found.
product/ERP5Type/Accessor/RelatedValue.py
View file @
2f683b4e
...
@@ -111,7 +111,8 @@ class SetGetter(ListGetter):
...
@@ -111,7 +111,8 @@ class SetGetter(ListGetter):
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
return
result_set
class
DefaultIdGetter
(
BaseGetter
):
class
DefaultPropertyGetter
(
BaseGetter
):
"""
"""
Gets a default reference object
Gets a default reference object
"""
"""
...
@@ -130,11 +131,11 @@ class DefaultIdGetter(BaseGetter):
...
@@ -130,11 +131,11 @@ class DefaultIdGetter(BaseGetter):
self
.
_key
=
key
self
.
_key
=
key
self
.
_warning
=
warning
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getDefaultRelatedProperty
(
return
instance
.
_getDefaultRelatedProperty
(
self
.
_key
,
'id'
,
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
portal_type
=
kw
.
get
(
'portal_type'
,()),
...
@@ -142,12 +143,11 @@ class DefaultIdGetter(BaseGetter):
...
@@ -142,12 +143,11 @@ class DefaultIdGetter(BaseGetter):
# 'strict' is deprecated
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
IdGetter
=
DefaultId
Getter
PropertyGetter
=
DefaultProperty
Getter
class
Id
ListGetter
(
BaseGetter
):
class
Property
ListGetter
(
BaseGetter
):
"""
"""
Gets a list of reference objects
Gets a list of reference objects
"""
"""
...
@@ -166,11 +166,11 @@ class IdListGetter(BaseGetter):
...
@@ -166,11 +166,11 @@ class IdListGetter(BaseGetter):
self
.
_key
=
key
self
.
_key
=
key
self
.
_warning
=
warning
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getRelatedPropertyList
(
return
instance
.
_getRelatedPropertyList
(
self
.
_key
,
'id'
,
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
portal_type
=
kw
.
get
(
'portal_type'
,()),
...
@@ -178,170 +178,41 @@ class IdListGetter(BaseGetter):
...
@@ -178,170 +178,41 @@ class IdListGetter(BaseGetter):
# 'strict' is deprecated
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
IdSetGetter
(
Id
ListGetter
):
class
PropertySetGetter
(
Property
ListGetter
):
"""
"""
Gets a category value set
Gets a category value set
"""
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
Id
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
result_list
=
Property
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
return
result_set
class
DefaultTitleGetter
(
BaseGetter
):
"""
Gets a default reference object
"""
_need__name__
=
1
# Generic Definition of Method Object
# This is required to call the method form the Web
func_code
=
func_code
()
func_code
.
co_varnames
=
(
'self'
,
)
func_code
.
co_argcount
=
1
func_defaults
=
()
def
__init__
(
self
,
id
,
key
,
warning
=
0
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
self
.
_warning
=
warning
class
DefaultIdGetter
(
PropertyGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
return
PropertyGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
IdGetter
=
DefaultIdGetter
return
instance
.
_getDefaultRelatedProperty
(
self
.
_key
,
'title'
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
strict_membership
=
kw
.
get
(
'strict_membership'
,
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
TitleGetter
=
DefaultTitleGetter
class
TitleListGetter
(
BaseGetter
):
"""
Gets a list of reference objects
"""
_need__name__
=
1
# Generic Definition of Method Object
# This is required to call the method form the Web
func_code
=
func_code
()
func_code
.
co_varnames
=
(
'self'
,
)
func_code
.
co_argcount
=
1
func_defaults
=
()
def
__init__
(
self
,
id
,
key
,
warning
=
0
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
self
.
_warning
=
warning
class
IdListGetter
(
PropertyListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getRelatedPropertyList
(
self
.
_key
,
'title'
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
strict_membership
=
kw
.
get
(
'strict_membership'
,
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
class
IdSetGetter
(
PropertySetGetter
):
class
TitleSetGetter
(
TitleListGetter
):
"""
Gets a category value set
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
TitleListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
return
PropertySetGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
class
DefaultPropertyGetter
(
BaseGetter
):
"""
Gets a default reference object
"""
_need__name__
=
1
# Generic Definition of Method Object
# This is required to call the method form the Web
func_code
=
func_code
()
func_code
.
co_varnames
=
(
'self'
,
)
func_code
.
co_argcount
=
1
func_defaults
=
()
def
__init__
(
self
,
id
,
key
,
warning
=
0
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getDefaultRelatedProperty
(
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
strict_membership
=
kw
.
get
(
'strict_membership'
,
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
PropertyGetter
=
DefaultPropertyGetter
class
PropertyListGetter
(
BaseGetter
):
"""
Gets a list of reference objects
"""
_need__name__
=
1
# Generic Definition of Method Object
# This is required to call the method form the Web
func_code
=
func_code
()
func_code
.
co_varnames
=
(
'self'
,
)
func_code
.
co_argcount
=
1
func_defaults
=
()
def
__init__
(
self
,
id
,
key
,
warning
=
0
):
class
DefaultTitleGetter
(
PropertyGetter
):
self
.
_id
=
id
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
self
.
__name__
=
id
return
PropertyGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
self
.
_key
=
key
TitleGetter
=
DefaultTitleGetter
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
class
TitleListGetter
(
PropertyListGetter
):
if
self
.
_warning
:
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
return
instance
.
_getRelatedPropertyList
(
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
strict_membership
=
kw
.
get
(
'strict_membership'
,
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
class
PropertySetGetter
(
PropertyListGetter
):
class
TitleSetGetter
(
PropertySetGetter
):
"""
Gets a category value set
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
PropertyListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
return
PropertySetGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
product/ERP5Type/tests/testERP5Type.py
View file @
2f683b4e
...
@@ -398,10 +398,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -398,10 +398,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal_type
=
"Person"
),
[
person_object
]
)
portal_type
=
"Person"
),
[
person_object
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedTitleList
(
self
.
assertEquals
(
category_object
.
getRegionRelatedTitleList
(
portal_type
=
"Person"
),
[
person_title
]
)
portal_type
=
"Person"
),
[
person_title
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedTitleSet
(
portal_type
=
"Person"
),
[
person_title
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedList
(
self
.
assertEquals
(
category_object
.
getRegionRelatedList
(
portal_type
=
"Person"
),
[
person_relative_url
]
)
portal_type
=
"Person"
),
[
person_relative_url
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedIdList
(
self
.
assertEquals
(
category_object
.
getRegionRelatedIdList
(
portal_type
=
"Person"
),
[
person_id
]
)
portal_type
=
"Person"
),
[
person_id
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedIdSet
(
portal_type
=
"Person"
),
[
person_id
]
)
def
checkRelationUnset
(
self
):
def
checkRelationUnset
(
self
):
self
.
commit
()
self
.
commit
()
person_object
.
reindexObject
()
person_object
.
reindexObject
()
...
...
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