commit-gnue
[Top][All Lists]
Advanced

[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: Sun, 05 Aug 2001 11:29:58 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Branch:         gnuef-new-datasources
Changes by:     Jason Cater <address@hidden>    01/08/05 11:29:58

Modified files:
        reports/src    : GRDataMapper.py GRLayout.py 

Log message:
        restructured grouping/section algorithm; first functioning prototype :)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRDataMapper.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.3.2.1&tr2=1.3.2.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRLayout.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.6.2.1&tr2=1.6.2.2&r1=text&r2=text

Patches:
Index: gnue/reports/src/GRDataMapper.py
diff -u gnue/reports/src/GRDataMapper.py:1.2 
gnue/reports/src/GRDataMapper.py:1.3
--- gnue/reports/src/GRDataMapper.py:1.2        Wed May 30 07:43:02 2001
+++ 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/reports/src/GRLayout.py
diff -u gnue/reports/src/GRLayout.py:1.5 gnue/reports/src/GRLayout.py:1.6
--- gnue/reports/src/GRLayout.py:1.5    Tue Jun  5 22:25:00 2001
+++ 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
 
 
 ############################################################



reply via email to

[Prev in Thread] Current Thread [Next in Thread]