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
Gabriel 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
Hide 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,163 +111,6 @@ class SetGetter(ListGetter):
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
class
DefaultIdGetter
(
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
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getDefaultRelatedProperty
(
self
.
_key
,
'id'
,
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__
)
IdGetter
=
DefaultIdGetter
class
IdListGetter
(
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
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type"
,
WARNING
,
"Deprecated Getter Id: %s"
%
self
.
_id
)
return
instance
.
_getRelatedPropertyList
(
self
.
_key
,
'id'
,
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
(
IdListGetter
):
"""
Gets a category value set
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
result_list
=
IdListGetter
.
__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
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
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
))
psyco
.
bind
(
__call__
)
class
TitleSetGetter
(
TitleListGetter
):
"""
Gets a category value set
"""
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
):
"""
...
...
@@ -345,3 +188,31 @@ class PropertySetGetter(PropertyListGetter):
result_list
=
PropertyListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
result_set
=
dict
([(
x
,
0
)
for
x
in
result_list
]).
keys
()
return
result_set
class
DefaultIdGetter
(
PropertyGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
IdGetter
=
DefaultIdGetter
class
IdListGetter
(
PropertyListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
class
IdSetGetter
(
PropertySetGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertySetGetter
.
__call__
(
self
,
instance
,
'id'
,
*
args
,
**
kw
)
class
DefaultTitleGetter
(
PropertyGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
TitleGetter
=
DefaultTitleGetter
class
TitleListGetter
(
PropertyListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
PropertyListGetter
.
__call__
(
self
,
instance
,
'title'
,
*
args
,
**
kw
)
class
TitleSetGetter
(
PropertySetGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
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