61 |
self.datasource = None |
self.datasource = None |
62 |
self._resultsets = [] |
self._resultsets = [] |
63 |
|
|
64 |
|
self._clearOnNextSet = 0 |
65 |
|
|
66 |
self._summMap = {'sum': self._summ_sum, |
self._summMap = {'sum': self._summ_sum, |
67 |
'count': self._summ_count, |
'count': self._summ_count, |
68 |
'avg': self._summ_avg, |
'avg': self._summ_avg, |
140 |
# |
# |
141 |
# Zero out the summary data |
# Zero out the summary data |
142 |
# |
# |
143 |
def _clearSummaries(self): |
def clearSummaries(self): |
144 |
for field in self.summaries.keys(): |
for field in self.summaries.keys(): |
145 |
for function in self.summaries[field].keys(): |
for function in self.summaries[field].keys(): |
146 |
self.summaries[field][function] = None |
self.summaries[field][function] = None |
147 |
|
self._clearOnNextSet = 0 |
148 |
|
|
149 |
|
|
150 |
# |
# |
169 |
# |
# |
170 |
# Initiate the calculation of summaries |
# Initiate the calculation of summaries |
171 |
# |
# |
172 |
|
# TODO: I **SERIOUSLY** don't think this is being used any longer |
173 |
def _handleSummary(self): |
def _handleSummary(self): |
174 |
|
if self._clearOnNextSet: |
175 |
|
self.clearSummaries() |
176 |
# Now, calc all summaries |
# Now, calc all summaries |
177 |
for field in self.summaries.keys(): |
for field in self.summaries.keys(): |
178 |
for function in _summFunctions: |
for function in _summFunctions: |
189 |
# the master-detail must be linked, the GRDataMapper will not have been |
# the master-detail must be linked, the GRDataMapper will not have been |
190 |
# created yet. [Yes, it's fugly] |
# created yet. [Yes, it's fugly] |
191 |
def _masterChanged(self, masterResultSet, detailResultSet): |
def _masterChanged(self, masterResultSet, detailResultSet): |
192 |
GDebug.printMesg (5, 'GRDataMapper._masterChanged') |
GDebug.printMesg (5, 'GRDataMapper._masterChanged on %s' % self.name) |
193 |
self._resultsets.insert(0,detailResultSet) |
self._resultsets.insert(0,detailResultSet) |
194 |
|
|
195 |
|
|
364 |
for s in self.sourceMap[source]: |
for s in self.sourceMap[source]: |
365 |
|
|
366 |
# Reset running summary counts if necessary... |
# Reset running summary counts if necessary... |
|
if firstSection and firstSection != controlSection._lastSection: |
|
|
s._clearSummaries() |
|
367 |
|
|
368 |
changed = s._precheckNextFields(recordset) |
changed = s._precheckNextFields(recordset) |
369 |
|
|
372 |
GDebug.printMesg(10, "After next record, first changed section is %s" % s.name) |
GDebug.printMesg(10, "After next record, first changed section is %s" % s.name) |
373 |
firstSection = s.name |
firstSection = s.name |
374 |
|
|
375 |
|
|
376 |
# Save the new field values in the data handler |
# Save the new field values in the data handler |
377 |
for field in s.fields.keys(): |
for field in s.fields.keys(): |
378 |
s.fields[field] = recordset.getField(field) |
s.fields[field] = recordset.getField(field) |
379 |
|
|
380 |
# ... and save any new summary data |
# ... and save any new summary data |
381 |
|
if s._clearOnNextSet: |
382 |
|
s.clearSummaries() |
383 |
|
|
384 |
for field in s.summaries.keys(): |
for field in s.summaries.keys(): |
385 |
for function in _summFunctions: |
for function in _summFunctions: |
386 |
if s.summaries[field].has_key(function): |
if s.summaries[field].has_key(function): |
410 |
# Contains all "summary" functions that |
# Contains all "summary" functions that |
411 |
# depend on other record keeping. (e.g., |
# depend on other record keeping. (e.g., |
412 |
# 'averages' need the total and the count |
# 'averages' need the total and the count |
413 |
# tracked. |
# tracked.) |
414 |
# |
# |
415 |
_summMultiMapping = { 'avg': ('sum','count'), |
_summMultiMapping = { 'avg': ('sum','count'), |
416 |
} |
} |