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
143
Merge Requests
143
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
Jobs
Commits
Open sidebar
nexedi
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
Show 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):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
self
.
_warning
:
LOG
(
"ERP5Type Deprecated Getter Id:"
,
0
,
self
.
_id
)
#LOG("__call__:",0, str((args,kw)))
return
instance
.
_getAcquiredValueList
(
self
.
_key
,
**
kw
)
psyco
.
bind
(
__call__
)
...
...
@@ -190,27 +189,9 @@ class DefaultTitleGetter(BaseGetter):
psyco
.
bind
(
__call__
)
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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
class
TitleListGetter
(
ListGetter
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getTitle
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
**
kw
)]
return
[
x
.
getTitle
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
TitleSetGetter
(
TitleListGetter
):
...
...
@@ -223,62 +204,17 @@ class TitleSetGetter(TitleListGetter):
return
result_set
class
DefaultTranslatedTitleGetter
(
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
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
class
DefaultTranslatedTitleGetter
(
DefaultGetter
):
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
))
o
=
DefaultGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
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
class
TranslatedTitleListGetter
(
ListGetter
):
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
))
]
return
[
x
.
getTranslatedTitle
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
TranslatedTitleSetGetter
(
TranslatedTitleListGetter
):
...
...
@@ -322,32 +258,9 @@ class DefaultReferenceGetter(BaseGetter):
psyco
.
bind
(
__call__
)
class
ReferenceListGetter
(
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
class
ReferenceListGetter
(
ListGetter
):
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
))
]
return
[
x
.
getReference
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
ReferenceSetGetter
(
ReferenceListGetter
):
...
...
@@ -394,32 +307,9 @@ class DefaultUidGetter(BaseGetter):
UidGetter
=
DefaultUidGetter
class
UidListGetter
(
BaseGetter
):
"""
Gets a list of reference objects uid
"""
_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
class
UidListGetter
(
ListGetter
):
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
))
]
return
[
x
.
getUid
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
UidSetGetter
(
UidListGetter
):
...
...
@@ -593,32 +483,9 @@ class DefaultTranslatedLogicalPathGetter(DefaultLogicalPathGetter):
TranslatedLogicalPathGetter
=
DefaultTranslatedLogicalPathGetter
class
IdListGetter
(
BaseGetter
):
"""
Gets a list of reference objects uid
"""
_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
class
IdListGetter
(
ListGetter
):
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
))
]
return
[
x
.
getId
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
IdSetGetter
(
IdListGetter
):
...
...
@@ -632,33 +499,11 @@ class IdSetGetter(IdListGetter):
return
result_set
class
LogicalPathListGetter
(
BaseGetter
):
"""
Gets a list of logical path
"""
_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
=
()
class
LogicalPathListGetter
(
ListGetter
):
_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
))
]
return
[
x
.
getLogicalPath
(
item_method
=
self
.
_item_method
)
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
class
LogicalPathSetGetter
(
LogicalPathListGetter
):
"""
...
...
@@ -704,32 +549,9 @@ class DefaultPropertyGetter(BaseGetter):
PropertyGetter
=
DefaultPropertyGetter
class
PropertyListGetter
(
BaseGetter
):
"""
Gets a list of reference objects uid
"""
_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
class
PropertyListGetter
(
ListGetter
):
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
))
]
return
[
x
.
getProperty
(
key
)
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
psyco
.
bind
(
__call__
)
class
PropertySetGetter
(
PropertyListGetter
):
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
836a3594
...
...
@@ -2440,6 +2440,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# the value of the category title is translated with erp5_content
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
.
assertEquals
(
'Gamma System/Alpha'
,
doc
.
getRegionTranslatedLogicalPath
())
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