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
Thomas Gambier
erp5
Commits
836a3594
Commit
836a3594
authored
May 16, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make $(Property)ListGetter reuse ValueListGetter
parent
3a33bbf9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
214 deletions
+40
-214
product/ERP5Type/Accessor/Value.py
product/ERP5Type/Accessor/Value.py
+36
-214
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+4
-0
No files found.
product/ERP5Type/Accessor/Value.py
View file @
836a3594
...
@@ -148,7 +148,6 @@ class ListGetter(BaseGetter):
...
@@ -148,7 +148,6 @@ class ListGetter(BaseGetter):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
if
self
.
_warning
:
LOG
(
"ERP5Type Deprecated Getter Id:"
,
0
,
self
.
_id
)
LOG
(
"ERP5Type Deprecated Getter Id:"
,
0
,
self
.
_id
)
#LOG("__call__:",0, str((args,kw)))
return
instance
.
_getAcquiredValueList
(
self
.
_key
,
**
kw
)
return
instance
.
_getAcquiredValueList
(
self
.
_key
,
**
kw
)
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
...
@@ -190,28 +189,10 @@ class DefaultTitleGetter(BaseGetter):
...
@@ -190,28 +189,10 @@ class DefaultTitleGetter(BaseGetter):
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
TitleListGetter
(
BaseGetter
):
class
TitleListGetter
(
ListGetter
):
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
Gets a list of reference objects
return
[
x
.
getTitle
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
"""
psyco
.
bind
(
__call__
)
_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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getTitle
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
TitleSetGetter
(
TitleListGetter
):
class
TitleSetGetter
(
TitleListGetter
):
"""
"""
...
@@ -223,63 +204,18 @@ class TitleSetGetter(TitleListGetter):
...
@@ -223,63 +204,18 @@ class TitleSetGetter(TitleListGetter):
return
result_set
return
result_set
class
DefaultTranslatedTitleGetter
(
BaseGetter
):
class
DefaultTranslatedTitleGetter
(
DefaultGetter
):
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
Gets a default reference object
o
=
DefaultGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
"""
if
o
is
None
:
_need__name__
=
1
return
None
return
o
.
getTranslatedTitle
()
# Generic Definition of Method Object
psyco
.
bind
(
__call__
)
# 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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
o
=
instance
.
_getDefaultAcquiredValue
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
if
o
is
None
:
return
None
return
o
.
getTranslatedTitle
()
psyco
.
bind
(
__call__
)
class
TranslatedTitleListGetter
(
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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getTranslatedTitle
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
psyco
.
bind
(
__call__
)
class
TranslatedTitleListGetter
(
ListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getTranslatedTitle
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
TranslatedTitleSetGetter
(
TranslatedTitleListGetter
):
class
TranslatedTitleSetGetter
(
TranslatedTitleListGetter
):
"""
"""
...
@@ -322,33 +258,10 @@ class DefaultReferenceGetter(BaseGetter):
...
@@ -322,33 +258,10 @@ class DefaultReferenceGetter(BaseGetter):
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
ReferenceListGetter
(
BaseGetter
):
class
ReferenceListGetter
(
ListGetter
):
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
Gets a list of reference objects
return
[
x
.
getReference
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
"""
psyco
.
bind
(
__call__
)
_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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getReference
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
psyco
.
bind
(
__call__
)
class
ReferenceSetGetter
(
ReferenceListGetter
):
class
ReferenceSetGetter
(
ReferenceListGetter
):
"""
"""
...
@@ -394,33 +307,10 @@ class DefaultUidGetter(BaseGetter):
...
@@ -394,33 +307,10 @@ class DefaultUidGetter(BaseGetter):
UidGetter
=
DefaultUidGetter
UidGetter
=
DefaultUidGetter
class
UidListGetter
(
BaseGetter
):
class
UidListGetter
(
ListGetter
):
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
Gets a list of reference objects uid
return
[
x
.
getUid
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
"""
psyco
.
bind
(
__call__
)
_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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getUid
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
psyco
.
bind
(
__call__
)
class
UidSetGetter
(
UidListGetter
):
class
UidSetGetter
(
UidListGetter
):
"""
"""
...
@@ -593,33 +483,10 @@ class DefaultTranslatedLogicalPathGetter(DefaultLogicalPathGetter):
...
@@ -593,33 +483,10 @@ class DefaultTranslatedLogicalPathGetter(DefaultLogicalPathGetter):
TranslatedLogicalPathGetter
=
DefaultTranslatedLogicalPathGetter
TranslatedLogicalPathGetter
=
DefaultTranslatedLogicalPathGetter
class
IdListGetter
(
BaseGetter
):
class
IdListGetter
(
ListGetter
):
"""
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
Gets a list of reference objects uid
return
[
x
.
getId
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
"""
psyco
.
bind
(
__call__
)
_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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getId
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
psyco
.
bind
(
__call__
)
class
IdSetGetter
(
IdListGetter
):
class
IdSetGetter
(
IdListGetter
):
"""
"""
...
@@ -632,33 +499,11 @@ class IdSetGetter(IdListGetter):
...
@@ -632,33 +499,11 @@ class IdSetGetter(IdListGetter):
return
result_set
return
result_set
class
LogicalPathListGetter
(
BaseGetter
):
class
LogicalPathListGetter
(
ListGetter
):
"""
_item_method
=
'getTitle'
Gets a list of logical path
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
"""
return
[
x
.
getLogicalPath
(
item_method
=
self
.
_item_method
)
for
x
in
_need__name__
=
1
ListGetter
.
__call__
(
self
,
instance
,
*
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
=
()
_item_method
=
'getTitle'
def
__init__
(
self
,
id
,
key
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getLogicalPath
(
item_method
=
self
.
_item_method
)
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
class
LogicalPathSetGetter
(
LogicalPathListGetter
):
class
LogicalPathSetGetter
(
LogicalPathListGetter
):
"""
"""
...
@@ -704,33 +549,10 @@ class DefaultPropertyGetter(BaseGetter):
...
@@ -704,33 +549,10 @@ class DefaultPropertyGetter(BaseGetter):
PropertyGetter
=
DefaultPropertyGetter
PropertyGetter
=
DefaultPropertyGetter
class
PropertyListGetter
(
BaseGetter
):
class
PropertyListGetter
(
ListGetter
):
"""
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
Gets a list of reference objects uid
return
[
x
.
getProperty
(
key
)
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
"""
psyco
.
bind
(
__call__
)
_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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
return
[
x
.
getProperty
(
key
)
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
]
psyco
.
bind
(
__call__
)
class
PropertySetGetter
(
PropertyListGetter
):
class
PropertySetGetter
(
PropertyListGetter
):
"""
"""
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
836a3594
...
@@ -2440,6 +2440,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -2440,6 +2440,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# the value of the category title is translated with erp5_content
# the value of the category title is translated with erp5_content
self
.
assertEquals
([
'Alpha'
],
self
.
portal
.
Localizer
.
erp5_content
.
_translated
)
self
.
assertEquals
([
'Alpha'
],
self
.
portal
.
Localizer
.
erp5_content
.
_translated
)
self
.
portal
.
Localizer
.
erp5_content
.
_translated
=
[]
self
.
assertEquals
([
'Alpha'
],
doc
.
getRegionTranslatedTitleList
())
self
.
assertEquals
([
'Alpha'
],
self
.
portal
.
Localizer
.
erp5_content
.
_translated
)
self
.
portal
.
Localizer
.
erp5_content
.
_translated
=
[]
self
.
portal
.
Localizer
.
erp5_content
.
_translated
=
[]
self
.
assertEquals
(
'Gamma System/Alpha'
,
doc
.
getRegionTranslatedLogicalPath
())
self
.
assertEquals
(
'Gamma System/Alpha'
,
doc
.
getRegionTranslatedLogicalPath
())
self
.
assertEquals
([
'Gamma System'
,
'Alpha'
],
self
.
assertEquals
([
'Gamma System'
,
'Alpha'
],
...
...
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