Commit 076ea409 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* add getDomainTreeMode() and getReportTreeMode().

* remove needless imports.
* some cosmetic changes.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18208 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24ccf35c
...@@ -27,13 +27,11 @@ ...@@ -27,13 +27,11 @@
############################################################################## ##############################################################################
from Globals import InitializeClass, Persistent, Acquisition from Globals import InitializeClass, Persistent, Acquisition
from Acquisition import aq_base, aq_inner, aq_parent, aq_self from Acquisition import aq_base
from OFS.SimpleItem import SimpleItem
from OFS.Traversable import Traversable from OFS.Traversable import Traversable
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions as ERP5Permissions from Products.ERP5Type import Permissions as ERP5Permissions
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
import string
# Put a try in front XXX # Put a try in front XXX
from Products.CMFCategory.Category import Category from Products.CMFCategory.Category import Category
...@@ -123,7 +121,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -123,7 +121,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
def getId(self): def getId(self):
return self.name return self.name
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):
...@@ -321,12 +319,12 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -321,12 +319,12 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
try: try:
current_zoom=self.params['zoom'] current_zoom=self.params['zoom']
if current_zoom != None: if current_zoom != None:
return current_zoom return current_zoom
else: else:
return 1 return 1
except KeyError: except KeyError:
return 1 return 1
security.declarePublic('getReportList') security.declarePublic('getReportList')
def getReportList(self): def getReportList(self):
if self.report_list is None: if self.report_list is None:
...@@ -342,19 +340,26 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): ...@@ -342,19 +340,26 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
security.declarePublic('isInvertMode') security.declarePublic('isInvertMode')
def isInvertMode(self): def isInvertMode(self):
return self.invert_mode return self.invert_mode
security.declarePublic('getInvertModeUidList') security.declarePublic('getInvertModeUidList')
def getInvertModeUidList(self): def getInvertModeUidList(self):
return self.uids return self.uids
security.declarePublic('getDomainTreeMode')
def getDomainTreeMode(self):
return getattr(self, 'domain_tree_mode', 0)
security.declarePublic('getReportTreeMode')
def getReportTreeMode(self):
return getattr(self, 'report_tree_mode', 0)
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. There are different ways to use DomainSelection in section. There are different ways to use DomainSelection in
SQL methods. As a general principle, SQL methods are passed SQL methods. As a general principle, SQL methods are passed
DomainSelection instances as a parameter. DomainSelection instances as a parameter.
...@@ -370,7 +375,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -370,7 +375,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
</dtml-if> </dtml-if>
Example 2: (auto generated) Example 2: (auto generated)
The domain object is in charge of generating automatically all The domain object is in charge of generating automatically all
SQL expressions to feed the SQL method (or the catalog). This SQL expressions to feed the SQL method (or the catalog). This
is the recommended approach. is the recommended approach.
...@@ -434,9 +439,9 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -434,9 +439,9 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
return obj return obj
security.declarePublic('asSQLExpression') security.declarePublic('asSQLExpression')
def asSQLExpression(self, table_map=None, domain_id=None, def asSQLExpression(self, table_map=None, domain_id=None,
exclude_domain_id=None, strict_membership=0, exclude_domain_id=None, strict_membership=0,
join_table="catalog", join_column="uid", join_table="catalog", join_column="uid",
base_category=None, category_table_alias='category'): base_category=None, category_table_alias='category'):
select_expression = [] select_expression = []
portal = self.getPortalObject() portal = self.getPortalObject()
...@@ -456,7 +461,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -456,7 +461,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
else: else:
# This is a category, we must join # This is a category, we must join
select_expression.append('%s.%s = %s_%s.uid' % \ select_expression.append('%s.%s = %s_%s.uid' % \
(join_table, join_column, (join_table, join_column,
k, category_table_alias)) k, category_table_alias))
select_expression.append( select_expression.append(
d.asSQLExpression(table='%s_%s' % (k, category_table_alias), d.asSQLExpression(table='%s_%s' % (k, category_table_alias),
...@@ -474,9 +479,9 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -474,9 +479,9 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
# Compatibility SQL Sql # Compatibility SQL Sql
security.declarePublic('asSqlExpression') security.declarePublic('asSqlExpression')
asSqlExpression = asSQLExpression asSqlExpression = asSQLExpression
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,
category_table_alias='category'): category_table_alias='category'):
join_expression = [] join_expression = []
#LOG('DomainSelection', 0, 'domain_id = %r, exclude_domain_id = %r, self.domain_dict = %r' % (domain_id, exclude_domain_id, self.domain_dict)) #LOG('DomainSelection', 0, 'domain_id = %r, exclude_domain_id = %r, self.domain_dict = %r' % (domain_id, exclude_domain_id, self.domain_dict))
......
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