Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
d4fc3821
Commit
d4fc3821
authored
Oct 05, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Form: use decorator syntax to apply lazyMethod on Listbox/PlanningBox methods
parent
1622517c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
145 deletions
+73
-145
product/ERP5Form/ListBox.py
product/ERP5Form/ListBox.py
+70
-139
product/ERP5Form/PlanningBox.py
product/ERP5Form/PlanningBox.py
+3
-6
No files found.
product/ERP5Form/ListBox.py
View file @
d4fc3821
...
@@ -533,6 +533,7 @@ class ListBoxRenderer:
...
@@ -533,6 +533,7 @@ class ListBoxRenderer:
# Here, define many getters which cache the results for better performance.
# Here, define many getters which cache the results for better performance.
@
lazyMethod
def
getContext
(
self
):
def
getContext
(
self
):
"""Return the context of rendering this ListBox.
"""Return the context of rendering this ListBox.
"""
"""
...
@@ -541,37 +542,32 @@ class ListBoxRenderer:
...
@@ -541,37 +542,32 @@ class ListBoxRenderer:
value
=
self
.
getForm
().
aq_parent
value
=
self
.
getForm
().
aq_parent
return
value
return
value
getContext
=
lazyMethod
(
getContext
)
@
lazyMethod
def
getForm
(
self
):
def
getForm
(
self
):
"""Return the form which contains the ListBox.
"""Return the form which contains the ListBox.
"""
"""
return
self
.
field
.
aq_parent
return
self
.
field
.
aq_parent
getForm
=
lazyMethod
(
getForm
)
@
lazyMethod
def
getEncoding
(
self
):
def
getEncoding
(
self
):
"""Retutn the encoding of strings in the fields. Default to UTF-8.
"""Retutn the encoding of strings in the fields. Default to UTF-8.
"""
"""
return
self
.
getPortalObject
().
getProperty
(
'management_page_charset'
,
'utf-8'
)
return
self
.
getPortalObject
().
getProperty
(
'management_page_charset'
,
'utf-8'
)
getEncoding
=
lazyMethod
(
getEncoding
)
@
lazyMethod
def
isReset
(
self
):
def
isReset
(
self
):
"""Determine if the ListBox should be reset.
"""Determine if the ListBox should be reset.
"""
"""
reset
=
self
.
request
.
get
(
'reset'
,
0
)
reset
=
self
.
request
.
get
(
'reset'
,
0
)
return
(
reset
not
in
(
0
,
'0'
))
return
(
reset
not
in
(
0
,
'0'
))
isReset
=
lazyMethod
(
isReset
)
@
lazyMethod
def
getFieldErrorDict
(
self
):
def
getFieldErrorDict
(
self
):
"""Return a dictionary of errors.
"""Return a dictionary of errors.
"""
"""
return
self
.
request
.
get
(
'field_errors'
,
{})
return
self
.
request
.
get
(
'field_errors'
,
{})
getFieldErrorDict
=
lazyMethod
(
getFieldErrorDict
)
@
lazyMethod
def
getUrl
(
self
):
def
getUrl
(
self
):
"""
"""
Return a requested URL.
Return a requested URL.
...
@@ -582,8 +578,7 @@ class ListBoxRenderer:
...
@@ -582,8 +578,7 @@ class ListBoxRenderer:
return
'%s/%s'
%
(
self
.
getContext
().
absolute_url
(),
return
'%s/%s'
%
(
self
.
getContext
().
absolute_url
(),
self
.
request
.
other
.
get
(
'current_form_id'
,
'view'
))
self
.
request
.
other
.
get
(
'current_form_id'
,
'view'
))
getUrl
=
lazyMethod
(
getUrl
)
@
lazyMethod
def
getRequestedSelectionName
(
self
):
def
getRequestedSelectionName
(
self
):
"""Return a selection name which may be passed by a request.
"""Return a selection name which may be passed by a request.
If not present, return "default". This selection can be different from the selection
If not present, return "default". This selection can be different from the selection
...
@@ -598,64 +593,54 @@ class ListBoxRenderer:
...
@@ -598,64 +593,54 @@ class ListBoxRenderer:
return
selection_name
return
selection_name
getRequestedSelectionName
=
lazyMethod
(
getRequestedSelectionName
)
@
lazyMethod
def
getSelectionIndex
(
self
):
def
getSelectionIndex
(
self
):
"""Return the index of a requested selection, or None if not specified.
"""Return the index of a requested selection, or None if not specified.
"""
"""
return
self
.
request
.
get
(
'selection_index'
,
None
)
return
self
.
request
.
get
(
'selection_index'
,
None
)
getSelectionIndex
=
lazyMethod
(
getSelectionIndex
)
@
lazyMethod
def
getReportDepth
(
self
):
def
getReportDepth
(
self
):
"""Return the depth of reports, or None if not specified.
"""Return the depth of reports, or None if not specified.
"""
"""
return
self
.
request
.
get
(
'report_depth'
,
None
)
return
self
.
request
.
get
(
'report_depth'
,
None
)
getReportDepth
=
lazyMethod
(
getReportDepth
)
@
lazyMethod
def
getPortalObject
(
self
):
def
getPortalObject
(
self
):
"""Return the portal object.
"""Return the portal object.
"""
"""
return
self
.
getContext
().
getPortalObject
()
return
self
.
getContext
().
getPortalObject
()
getPortalObject
=
lazyMethod
(
getPortalObject
)
@
lazyMethod
def
getPortalUrlString
(
self
):
def
getPortalUrlString
(
self
):
"""Return the URL of the portal as a string.
"""Return the URL of the portal as a string.
"""
"""
return
self
.
getPortalObject
().
portal_url
()
return
self
.
getPortalObject
().
portal_url
()
getPortalUrlString
=
lazyMethod
(
getPortalUrlString
)
@
lazyMethod
def
getCategoryTool
(
self
):
def
getCategoryTool
(
self
):
"""Return the Category Tool.
"""Return the Category Tool.
"""
"""
return
self
.
getPortalObject
().
portal_categories
return
self
.
getPortalObject
().
portal_categories
getCategoryTool
=
lazyMethod
(
getCategoryTool
)
@
lazyMethod
def
getDomainTool
(
self
):
def
getDomainTool
(
self
):
"""Return the Domain Tool.
"""Return the Domain Tool.
"""
"""
return
self
.
getPortalObject
().
portal_domains
return
self
.
getPortalObject
().
portal_domains
getDomainTool
=
lazyMethod
(
getDomainTool
)
@
lazyMethod
def
getCatalogTool
(
self
):
def
getCatalogTool
(
self
):
"""Return the Catalog Tool.
"""Return the Catalog Tool.
"""
"""
return
self
.
getPortalObject
().
portal_catalog
return
self
.
getPortalObject
().
portal_catalog
getCatalogTool
=
lazyMethod
(
getCatalogTool
)
@
lazyMethod
def
getSelectionTool
(
self
):
def
getSelectionTool
(
self
):
"""Return the Selection Tool.
"""Return the Selection Tool.
"""
"""
return
self
.
getPortalObject
().
portal_selections
return
self
.
getPortalObject
().
portal_selections
getSelectionTool
=
lazyMethod
(
getSelectionTool
)
def
getPrefixedString
(
self
,
string
):
def
getPrefixedString
(
self
,
string
):
prefix
=
self
.
render_prefix
prefix
=
self
.
render_prefix
if
prefix
is
None
:
if
prefix
is
None
:
...
@@ -664,55 +649,50 @@ class ListBoxRenderer:
...
@@ -664,55 +649,50 @@ class ListBoxRenderer:
result
=
'%s_%s'
%
(
prefix
,
string
)
result
=
'%s_%s'
%
(
prefix
,
string
)
return
result
return
result
@
lazyMethod
def
getId
(
self
):
def
getId
(
self
):
"""Return the id of the field. Usually, "listbox".
"""Return the id of the field. Usually, "listbox".
The prefix will automatically be added
The prefix will automatically be added
"""
"""
return
self
.
getPrefixedString
(
self
.
field
.
id
)
return
self
.
getPrefixedString
(
self
.
field
.
id
)
getId
=
lazyMethod
(
getId
)
@
lazyMethod
def
getUnprefixedId
(
self
):
def
getUnprefixedId
(
self
):
"""Return the id of the field. Usually, "listbox".
"""Return the id of the field. Usually, "listbox".
"""
"""
return
self
.
field
.
id
return
self
.
field
.
id
getUnprefixedId
=
lazyMethod
(
getUnprefixedId
)
@
lazyMethod
def
getTitle
(
self
):
def
getTitle
(
self
):
"""Return the title. Make sure that it is in unicode.
"""Return the title. Make sure that it is in unicode.
"""
"""
return
unicode
(
self
.
field
.
get_value
(
'title'
),
self
.
getEncoding
())
return
unicode
(
self
.
field
.
get_value
(
'title'
),
self
.
getEncoding
())
getTitle
=
lazyMethod
(
getTitle
)
def
getMaxLineNumber
(
self
):
def
getMaxLineNumber
(
self
):
"""Return the maximum number of lines shown in a page.
"""Return the maximum number of lines shown in a page.
This must be overridden in subclasses.
This must be overridden in subclasses.
"""
"""
raise
NotImplementedError
,
"getMaxLineNumber must be overridden in a subclass"
raise
NotImplementedError
,
"getMaxLineNumber must be overridden in a subclass"
@
lazyMethod
def
showSearchLine
(
self
):
def
showSearchLine
(
self
):
"""Return a boolean that represents whether a search line is displayed or not.
"""Return a boolean that represents whether a search line is displayed or not.
"""
"""
return
self
.
field
.
get_value
(
'search'
)
return
self
.
field
.
get_value
(
'search'
)
showSearchLine
=
lazyMethod
(
showSearchLine
)
@
lazyMethod
def
showSelectColumn
(
self
):
def
showSelectColumn
(
self
):
"""Return a boolean that represents whether a select column is displayed or not.
"""Return a boolean that represents whether a select column is displayed or not.
"""
"""
return
self
.
field
.
get_value
(
'select'
)
return
self
.
field
.
get_value
(
'select'
)
showSelectColumn
=
lazyMethod
(
showSelectColumn
)
@
lazyMethod
def
showAnchorColumn
(
self
):
def
showAnchorColumn
(
self
):
"""Return a boolean that represents whether a anchor column is displayed or not.
"""Return a boolean that represents whether a anchor column is displayed or not.
"""
"""
return
self
.
field
.
get_value
(
'anchor'
)
return
self
.
field
.
get_value
(
'anchor'
)
showAnchorColumn
=
lazyMethod
(
showAnchorColumn
)
@
lazyMethod
def
isHideRowsOnNoSearchCriterion
(
self
,
REQUEST
=
None
):
def
isHideRowsOnNoSearchCriterion
(
self
,
REQUEST
=
None
):
"""
"""
Return a boolean that represents whether search rows are shown or not.
Return a boolean that represents whether search rows are shown or not.
...
@@ -767,8 +747,7 @@ class ListBoxRenderer:
...
@@ -767,8 +747,7 @@ class ListBoxRenderer:
return
0
return
0
return
1
return
1
isHideRowsOnNoSearchCriterion
=
lazyMethod
(
isHideRowsOnNoSearchCriterion
)
@
lazyMethod
def
showStat
(
self
):
def
showStat
(
self
):
"""Return a boolean that represents whether a stat line is displayed or not.
"""Return a boolean that represents whether a stat line is displayed or not.
...
@@ -777,43 +756,37 @@ class ListBoxRenderer:
...
@@ -777,43 +756,37 @@ class ListBoxRenderer:
"""
"""
return
(
self
.
getStatMethod
()
is
not
None
)
and
(
len
(
self
.
getStatColumnList
())
>
0
)
return
(
self
.
getStatMethod
()
is
not
None
)
and
(
len
(
self
.
getStatColumnList
())
>
0
)
showStat
=
lazyMethod
(
showStat
)
@
lazyMethod
def
isDomainTreeSupported
(
self
):
def
isDomainTreeSupported
(
self
):
"""Return a boolean that represents whether a domain tree is supported or not.
"""Return a boolean that represents whether a domain tree is supported or not.
"""
"""
return
(
self
.
field
.
get_value
(
'domain_tree'
)
and
len
(
self
.
getDomainRootList
())
>
0
)
return
(
self
.
field
.
get_value
(
'domain_tree'
)
and
len
(
self
.
getDomainRootList
())
>
0
)
isDomainTreeSupported
=
lazyMethod
(
isDomainTreeSupported
)
@
lazyMethod
def
isReportTreeSupported
(
self
):
def
isReportTreeSupported
(
self
):
"""Return a boolean that represents whether a report tree is supported or not.
"""Return a boolean that represents whether a report tree is supported or not.
"""
"""
return
(
self
.
field
.
get_value
(
'report_tree'
)
and
len
(
self
.
getReportRootList
())
>
0
)
return
(
self
.
field
.
get_value
(
'report_tree'
)
and
len
(
self
.
getReportRootList
())
>
0
)
isReportTreeSupported
=
lazyMethod
(
isReportTreeSupported
)
@
lazyMethod
def
isDomainTreeMode
(
self
):
def
isDomainTreeMode
(
self
):
"""Return whether the current mode is domain tree mode or not.
"""Return whether the current mode is domain tree mode or not.
"""
"""
return
self
.
isDomainTreeSupported
()
and
self
.
getSelection
().
domain_tree_mode
return
self
.
isDomainTreeSupported
()
and
self
.
getSelection
().
domain_tree_mode
isDomainTreeMode
=
lazyMethod
(
isDomainTreeMode
)
@
lazyMethod
def
isReportTreeMode
(
self
):
def
isReportTreeMode
(
self
):
"""Return whether the current mode is report tree mode or not.
"""Return whether the current mode is report tree mode or not.
"""
"""
return
self
.
isReportTreeSupported
()
and
self
.
getSelection
().
report_tree_mode
return
self
.
isReportTreeSupported
()
and
self
.
getSelection
().
report_tree_mode
isReportTreeMode
=
lazyMethod
(
isReportTreeMode
)
@
lazyMethod
def
getDefaultParamList
(
self
):
def
getDefaultParamList
(
self
):
"""Return the list of default parameters.
"""Return the list of default parameters.
"""
"""
return
self
.
field
.
get_value
(
'default_params'
)
return
self
.
field
.
get_value
(
'default_params'
)
getDefaultParamList
=
lazyMethod
(
getDefaultParamList
)
@
lazyMethod
def
getListMethodName
(
self
):
def
getListMethodName
(
self
):
"""Return the name of the list method. If not defined, return None.
"""Return the name of the list method. If not defined, return None.
"""
"""
...
@@ -824,8 +797,7 @@ class ListBoxRenderer:
...
@@ -824,8 +797,7 @@ class ListBoxRenderer:
name
=
list_method
name
=
list_method
return
name
or
None
return
name
or
None
getListMethodName
=
lazyMethod
(
getListMethodName
)
@
lazyMethod
def
getCountMethodName
(
self
):
def
getCountMethodName
(
self
):
"""Return the name of the count method. If not defined, return None.
"""Return the name of the count method. If not defined, return None.
"""
"""
...
@@ -836,8 +808,7 @@ class ListBoxRenderer:
...
@@ -836,8 +808,7 @@ class ListBoxRenderer:
name
=
count_method
name
=
count_method
return
name
or
None
return
name
or
None
getCountMethodName
=
lazyMethod
(
getCountMethodName
)
@
lazyMethod
def
getStatMethodName
(
self
):
def
getStatMethodName
(
self
):
"""Return the name of the stat method. If not defined, return None.
"""Return the name of the stat method. If not defined, return None.
"""
"""
...
@@ -848,8 +819,7 @@ class ListBoxRenderer:
...
@@ -848,8 +819,7 @@ class ListBoxRenderer:
name
=
stat_method
name
=
stat_method
return
name
or
None
return
name
or
None
getStatMethodName
=
lazyMethod
(
getStatMethodName
)
@
lazyMethod
def
getRowCSSMethodName
(
self
):
def
getRowCSSMethodName
(
self
):
"""Return the name of the row CSS method. If not defined, return None.
"""Return the name of the row CSS method. If not defined, return None.
"""
"""
...
@@ -860,39 +830,34 @@ class ListBoxRenderer:
...
@@ -860,39 +830,34 @@ class ListBoxRenderer:
name
=
row_css_method
name
=
row_css_method
return
name
or
None
return
name
or
None
getRowCSSMethodName
=
lazyMethod
(
getRowCSSMethodName
)
@
lazyMethod
def
getSelectionName
(
self
):
def
getSelectionName
(
self
):
"""Return the selection name.
"""Return the selection name.
"""
"""
return
self
.
getPrefixedString
(
self
.
field
.
get_value
(
'selection_name'
))
return
self
.
getPrefixedString
(
self
.
field
.
get_value
(
'selection_name'
))
getSelectionName
=
lazyMethod
(
getSelectionName
)
@
lazyMethod
def
getMetaTypeList
(
self
):
def
getMetaTypeList
(
self
):
"""Return the list of meta types for filtering. Return None when empty.
"""Return the list of meta types for filtering. Return None when empty.
"""
"""
meta_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'meta_types'
)]
meta_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'meta_types'
)]
return
meta_types
or
None
return
meta_types
or
None
getMetaTypeList
=
lazyMethod
(
getMetaTypeList
)
@
lazyMethod
def
getPortalTypeList
(
self
):
def
getPortalTypeList
(
self
):
"""Return the list of portal types for filtering. Return None when empty.
"""Return the list of portal types for filtering. Return None when empty.
"""
"""
portal_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'portal_types'
)]
portal_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'portal_types'
)]
return
portal_types
or
None
return
portal_types
or
None
getPortalTypeList
=
lazyMethod
(
getPortalTypeList
)
@
lazyMethod
def
getColumnList
(
self
):
def
getColumnList
(
self
):
"""Return the columns. Make sure that the titles are in unicode.
"""Return the columns. Make sure that the titles are in unicode.
"""
"""
columns
=
self
.
field
.
get_value
(
'columns'
)
columns
=
self
.
field
.
get_value
(
'columns'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
getColumnList
=
lazyMethod
(
getColumnList
)
@
lazyMethod
def
getAllColumnList
(
self
):
def
getAllColumnList
(
self
):
"""Return the all columns. Make sure that the titles are in unicode.
"""Return the all columns. Make sure that the titles are in unicode.
Make sure there is no duplicates.
Make sure there is no duplicates.
...
@@ -904,15 +869,13 @@ class ListBoxRenderer:
...
@@ -904,15 +869,13 @@ class ListBoxRenderer:
if
c
[
0
]
not
in
all_column_id_set
)
if
c
[
0
]
not
in
all_column_id_set
)
return
all_column_list
return
all_column_list
getAllColumnList
=
lazyMethod
(
getAllColumnList
)
@
lazyMethod
def
getStyleColumnList
(
self
):
def
getStyleColumnList
(
self
):
"""Return the style columns columns.
"""Return the style columns columns.
"""
"""
return
self
.
field
.
get_value
(
'style_columns'
)
return
self
.
field
.
get_value
(
'style_columns'
)
getStyleColumnList
=
lazyMethod
(
getStyleColumnList
)
@
lazyMethod
def
getStatColumnList
(
self
):
def
getStatColumnList
(
self
):
"""Return the stat columns. Fall back to all the columns if empty.
"""Return the stat columns. Fall back to all the columns if empty.
"""
"""
...
@@ -923,8 +886,7 @@ class ListBoxRenderer:
...
@@ -923,8 +886,7 @@ class ListBoxRenderer:
stat_column_list
=
[(
c
[
0
],
c
[
0
])
for
c
in
self
.
getAllColumnList
()]
stat_column_list
=
[(
c
[
0
],
c
[
0
])
for
c
in
self
.
getAllColumnList
()]
return
stat_column_list
return
stat_column_list
getStatColumnList
=
lazyMethod
(
getStatColumnList
)
@
lazyMethod
def
getUrlColumnList
(
self
):
def
getUrlColumnList
(
self
):
"""Return the url columns. Make sure that it is an empty list, when not defined.
"""Return the url columns. Make sure that it is an empty list, when not defined.
"""
"""
...
@@ -938,31 +900,27 @@ class ListBoxRenderer:
...
@@ -938,31 +900,27 @@ class ListBoxRenderer:
untranslatable_columns
=
self
.
field
.
get_value
(
'untranslatable_columns'
)
untranslatable_columns
=
self
.
field
.
get_value
(
'untranslatable_columns'
)
return
untranslatable_columns
or
[]
return
untranslatable_columns
or
[]
getUrlColumnList
=
lazyMethod
(
getUrlColumnList
)
@
lazyMethod
def
getDefaultSortColumnList
(
self
):
def
getDefaultSortColumnList
(
self
):
"""Return the default sort columns.
"""Return the default sort columns.
"""
"""
return
self
.
field
.
get_value
(
'sort'
)
return
self
.
field
.
get_value
(
'sort'
)
getDefaultSortColumnList
=
lazyMethod
(
getDefaultSortColumnList
)
@
lazyMethod
def
getDomainRootList
(
self
):
def
getDomainRootList
(
self
):
"""Return the domain root list. Make sure that the titles are in unicode.
"""Return the domain root list. Make sure that the titles are in unicode.
"""
"""
domain_root_list
=
self
.
field
.
get_value
(
'domain_root_list'
)
domain_root_list
=
self
.
field
.
get_value
(
'domain_root_list'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
getDomainRootList
=
lazyMethod
(
getDomainRootList
)
@
lazyMethod
def
getReportRootList
(
self
):
def
getReportRootList
(
self
):
"""Return the report root list. Make sure that the titles are in unicode.
"""Return the report root list. Make sure that the titles are in unicode.
"""
"""
report_root_list
=
self
.
field
.
get_value
(
'report_root_list'
)
report_root_list
=
self
.
field
.
get_value
(
'report_root_list'
)
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
getReportRootList
=
lazyMethod
(
getReportRootList
)
@
lazyMethod
def
getDisplayStyleList
(
self
):
def
getDisplayStyleList
(
self
):
"""Return the list of avaible display style. Make sure that the
"""Return the list of avaible display style. Make sure that the
titles are in unicode"""
titles are in unicode"""
...
@@ -970,20 +928,16 @@ class ListBoxRenderer:
...
@@ -970,20 +928,16 @@ class ListBoxRenderer:
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
return
[(
str
(
c
[
0
]),
unicode
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
display_style_list
]
display_style_list
]
getDisplayStyleList
=
lazyMethod
(
getDisplayStyleList
)
@
lazyMethod
def
getDefaultDisplayStyle
(
self
):
def
getDefaultDisplayStyle
(
self
):
"""Return the default display list style."""
"""Return the default display list style."""
return
self
.
field
.
get_value
(
'default_display_style'
)
return
self
.
field
.
get_value
(
'default_display_style'
)
getDefaultDisplayStyle
=
lazyMethod
(
getDefaultDisplayStyle
)
@
lazyMethod
def
getGlobalSearchColumn
(
self
):
def
getGlobalSearchColumn
(
self
):
"""Return the full text search key."""
"""Return the full text search key."""
return
self
.
field
.
get_value
(
'global_search_column'
)
return
self
.
field
.
get_value
(
'global_search_column'
)
getGlobalSearchColumn
=
lazyMethod
(
getGlobalSearchColumn
)
# backwards compatability
# backwards compatability
def
getGlobalSearchColumnScript
(
self
):
def
getGlobalSearchColumnScript
(
self
):
warn
(
"getGlobalSearchColumnScript() is deprecated. Do not use it!"
,
\
warn
(
"getGlobalSearchColumnScript() is deprecated. Do not use it!"
,
\
...
@@ -993,14 +947,15 @@ class ListBoxRenderer:
...
@@ -993,14 +947,15 @@ class ListBoxRenderer:
getFullTextSearchKey
=
getGlobalSearchColumn
getFullTextSearchKey
=
getGlobalSearchColumn
getFullTextSearchKeyScript
=
getGlobalSearchColumnScript
getFullTextSearchKeyScript
=
getGlobalSearchColumnScript
@
lazyMethod
def
getPageNavigationTemplate
(
self
):
def
getPageNavigationTemplate
(
self
):
"""Return the list box page navigation template."""
"""Return the list box page navigation template."""
return
self
.
field
.
get_value
(
'page_navigation_template'
)
return
self
.
field
.
get_value
(
'page_navigation_template'
)
getPageNavigationTemplate
=
lazyMethod
(
getPageNavigationTemplate
)
# backwards compatability
# backwards compatability
getPageNavigationMode
=
getPageNavigationTemplate
getPageNavigationMode
=
getPageNavigationTemplate
@
lazyMethod
def
getSearchColumnIdSet
(
self
):
def
getSearchColumnIdSet
(
self
):
"""Return the set of the ids of the search columns. Fall back to the catalog schema, if not defined.
"""Return the set of the ids of the search columns. Fall back to the catalog schema, if not defined.
"""
"""
...
@@ -1010,8 +965,7 @@ class ListBoxRenderer:
...
@@ -1010,8 +965,7 @@ class ListBoxRenderer:
isValidColumn
=
self
.
getCatalogTool
().
getSQLCatalog
().
isValidColumn
isValidColumn
=
self
.
getCatalogTool
().
getSQLCatalog
().
isValidColumn
return
{
id
for
id
,
title
in
self
.
getAllColumnList
()
if
isValidColumn
(
id
)}
return
{
id
for
id
,
title
in
self
.
getAllColumnList
()
if
isValidColumn
(
id
)}
getSearchColumnIdSet
=
lazyMethod
(
getSearchColumnIdSet
)
@
lazyMethod
def
getSortColumnIdSet
(
self
):
def
getSortColumnIdSet
(
self
):
"""Return the set of the ids of the sort columns. Fall back to search column ids, if not defined.
"""Return the set of the ids of the sort columns. Fall back to search column ids, if not defined.
"""
"""
...
@@ -1020,16 +974,14 @@ class ListBoxRenderer:
...
@@ -1020,16 +974,14 @@ class ListBoxRenderer:
return
{
c
[
0
]
for
c
in
sort_columns
}
return
{
c
[
0
]
for
c
in
sort_columns
}
return
self
.
getSearchColumnIdSet
()
return
self
.
getSearchColumnIdSet
()
getSortColumnIdSet
=
lazyMethod
(
getSortColumnIdSet
)
@
lazyMethod
def
getEditableColumnIdSet
(
self
):
def
getEditableColumnIdSet
(
self
):
"""Return the set of the ids of the editable columns.
"""Return the set of the ids of the editable columns.
"""
"""
editable_columns
=
self
.
field
.
get_value
(
'editable_columns'
)
editable_columns
=
self
.
field
.
get_value
(
'editable_columns'
)
return
{
c
[
0
]
for
c
in
editable_columns
}
return
{
c
[
0
]
for
c
in
editable_columns
}
getEditableColumnIdSet
=
lazyMethod
(
getEditableColumnIdSet
)
@
lazyMethod
def
getListActionUrl
(
self
):
def
getListActionUrl
(
self
):
"""Return the URL of the list action.
"""Return the URL of the list action.
"""
"""
...
@@ -1048,11 +1000,10 @@ class ListBoxRenderer:
...
@@ -1048,11 +1000,10 @@ class ListBoxRenderer:
list_action_part_list
.
append
(
'&ignore_layout:int=1'
)
list_action_part_list
.
append
(
'&ignore_layout:int=1'
)
return
''
.
join
(
list_action_part_list
)
return
''
.
join
(
list_action_part_list
)
getListActionUrl
=
lazyMethod
(
getListActionUrl
)
# Whether the selection object is initialized.
# Whether the selection object is initialized.
is_selection_initialized
=
False
is_selection_initialized
=
False
@
lazyMethod
def
getSelection
(
self
):
def
getSelection
(
self
):
"""FIXME: Tweak a selection and return the selection object.
"""FIXME: Tweak a selection and return the selection object.
This code depends on the implementation of Selection too much.
This code depends on the implementation of Selection too much.
...
@@ -1100,22 +1051,18 @@ class ListBoxRenderer:
...
@@ -1100,22 +1051,18 @@ class ListBoxRenderer:
return
selection
return
selection
getSelection
=
lazyMethod
(
getSelection
)
@
lazyMethod
def
getCheckedUidList
(
self
):
def
getCheckedUidList
(
self
):
"""Return the list of checked uids.
"""Return the list of checked uids.
"""
"""
return
self
.
getSelection
().
getCheckedUids
()
return
self
.
getSelection
().
getCheckedUids
()
getCheckedUidList
=
lazyMethod
(
getCheckedUidList
)
@
lazyMethod
def
getCheckedUidSet
(
self
):
def
getCheckedUidSet
(
self
):
"""Return the set of checked uids.
"""Return the set of checked uids.
"""
"""
return
set
(
self
.
getCheckedUidList
())
return
set
(
self
.
getCheckedUidList
())
getCheckedUidSet
=
lazyMethod
(
getCheckedUidSet
)
def
setDisplayedColumnIdList
(
self
,
displayed_column_id_list
):
def
setDisplayedColumnIdList
(
self
,
displayed_column_id_list
):
"""Set the column to be displayed.
"""Set the column to be displayed.
Impact the result of getSelectedColumnList.
Impact the result of getSelectedColumnList.
...
@@ -1137,6 +1084,7 @@ class ListBoxRenderer:
...
@@ -1137,6 +1084,7 @@ class ListBoxRenderer:
return
request
.
get
(
'list_style'
,
\
return
request
.
get
(
'list_style'
,
\
selection
.
getParams
().
get
(
'list_style'
,
self
.
getDefaultDisplayStyle
()))
selection
.
getParams
().
get
(
'list_style'
,
self
.
getDefaultDisplayStyle
()))
@
lazyMethod
def
getSelectedColumnList
(
self
):
def
getSelectedColumnList
(
self
):
"""Return the list of selected columns.
"""Return the list of selected columns.
"""
"""
...
@@ -1168,8 +1116,7 @@ class ListBoxRenderer:
...
@@ -1168,8 +1116,7 @@ class ListBoxRenderer:
REQUEST
=
self
.
request
)
REQUEST
=
self
.
request
)
return
column_list
return
column_list
getSelectedColumnList
=
lazyMethod
(
getSelectedColumnList
)
@
lazyMethod
def
getColumnAliasList
(
self
):
def
getColumnAliasList
(
self
):
"""Return the list of column aliases for SQL, because SQL does not allow a symbol to contain dots.
"""Return the list of column aliases for SQL, because SQL does not allow a symbol to contain dots.
"""
"""
...
@@ -1178,8 +1125,7 @@ class ListBoxRenderer:
...
@@ -1178,8 +1125,7 @@ class ListBoxRenderer:
alias_list
.
append
(
sql
.
replace
(
'.'
,
'_'
))
alias_list
.
append
(
sql
.
replace
(
'.'
,
'_'
))
return
alias_list
return
alias_list
getColumnAliasList
=
lazyMethod
(
getColumnAliasList
)
@
lazyMethod
def
getParamDict
(
self
):
def
getParamDict
(
self
):
"""Return a dictionary of parameters.
"""Return a dictionary of parameters.
"""
"""
...
@@ -1291,8 +1237,6 @@ class ListBoxRenderer:
...
@@ -1291,8 +1237,6 @@ class ListBoxRenderer:
self
.
getSelection
().
edit
(
params
=
params
)
self
.
getSelection
().
edit
(
params
=
params
)
return
params
return
params
getParamDict
=
lazyMethod
(
getParamDict
)
def
getEditableField
(
self
,
alias
):
def
getEditableField
(
self
,
alias
):
"""Get an editable field for column, using column alias.
"""Get an editable field for column, using column alias.
Return None if a field for this column does not exist.
Return None if a field for this column does not exist.
...
@@ -1311,6 +1255,7 @@ class ListBoxRenderer:
...
@@ -1311,6 +1255,7 @@ class ListBoxRenderer:
# by the template field listbox id or by the proxy field listbox id.
# by the template field listbox id or by the proxy field listbox id.
field
=
aq_inner
(
field
.
getTemplateField
())
field
=
aq_inner
(
field
.
getTemplateField
())
@
lazyMethod
def
getListMethod
(
self
):
def
getListMethod
(
self
):
"""Return the list method object.
"""Return the list method object.
"""
"""
...
@@ -1327,8 +1272,7 @@ class ListBoxRenderer:
...
@@ -1327,8 +1272,7 @@ class ListBoxRenderer:
return
list_method
return
list_method
getListMethod
=
lazyMethod
(
getListMethod
)
@
lazyMethod
def
getCountMethod
(
self
):
def
getCountMethod
(
self
):
"""Return the count method object.
"""Return the count method object.
"""
"""
...
@@ -1348,8 +1292,7 @@ class ListBoxRenderer:
...
@@ -1348,8 +1292,7 @@ class ListBoxRenderer:
return
count_method
return
count_method
getCountMethod
=
lazyMethod
(
getCountMethod
)
@
lazyMethod
def
getStatMethod
(
self
):
def
getStatMethod
(
self
):
"""Return the stat method object.
"""Return the stat method object.
"""
"""
...
@@ -1369,8 +1312,7 @@ class ListBoxRenderer:
...
@@ -1369,8 +1312,7 @@ class ListBoxRenderer:
return
stat_method
return
stat_method
getStatMethod
=
lazyMethod
(
getStatMethod
)
@
lazyMethod
def
getRowCSSMethod
(
self
):
def
getRowCSSMethod
(
self
):
"""Return the row css method object.
"""Return the row css method object.
"""
"""
...
@@ -1380,8 +1322,7 @@ class ListBoxRenderer:
...
@@ -1380,8 +1322,7 @@ class ListBoxRenderer:
row_css_method
=
getattr
(
self
.
getContext
(),
row_css_method_name
,
None
)
row_css_method
=
getattr
(
self
.
getContext
(),
row_css_method_name
,
None
)
return
row_css_method
return
row_css_method
getRowCSSMethod
=
lazyMethod
(
getRowCSSMethod
)
@
lazyMethod
def
getDomainSelection
(
self
):
def
getDomainSelection
(
self
):
"""Return a DomainSelection object wrapped with the context.
"""Return a DomainSelection object wrapped with the context.
"""
"""
...
@@ -1419,8 +1360,7 @@ class ListBoxRenderer:
...
@@ -1419,8 +1360,7 @@ class ListBoxRenderer:
return
DomainSelection
(
domain_dict
=
root_dict
).
__of__
(
self
.
getContext
())
return
DomainSelection
(
domain_dict
=
root_dict
).
__of__
(
self
.
getContext
())
getDomainSelection
=
lazyMethod
(
getDomainSelection
)
@
lazyMethod
def
getStatSelectExpression
(
self
):
def
getStatSelectExpression
(
self
):
"""Return a string which expresses the information retrieved by SELECT for
"""Return a string which expresses the information retrieved by SELECT for
the statistics.
the statistics.
...
@@ -1448,8 +1388,6 @@ class ListBoxRenderer:
...
@@ -1448,8 +1388,6 @@ class ListBoxRenderer:
return
', '
.
join
(
select_expression_list
)
return
', '
.
join
(
select_expression_list
)
getStatSelectExpression
=
lazyMethod
(
getStatSelectExpression
)
def
makeReportTreeList
(
self
,
root_dict
=
None
,
report_path
=
None
,
base_category
=
None
,
depth
=
0
,
def
makeReportTreeList
(
self
,
root_dict
=
None
,
report_path
=
None
,
base_category
=
None
,
depth
=
0
,
unfolded_list
=
(),
is_report_opened
=
True
,
sort_on
=
((
'id'
,
'ASC'
),),
unfolded_list
=
(),
is_report_opened
=
True
,
sort_on
=
((
'id'
,
'ASC'
),),
checked_permission
=
'View'
):
checked_permission
=
'View'
):
...
@@ -1584,6 +1522,7 @@ class ListBoxRenderer:
...
@@ -1584,6 +1522,7 @@ class ListBoxRenderer:
"""
"""
raise
NotImplementedError
,
"getLineStart must be overridden in a subclass"
raise
NotImplementedError
,
"getLineStart must be overridden in a subclass"
@
lazyMethod
def
getSelectedDomainPath
(
self
):
def
getSelectedDomainPath
(
self
):
"""Return a selected domain path.
"""Return a selected domain path.
"""
"""
...
@@ -1596,8 +1535,7 @@ class ListBoxRenderer:
...
@@ -1596,8 +1535,7 @@ class ListBoxRenderer:
domain_path
=
None
domain_path
=
None
return
domain_path
return
domain_path
getSelectedDomainPath
=
lazyMethod
(
getSelectedDomainPath
)
@
lazyMethod
def
getSelectedReportPath
(
self
):
def
getSelectedReportPath
(
self
):
"""Return a selected report path.
"""Return a selected report path.
"""
"""
...
@@ -1613,8 +1551,6 @@ class ListBoxRenderer:
...
@@ -1613,8 +1551,6 @@ class ListBoxRenderer:
return
selection
.
getReportPath
(
default
=
default_selection_report_path
)
return
selection
.
getReportPath
(
default
=
default_selection_report_path
)
getSelectedReportPath
=
lazyMethod
(
getSelectedReportPath
)
def
getLabelValueList
(
self
):
def
getLabelValueList
(
self
):
"""Return a list of values, where each value is a tuple consisting of an property id, a title and a string which
"""Return a list of values, where each value is a tuple consisting of an property id, a title and a string which
describes the current sorting order, one of ascending, descending and None. If a value is not sortable, the id is
describes the current sorting order, one of ascending, descending and None. If a value is not sortable, the id is
...
@@ -2130,6 +2066,7 @@ class ListBoxRendererLine:
...
@@ -2130,6 +2066,7 @@ class ListBoxRendererLine:
"""
"""
return
self
.
obj
return
self
.
obj
@
lazyMethod
def
getObject
(
self
):
def
getObject
(
self
):
"""Return a real object.
"""Return a real object.
"""
"""
...
@@ -2138,22 +2075,18 @@ class ListBoxRendererLine:
...
@@ -2138,22 +2075,18 @@ class ListBoxRendererLine:
except
AttributeError
:
except
AttributeError
:
return
self
.
obj
return
self
.
obj
getObject
=
lazyMethod
(
getObject
)
@
lazyMethod
def
getUid
(
self
):
def
getUid
(
self
):
"""Return the uid of the object.
"""Return the uid of the object.
"""
"""
return
getattr
(
aq_base
(
self
.
obj
),
'uid'
,
None
)
return
getattr
(
aq_base
(
self
.
obj
),
'uid'
,
None
)
getUid
=
lazyMethod
(
getUid
)
@
lazyMethod
def
getUrl
(
self
):
def
getUrl
(
self
):
"""Return the absolute URL path of the object
"""Return the absolute URL path of the object
"""
"""
return
self
.
getBrain
().
getUrl
()
return
self
.
getBrain
().
getUrl
()
getUrl
=
lazyMethod
(
getUrl
)
def
isSummary
(
self
):
def
isSummary
(
self
):
"""Return whether this line is a summary or not.
"""Return whether this line is a summary or not.
"""
"""
...
@@ -2562,20 +2495,18 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
...
@@ -2562,20 +2495,18 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
"""
"""
return
ListBoxHTMLRendererLine
return
ListBoxHTMLRendererLine
@
lazyMethod
def
getLineStart
(
self
):
def
getLineStart
(
self
):
"""Return a requested start number.
"""Return a requested start number.
"""
"""
return
int
(
self
.
getParamDict
().
get
(
'list_start'
,
0
))
return
int
(
self
.
getParamDict
().
get
(
'list_start'
,
0
))
getLineStart
=
lazyMethod
(
getLineStart
)
@
lazyMethod
def
getMaxLineNumber
(
self
):
def
getMaxLineNumber
(
self
):
"""Return the maximum number of lines shown in a page.
"""Return the maximum number of lines shown in a page.
"""
"""
return
self
.
field
.
get_value
(
'lines'
)
return
self
.
field
.
get_value
(
'lines'
)
getMaxLineNumber
=
lazyMethod
(
getMaxLineNumber
)
def
getMD5Checksum
(
self
):
def
getMD5Checksum
(
self
):
"""Generate a MD5 checksum against checked uids. This is used to confirm
"""Generate a MD5 checksum against checked uids. This is used to confirm
that selected values do not change between a display of a dialog and an execution.
that selected values do not change between a display of a dialog and an execution.
...
...
product/ERP5Form/PlanningBox.py
View file @
d4fc3821
...
@@ -1222,20 +1222,19 @@ class BasicStructure:
...
@@ -1222,20 +1222,19 @@ class BasicStructure:
return
object_list
return
object_list
@
lazyMethod
def
getPortalObject
(
self
):
def
getPortalObject
(
self
):
"""Return the portal object.
"""Return the portal object.
"""
"""
return
self
.
context
.
getPortalObject
()
return
self
.
context
.
getPortalObject
()
getPortalObject
=
lazyMethod
(
getPortalObject
)
@
lazyMethod
def
getSelectionTool
(
self
):
def
getSelectionTool
(
self
):
"""Return the Selection Tool.
"""Return the Selection Tool.
"""
"""
return
self
.
getPortalObject
().
portal_selections
return
self
.
getPortalObject
().
portal_selections
getSelectionTool
=
lazyMethod
(
getSelectionTool
)
@
lazyMethod
def
getPortalTypeList
(
self
):
def
getPortalTypeList
(
self
):
"""
"""
Return the list of portal types for filtering. Return None when empty.
Return the list of portal types for filtering. Return None when empty.
...
@@ -1243,8 +1242,6 @@ class BasicStructure:
...
@@ -1243,8 +1242,6 @@ class BasicStructure:
portal_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'portal_types'
)]
portal_types
=
[
c
[
0
]
for
c
in
self
.
field
.
get_value
(
'portal_types'
)]
return
portal_types
or
None
return
portal_types
or
None
getPortalTypeList
=
lazyMethod
(
getPortalTypeList
)
def
getReportGroupList
(
self
,
report_tree_list
=
[],
\
def
getReportGroupList
(
self
,
report_tree_list
=
[],
\
sec_layer_method_name
=
None
,
show_stat
=
0
):
sec_layer_method_name
=
None
,
show_stat
=
0
):
"""
"""
...
...
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