[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-reports/src GRDataMapper.py GRLayout....
From: |
Jason Cater |
Subject: |
gnue/gnue-reports/src GRDataMapper.py GRLayout.... |
Date: |
Wed, 20 Jun 2001 15:33:38 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/06/20 15:33:38
Modified files:
gnue-reports/src: GRDataMapper.py GRLayout.py GRParser.py
Log message:
Miscellaneous changes; added a <default> tag to sections (the default
text will be (the only) output generated by a section if the datasource for
that section does not generate any results
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-reports/src/GRDataMapper.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-reports/src/GRLayout.py.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-reports/src/GRParser.py.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gnue/gnue-reports/src/GRDataMapper.py
diff -u gnue/gnue-reports/src/GRDataMapper.py:1.2
gnue/gnue-reports/src/GRDataMapper.py:1.3
--- gnue/gnue-reports/src/GRDataMapper.py:1.2 Wed May 30 07:43:02 2001
+++ gnue/gnue-reports/src/GRDataMapper.py Wed Jun 20 15:33:38 2001
@@ -120,11 +120,12 @@
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 \
- self.grouping or \
+ not self.grouping or \
self.fields[field] != val ):
self.changed = 1
- GDebug.printMesg(10, "Field %s changed after nextRecord" % field)
+ 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
GDebug.printMesg(10, "After _loadFields, changed=%s" % self.changed)
self.initial = 0
@@ -155,7 +156,7 @@
def addSection(self, section, source, parentSection):
if source == None:
return
- if self.sectionMap.has_key ('section'):
+ if self.sectionMap.has_key (section):
raise GRException.SectionHasDuplicateName, \
"Section %s is defined multiple times" % section
@@ -215,11 +216,12 @@
GDebug.printMesg (4, 'Creating ResultSet for source %s' % source)
controlSection.resultset = self.sources.getDataSource(source)\
.getDataObject().createResultSet(readOnly=1)
+# print "controlSection=%s" % controlSection
else:
GDebug.printMesg(4, 'Getting pre-created ResultSet for source "%s"' \
% (source))
- self.getNextRecord(source)
+ return self.getNextRecord(source)
# Returns a string containing first section to change.
@@ -231,6 +233,7 @@
GDebug.printMesg (6, 'Getting next record for source %s' % source)
controlSection = self.sourceMap[source][0]
+# print "controlSection=%s" % controlSection
GDebug.printMesg (10, controlSection.resultset)
Index: gnue/gnue-reports/src/GRLayout.py
diff -u gnue/gnue-reports/src/GRLayout.py:1.5
gnue/gnue-reports/src/GRLayout.py:1.6
--- gnue/gnue-reports/src/GRLayout.py:1.5 Tue Jun 5 22:25:00 2001
+++ gnue/gnue-reports/src/GRLayout.py Wed Jun 20 15:33:38 2001
@@ -119,6 +119,7 @@
self._mapper.addSection(object.name, \
object.source, object._parent.name)
object._mymapper = self._mapper.sectionMap[object.name]
+ object._mymapper._object = object
elif isinstance(object, GRField):
s = object._parent.getAncestorWithSource(object.source)
@@ -159,7 +160,7 @@
#
- # Pull value for paramters
+ # Pull value for parameters
#
if object.getObjectType == 'GRParam':
object._value = self._parameters.getParameter(object.name)
@@ -194,9 +195,11 @@
self.source = None
self._mymapper = None
+ # Called if section contains data
def process(self, dest, mapper):
pass
+
############################################################
#
# <section> tag
@@ -207,7 +210,6 @@
def process(self, dest, mapper):
-
myTurnAtBat = 1
while myTurnAtBat:
@@ -219,8 +221,16 @@
else:
if isinstance(child, GRSection) and child._mymapper.toplevel:
GDebug.printMesg(10, "Getting first record for child;
(child,toplevel)=(%s,%s)" % (child.name, child._mymapper.toplevel))
- mapper.getFirstRecord(child.source)
- child.process(dest, mapper)
+ if mapper.getFirstRecord(child.source):
+ # There was data returned, so process section
+ child.process(dest, mapper)
+ else:
+ # There was no data returned, so generate default text (if any)
+ for c2 in child._children:
+ if isinstance (c2, GRDefault):
+ c2.processDefault(dest, mapper)
+ else:
+ child.process(dest, mapper)
if self._mymapper == None or not self._mymapper.toplevel:
myTurnAtBat = 0
else:
@@ -230,8 +240,8 @@
myTurnAtBat = 0
else:
if goto != self.name:
- GDebug.printMesg (10, "Calling process() for section '%s'" % goto)
- mapper.sectionMap[goto].process(dest, mapper)
+ GDebug.printMesg (10, "Calling process() for section '%s' (mapper
is %s)" % (goto, mapper.sectionMap[goto]))
+ mapper.sectionMap[goto]._object.process(dest, mapper)
structuralComment(dest,"<!--[/section:%s]-->" % self.name)
GDebug.printMesg(10,"Left section %s" % self.name)
@@ -247,6 +257,31 @@
return self._parent.getAncestorWithSource(source)
else:
return None
+
+
+############################################################
+#
+# <default> tag
+# Text in this tag is only displayed if datasource
+# returns no data. Note: this will be the only thing
+# in the section that will be displayed.
+#
+class GRDefault (GObj):
+ def __init__(self, parent=None, type='GRDefault'):
+ GObj.__init__(self, parent, type=type)
+ self.name = None
+ self.source = None
+ self._mymapper = None
+
+ def processDefault(self, dest, mapper):
+ structuralComment(dest,"<!--[default]-->")
+ for child in self._children:
+ if child.getObjectType() == "_content_":
+ dest.write(child.getContent())
+ structuralComment(dest,"<!--[/default]-->")
+
+ def process(self, dest, mapper):
+ pass
############################################################
Index: gnue/gnue-reports/src/GRParser.py
diff -u gnue/gnue-reports/src/GRParser.py:1.8
gnue/gnue-reports/src/GRParser.py:1.9
--- gnue/gnue-reports/src/GRParser.py:1.8 Tue May 29 19:19:49 2001
+++ gnue/gnue-reports/src/GRParser.py Wed Jun 20 15:33:38 2001
@@ -87,6 +87,7 @@
'layout': (GRLayout, { 'format': (0, 0, char, None)}, 0),
'section': (GRSection, { 'name': (0, 0, char, None),
'source': (0, 0, char, None)}, 0),
+ 'default': (GRDefault, { }, 0),
'field': (GRField, { 'name': (1, 0, char, None),
'source': (0, 0, char, None),
'format': (0, 0, char, None)}, 1),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnue-reports/src GRDataMapper.py GRLayout....,
Jason Cater <=