[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r6905 - trunk/gnue-common/src/datasources
From: |
johannes |
Subject: |
[gnue] r6905 - trunk/gnue-common/src/datasources |
Date: |
Sun, 16 Jan 2005 04:05:46 -0600 (CST) |
Author: johannes
Date: 2005-01-16 04:05:45 -0600 (Sun, 16 Jan 2005)
New Revision: 6905
Modified:
trunk/gnue-common/src/datasources/GDataSource.py
Log:
Changed property-accessors for datasource's order_by. This way one can change
sort-order via trigger-code (dts.__properties__.order_by = ...)
Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py 2005-01-15 23:30:26 UTC
(rev 6904)
+++ trunk/gnue-common/src/datasources/GDataSource.py 2005-01-16 10:05:45 UTC
(rev 6905)
@@ -143,9 +143,9 @@
return self.sorting
def triggerSetOrderBy(self,value):
- self.sorting = value
+ self.sorting = self.__convertOrderBy (value)
if self._dataObject:
- self._dataObject.sorting = value
+ self._dataObject.sorting = self.sorting
def triggerGetCount(self):
if self._currentResultSet:
@@ -452,41 +452,55 @@
# otherwise let's investigate the order_by attribute given
elif hasattr (self, 'order_by'):
- self.sorting = []
+ self.sorting = self.__convertOrderBy (self.order_by)
+ delattr (self, 'order_by')
- # If it's a string or a unicode string, we transform it into a tuple
- # sequence, where all items are treated to be in 'ascending' order
- if isinstance (self.order_by, types.StringType) or \
- isinstance (self.order_by, types.UnicodeType):
- print o(u_("DEPRECIATION WARNING: use of 'order_by' attribute is " \
- "depreciated. Please use <sortorder> instead."))
- for field in string.split (self.order_by, ','):
- (item, desc) = (field, field [-5:].lower () == ' desc')
- if desc:
- item = item [:-5].strip ()
- self.sorting.append ((item, desc))
+ # ---------------------------------------------------------------------------
+ # convert an order_by rule into the new 'sorting' format
+ # ---------------------------------------------------------------------------
- # Well, order_by is already a sequence. So we've to make sure it's a
- # sequence of tuples with fieldname and direction.
- elif isinstance (self.order_by, types.ListType):
- for item in self.order_by:
- if isinstance (item, types.StringType) or \
- isinstance (item, types.UnicodeType):
- self.sorting.append ((item, False))
- else:
- self.sorting.append (item)
+ def __convertOrderBy (self, order_by):
+ """
+ This function transforms an order_by rule into a proper 'sorting' sequence,
+ made of tuples with fieldname and sort-direction.
- else:
- raise MarkupError, \
- u_("Invalid form of 'order_by' attribute. Please use <sorting> "
- "instead")
+ @param order_by: string, unicode-string, sequence with sort-order
+ @return: sequence of tuples (field, direction)
+ """
- delattr (self, 'order_by')
+ result = []
+ # If it's a string or a unicode string, we transform it into a tuple
+ # sequence, where all items are treated to be in 'ascending' order
+ if isinstance (order_by, types.StringType) or \
+ isinstance (order_by, types.UnicodeType):
+ print o(u_("DEPRECIATION WARNING: use of 'order_by' attribute is " \
+ "depreciated. Please use <sortorder> instead."))
+ for field in string.split (order_by, ','):
+ (item, desc) = (field, field [-5:].lower () == ' desc')
+ if desc:
+ item = item [:-5].strip ()
+ result.append ((item, desc))
+ # Well, order_by is already a sequence. So we've to make sure it's a
+ # sequence of tuples with fieldname and direction.
+ elif isinstance (order_by, types.ListType):
+ for item in order_by:
+ if isinstance (item, types.StringType) or \
+ isinstance (item, types.UnicodeType):
+ result.append ((item, False))
+ else:
+ result.append (item)
+ else:
+ raise MarkupError, u_("Unknown type/format of 'order-by' attribute")
+
+ return result
+
+
+
# Find a specific record in the resultset by field values
def findRecord(self, fieldValues):
self._currentResultSet.findRecord(fieldValues)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r6905 - trunk/gnue-common/src/datasources,
johannes <=