Commit 02d9da29 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Initialize domain_list and report_list to an empty tuple instead of a tuple of an empty tuple.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1372 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4fedae1e
...@@ -81,19 +81,19 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -81,19 +81,19 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
- report_list -- list of open report nodes - report_list -- list of open report nodes
XXX this will have to be updated for cartesion product XXX this will have to be updated for cartesion product
- domain -- a DomainSelection instance - domain -- a DomainSelection instance
- report -- a DomainSelection instance - report -- a DomainSelection instance
- flat_list_mode -- - flat_list_mode --
- domain_tree_mode -- - domain_tree_mode --
- report_tree_mode -- - report_tree_mode --
""" """
method_path=None method_path=None
params={} params={}
sort_on=() sort_on=()
...@@ -111,13 +111,13 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -111,13 +111,13 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
report_list = ((),) report_list = ((),)
domain=None domain=None
report=None report=None
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectPublic() security.declareObjectPublic()
security.declarePublic('domain') security.declarePublic('domain')
security.declarePublic('report') security.declarePublic('report')
def __init__(self, method_path=None, params=None, sort_on=None, default_sort_on=None, def __init__(self, method_path=None, params=None, sort_on=None, default_sort_on=None,
uids=None, invert_mode=0, list_url='', domain=None, report=None, uids=None, invert_mode=0, list_url='', domain=None, report=None,
columns=None, checked_uids=None, name=None, index=None): columns=None, checked_uids=None, name=None, index=None):
...@@ -142,9 +142,9 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -142,9 +142,9 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
self.name = name self.name = name
self.index = index self.index = index
self.domain_path = ('portal_categories',) self.domain_path = ('portal_categories',)
self.domain_list = ((),) self.domain_list = ()
self.report_path = ('portal_categories',) self.report_path = ('portal_categories',)
self.report_list = ((),) self.report_list = ()
self.domain = None self.domain = None
self.report = None self.report = None
...@@ -192,7 +192,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -192,7 +192,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
if callable(method): if callable(method):
#LOG('Selection', 0, "self.params = %s" % repr(self.params)) #LOG('Selection', 0, "self.params = %s" % repr(self.params))
if self.domain is not None and self.report is not None: if self.domain is not None and self.report is not None:
result = method(selection_domain = self.domain, result = method(selection_domain = self.domain,
selection_report = self.report, selection=self, **self.params) selection_report = self.report, selection=self, **self.params)
elif self.domain is not None: elif self.domain is not None:
result = method(selection_domain = self.domain, selection=self, **self.params) result = method(selection_domain = self.domain, selection=self, **self.params)
...@@ -288,33 +288,33 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -288,33 +288,33 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
return self.report_list return self.report_list
InitializeClass(Selection) InitializeClass(Selection)
allow_class(Selection) allow_class(Selection)
class DomainSelection(Acquisition.Implicit, Traversable, Persistent): class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
""" """
A class to store a selection of domains which defines a report A class to store a selection of domains which defines a report
section. section.
Example 1: (hand coded) Example 1: (hand coded)
<dtml-if selection.domain.eip> <dtml-if selection.domain.eip>
<dtml-in "selection.domain.eip.getCategoryChildUidList()">uid = <dtml-sqlvar sequence-item type="int"></dtml-in> <dtml-in "selection.domain.eip.getCategoryChildUidList()">uid = <dtml-sqlvar sequence-item type="int"></dtml-in>
</dtml-if> </dtml-if>
Example 2: (auto generated) Example 2: (auto generated)
<dtml-var "selection.domain.asSqlExpression(table_map=(('eip','movement'), ('group', 'catalog')))"> <dtml-var "selection.domain.asSqlExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
<dtml-var "selection.domain.asSqlJoinExpression(table_map=(('eip','movement'), ('group', 'catalog')))"> <dtml-var "selection.domain.asSqlJoinExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
Example 3: (mixed) Example 3: (mixed)
<dtml-var "selection.domain.eip.asSqlExpresion(table="resource_category")"> <dtml-var "selection.domain.eip.asSqlExpresion(table="resource_category")">
""" """
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectPublic() security.declareObjectPublic()
def __init__(self, domain_dict = None): def __init__(self, domain_dict = None):
if domain_dict is not None: if domain_dict is not None:
self.domain_dict = domain_dict self.domain_dict = domain_dict
...@@ -323,11 +323,11 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -323,11 +323,11 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
setattr(self, k, v) setattr(self, k, v)
def __len__(self): def __len__(self):
return len(self.domain_dict) return len(self.domain_dict)
security.declarePublic('getCategoryList') security.declarePublic('getCategoryList')
def getCategoryList(self): def getCategoryList(self):
return return
security.declarePublic('asSqlExpression') security.declarePublic('asSqlExpression')
def asSqlExpression(self, table_map=None, domain_id=None, exclude_domain_id=None, strict_membership=0): def asSqlExpression(self, table_map=None, domain_id=None, exclude_domain_id=None, strict_membership=0):
...@@ -335,19 +335,19 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -335,19 +335,19 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
for k, d in self.domain_dict.items(): for k, d in self.domain_dict.items():
if k is not None and getattr(aq_base(d), 'isCategory', 0): if k is not None and getattr(aq_base(d), 'isCategory', 0):
# This is a category, we must join # This is a category, we must join
join_expression.append('catalog.uid = %s_category.uid' % k) join_expression.append('catalog.uid = %s_category.uid' % k)
join_expression.append(d.asSqlExpression(table = '%s_category' % k, strict_membership=strict_membership)) join_expression.append(d.asSqlExpression(table = '%s_category' % k, strict_membership=strict_membership))
result = "( %s )" % ' AND '.join(join_expression) result = "( %s )" % ' AND '.join(join_expression)
LOG('asSqlExpression', 0, str(result)) LOG('asSqlExpression', 0, str(result))
return result return result
security.declarePublic('asSqlJoinExpression') security.declarePublic('asSqlJoinExpression')
def asSqlJoinExpression(self, domain_id=None, exclude_domain_id=None): def asSqlJoinExpression(self, domain_id=None, exclude_domain_id=None):
join_expression = [] join_expression = []
for k, d in self.domain_dict.items(): for k, d in self.domain_dict.items():
if k is not None and getattr(aq_base(d), 'isCategory', 0): if k is not None and getattr(aq_base(d), 'isCategory', 0):
# This is a category, we must join # This is a category, we must join
join_expression.append('category AS %s_category' % k) join_expression.append('category AS %s_category' % k)
result = "%s" % ' , '.join(join_expression) result = "%s" % ' , '.join(join_expression)
LOG('asSqlJoinExpression', 0, str(result)) LOG('asSqlJoinExpression', 0, str(result))
return result return result
...@@ -362,8 +362,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -362,8 +362,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
security.declarePublic('updateDomain') security.declarePublic('updateDomain')
def updateDomain(self, domain): def updateDomain(self, domain):
pass pass
InitializeClass(DomainSelection) InitializeClass(DomainSelection)
allow_class(DomainSelection) allow_class(DomainSelection)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment