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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
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):
...
@@ -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,27 +189,9 @@ class DefaultTitleGetter(BaseGetter):
...
@@ -190,27 +189,9 @@ class DefaultTitleGetter(BaseGetter):
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
TitleListGetter
(
BaseGetter
):
class
TitleListGetter
(
ListGetter
):
"""
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
):
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__
)
psyco
.
bind
(
__call__
)
class
TitleSetGetter
(
TitleListGetter
):
class
TitleSetGetter
(
TitleListGetter
):
...
@@ -223,62 +204,17 @@ class TitleSetGetter(TitleListGetter):
...
@@ -223,62 +204,17 @@ class TitleSetGetter(TitleListGetter):
return
result_set
return
result_set
class
DefaultTranslatedTitleGetter
(
BaseGetter
):
class
DefaultTranslatedTitleGetter
(
DefaultGetter
):
"""
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
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
o
=
instance
.
_getDefaultAcquiredValue
(
self
.
_key
,
o
=
DefaultGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)
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
:
if
o
is
None
:
return
None
return
None
return
o
.
getTranslatedTitle
()
return
o
.
getTranslatedTitle
()
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
TranslatedTitleListGetter
(
BaseGetter
):
class
TranslatedTitleListGetter
(
ListGetter
):
"""
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
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getTranslatedTitle
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
return
[
x
.
getTranslatedTitle
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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__
)
psyco
.
bind
(
__call__
)
class
TranslatedTitleSetGetter
(
TranslatedTitleListGetter
):
class
TranslatedTitleSetGetter
(
TranslatedTitleListGetter
):
...
@@ -322,32 +258,9 @@ class DefaultReferenceGetter(BaseGetter):
...
@@ -322,32 +258,9 @@ class DefaultReferenceGetter(BaseGetter):
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
class
ReferenceListGetter
(
BaseGetter
):
class
ReferenceListGetter
(
ListGetter
):
"""
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
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getReference
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
return
[
x
.
getReference
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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__
)
psyco
.
bind
(
__call__
)
class
ReferenceSetGetter
(
ReferenceListGetter
):
class
ReferenceSetGetter
(
ReferenceListGetter
):
...
@@ -394,32 +307,9 @@ class DefaultUidGetter(BaseGetter):
...
@@ -394,32 +307,9 @@ class DefaultUidGetter(BaseGetter):
UidGetter
=
DefaultUidGetter
UidGetter
=
DefaultUidGetter
class
UidListGetter
(
BaseGetter
):
class
UidListGetter
(
ListGetter
):
"""
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
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getUid
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
return
[
x
.
getUid
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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__
)
psyco
.
bind
(
__call__
)
class
UidSetGetter
(
UidListGetter
):
class
UidSetGetter
(
UidListGetter
):
...
@@ -593,32 +483,9 @@ class DefaultTranslatedLogicalPathGetter(DefaultLogicalPathGetter):
...
@@ -593,32 +483,9 @@ class DefaultTranslatedLogicalPathGetter(DefaultLogicalPathGetter):
TranslatedLogicalPathGetter
=
DefaultTranslatedLogicalPathGetter
TranslatedLogicalPathGetter
=
DefaultTranslatedLogicalPathGetter
class
IdListGetter
(
BaseGetter
):
class
IdListGetter
(
ListGetter
):
"""
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
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getId
()
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
return
[
x
.
getId
()
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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__
)
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
):
"""
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
=
()
_item_method
=
'getTitle'
_item_method
=
'getTitle'
def
__init__
(
self
,
id
,
key
):
self
.
_id
=
id
self
.
__name__
=
id
self
.
_key
=
key
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
return
[
x
.
getLogicalPath
(
item_method
=
self
.
_item_method
)
return
[
x
.
getLogicalPath
(
item_method
=
self
.
_item_method
)
for
x
in
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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,32 +549,9 @@ class DefaultPropertyGetter(BaseGetter):
...
@@ -704,32 +549,9 @@ class DefaultPropertyGetter(BaseGetter):
PropertyGetter
=
DefaultPropertyGetter
PropertyGetter
=
DefaultPropertyGetter
class
PropertyListGetter
(
BaseGetter
):
class
PropertyListGetter
(
ListGetter
):
"""
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
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
key
,
*
args
,
**
kw
):
return
[
x
.
getProperty
(
key
)
for
x
in
instance
.
_getAcquiredValueList
(
self
.
_key
,
return
[
x
.
getProperty
(
key
)
for
x
in
ListGetter
.
__call__
(
self
,
instance
,
*
args
,
**
kw
)]
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__
)
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