[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/reports/src GRDataMapper.py GRLayout.py
From: |
Jason Cater |
Subject: |
gnue/reports/src GRDataMapper.py GRLayout.py |
Date: |
Wed, 10 Apr 2002 15:58:35 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/04/10 15:58:35
Modified files:
reports/src : GRDataMapper.py GRLayout.py
Log message:
subtotals/summaries finally working in reports
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRDataMapper.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRLayout.py.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
Patches:
Index: gnue/reports/src/GRDataMapper.py
diff -c gnue/reports/src/GRDataMapper.py:1.13
gnue/reports/src/GRDataMapper.py:1.14
*** gnue/reports/src/GRDataMapper.py:1.13 Tue Apr 9 21:40:15 2002
--- gnue/reports/src/GRDataMapper.py Wed Apr 10 15:58:35 2002
***************
*** 56,62 ****
self._fieldsOld = {}
self.toplevel = 0 # Is this the first section to use a datasource
self.initial = 1 # Are we in an initial run in which we have no
history?
! self.changed = 0 # Did this section change w/the last
self.grouping = 0 # Is this a "grouping" section?
self._lastSection = None
self.datasource = None
--- 56,62 ----
self._fieldsOld = {}
self.toplevel = 0 # Is this the first section to use a datasource
self.initial = 1 # Are we in an initial run in which we have no
history?
! ## self.changed = 0 # Did this section change w/the last
self.grouping = 0 # Is this a "grouping" section?
self._lastSection = None
self.datasource = None
***************
*** 135,199 ****
def addChildSection(self, mapper):
self.sections.append(mapper)
! #
! # Set initial states
! #
! def resetState(self):
! self.initial = 1
! self.changed = 0
#
! #
#
def _clearSummaries(self):
- print "clearing summaries for %s" % self.name
- print self.summaries
for field in self.summaries.keys():
for function in self.summaries[field].keys():
self.summaries[field][function] = None
! #
! # Save current values before new query occurs
! #
! def _loadFields(self, recordset, reset=0):
! if reset: self._clearSummaries()
! self.changed = 0
! for field in self.fields.keys():
! val = recordset.getField(field)
! GDebug.printMesg(10, 'self=%s,%s'%(self,self.name))
! if ( self.initial or \
! not self.grouping or \
! self.fields[field] != val ):
! self.changed = 1
! GDebug.printMesg(10, "Field %s changed after nextRecord
(%s,%s,%s,%s)" % (field, self.initial, self.grouping, self.fields[field], val))
! self.fields[field] = val
!
## handler = self
## while handler:
## handler._handleSummary(field, val)
## handler = handler.parent
!
! GDebug.printMesg(10, "After _loadFields, changed=%s" % self.changed)
! self.initial = 0
#
! # Initiate the calculation of summaries
! #
! def _handleSummary(self):
! # Now, calc all summaries
! for field in self.summaries.keys():
! for function in _summFunctions:
! if self.summaries[field].has_key(function):
! try:
! self._summMap[function](field, self.fields[field])
! except KeyError:
! pass
!
! #
! # Will the next recordset cause
#
def _precheckNextFields(self, recordset):
if not recordset:
--- 135,180 ----
def addChildSection(self, mapper):
self.sections.append(mapper)
! ## #
! ## # Set initial states
! ## #
! ## def resetState(self):
! ## self.initial = 1
! ## self.changed = 0
#
! # Zero out the summary data
#
def _clearSummaries(self):
for field in self.summaries.keys():
for function in self.summaries[field].keys():
self.summaries[field][function] = None
! ## #
! ## # Save current values before new query occurs
! ## #
! ## def _loadFields(self, recordset):
! ## GDebug.printMesg(10, 'self=%s,%s'%(self,self.name))
! ## if ( self.initial or \
! ## not self.grouping or \
! ## self.fields[field] != val ):
! ## self.changed = 1
! ## GDebug.printMesg(10, "Field %s changed after nextRecord
(%s,%s,%s,%s)" % (field, self.initial, self.grouping, self.fields[field], val))
! ## self.fields[field] = val
! ##
## handler = self
## while handler:
## handler._handleSummary(field, val)
## handler = handler.parent
! ##
! ## GDebug.printMesg(10, "After _loadFields, changed=%s" % self.changed)
! ## self.initial = 0
#
! # Will the next recordset cause our section to change?
#
def _precheckNextFields(self, recordset):
if not recordset:
***************
*** 206,215 ****
--- 187,211 ----
self.fields[field] != val ):
changed = 1
GDebug.printMesg(10, "Field %s changed after nextRecord
(%s,%s,%s,%s)" % (field, self.initial, self.grouping, self.fields[field], val))
+ break
GDebug.printMesg(10, "After _precheckNextFields, changed=%s" % changed)
return changed
+ ## #
+ # Initiate the calculation of summaries
+ #
+ def _handleSummary(self):
+ # Now, calc all summaries
+ for field in self.summaries.keys():
+ for function in _summFunctions:
+ if self.summaries[field].has_key(function):
+ try:
+ self._summMap[function](field, self.fields[field])
+ except KeyError:
+ pass
+
+
# Used in GRSources.__connectMasterDetail to link detail datasource to
# master source. Called by GDataObjects.ResultSet when master changed
# This will actually be over-written by GRDataMapper but at the time
***************
*** 221,227 ****
##
! ##
##
# Summary function: "count"
--- 217,223 ----
##
! ## Summary calculation functions
##
# Summary function: "count"
***************
*** 335,341 ****
return None
for s in self.sourceMap[source]:
! s.resetState()
controlSection = self.sourceMap[source][0]
--- 331,337 ----
return None
for s in self.sourceMap[source]:
! s.initial = 1
controlSection = self.sourceMap[source][0]
***************
*** 380,404 ****
firstSection = None
nextSection = None
for s in self.sourceMap[source]:
! s._loadFields(recordset)
# What is the current section?
! if firstSection == None and s.changed:
GDebug.printMesg(10, "After next record, first changed section is
%s" % s.name)
firstSection = s.name
# What will the next section be?
if (nextSection is None and \
controlSection.__nextRecord and \
s._precheckNextFields(controlSection.__nextRecord)):
nextSection = s.name
! if nextSection and nextSection != s._lastSection:
! s._clearSummaries()
! s._handleSummary()
!
! s._lastSection = firstSection
return (firstSection, nextSection)
--- 376,415 ----
firstSection = None
nextSection = None
+ # Apply the recordset to each section we control,
+ # determining the first section to change.
for s in self.sourceMap[source]:
!
! # Reset running summary counts if necessary...
! if firstSection and firstSection != controlSection._lastSection:
! s._clearSummaries()
!
! changed = s._precheckNextFields(recordset)
# What is the current section?
! if firstSection == None and changed:
GDebug.printMesg(10, "After next record, first changed section is
%s" % s.name)
firstSection = s.name
+ # Save the new field values in the data handler
+ for field in s.fields.keys():
+ s.fields[field] = recordset.getField(field)
+
+ # ... and save any new summary data
+ for field in s.summaries.keys():
+ for function in _summFunctions:
+ if s.summaries[field].has_key(function):
+ s._summMap[function](field, recordset.getField(field))
+
# What will the next section be?
if (nextSection is None and \
controlSection.__nextRecord and \
s._precheckNextFields(controlSection.__nextRecord)):
nextSection = s.name
!
! # Save this in case
! controlSection._lastSection = firstSection
return (firstSection, nextSection)
Index: gnue/reports/src/GRLayout.py
diff -c gnue/reports/src/GRLayout.py:1.26 gnue/reports/src/GRLayout.py:1.27
*** gnue/reports/src/GRLayout.py:1.26 Tue Apr 9 18:55:41 2002
--- gnue/reports/src/GRLayout.py Wed Apr 10 15:58:35 2002
***************
*** 225,231 ****
def processChildren(self, dest, mapper,
isfirst, islast, firstSection, nextSection):
! first = isfirst or isinstance(self, GRSection)
while 1:
for child in self._children:
--- 225,231 ----
def processChildren(self, dest, mapper,
isfirst, islast, firstSection, nextSection):
! first = isfirst or self._type == 'GRSection'
while 1:
for child in self._children:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/reports/src GRDataMapper.py GRLayout.py,
Jason Cater <=