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
Klaus Wölfel
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):
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
class
DefaultIdGetter
(
BaseGetter
):
class
DefaultPropertyGetter
(
BaseGetter
):
"""
Gets a default reference object
"""
...
...
@@ -130,11 +131,11 @@ class DefaultIdGetter(BaseGetter):
self
.
_key
=
key
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getDefaultRelatedProperty
(
self
.
_key
,
'id'
,
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
...
...
@@ -142,12 +143,11 @@ class DefaultIdGetter(BaseGetter):
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
IdGetter
=
DefaultId
Getter
PropertyGetter
=
DefaultProperty
Getter
class
Id
ListGetter
(
BaseGetter
):
class
Property
ListGetter
(
BaseGetter
):
"""
Gets a list of reference objects
"""
...
...
@@ -166,11 +166,11 @@ class IdListGetter(BaseGetter):
self
.
_key
=
key
self
.
_warning
=
warning
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getRelatedPropertyList
(
self
.
_key
,
'id'
,
self
.
_key
,
key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
...
...
@@ -178,170 +178,41 @@ class IdListGetter(BaseGetter):
# 'strict' is deprecated
kw
.
get
(
'strict'
,
None
)),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
psyco
.
bind
(
__call__
)
class
IdSetGetter
(
Id
ListGetter
):
class
PropertySetGetter
(
Property
ListGetter
):
"""
Gets a category value set
"""
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
()
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
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
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
return
PropertyGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
IdGetter
=
DefaultIdGetter
class
IdListGetter
(
PropertyListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
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
))
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
psyco
.
bind
(
__call__
)
class
TitleSetGetter
(
TitleListGetter
):
"""
Gets a category value set
"""
class
IdSetGetter
(
PropertySetGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
TitleListGetter
.
__call__
(
self
,
instance
,
*
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
return
PropertySetGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
# 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
DefaultTitleGetter
(
PropertyGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
TitleGetter
=
DefaultTitleGetter
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
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
TitleListGetter
(
PropertyListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
class
PropertySetGetter
(
PropertyListGetter
):
"""
Gets a category value set
"""
class
TitleSetGetter
(
PropertySetGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
PropertyListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
return
PropertySetGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
product/ERP5Type/tests/testERP5Type.py
View file @
2f683b4e
...
...
@@ -398,10 +398,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal_type
=
"Person"
),
[
person_object
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedTitleList
(
portal_type
=
"Person"
),
[
person_title
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedTitleSet
(
portal_type
=
"Person"
),
[
person_title
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedList
(
portal_type
=
"Person"
),
[
person_relative_url
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedIdList
(
portal_type
=
"Person"
),
[
person_id
]
)
self
.
assertEquals
(
category_object
.
getRegionRelatedIdSet
(
portal_type
=
"Person"
),
[
person_id
]
)
def
checkRelationUnset
(
self
):
self
.
commit
()
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