commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/reports/src GRLayout.py


From: Jason Cater
Subject: gnue/reports/src GRLayout.py
Date: Mon, 08 Apr 2002 18:01:52 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/04/08 18:01:50

Modified files:
        reports/src    : GRLayout.py 

Log message:
        I have broken reports (and haven't even released yet :)... conversion 
to new process format

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRLayout.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: gnue/reports/src/GRLayout.py
diff -c gnue/reports/src/GRLayout.py:1.21 gnue/reports/src/GRLayout.py:1.22
*** gnue/reports/src/GRLayout.py:1.21   Mon Apr  8 12:03:20 2002
--- gnue/reports/src/GRLayout.py        Mon Apr  8 18:01:50 2002
***************
*** 200,207 ****
      self._inits = [self.primaryInit]
  
    # Called if section contains data
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
!     pass
  
    def primaryInit(self):
      if hasattr(self,'source') and self.source is not None:
--- 200,207 ----
      self._inits = [self.primaryInit]
  
    # Called if section contains data
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
!     return nextSection
  
    def primaryInit(self):
      if hasattr(self,'source') and self.source is not None:
***************
*** 223,244 ****
      GRLayoutElement.__init__(self, parent, type=type)
  
  
!   def processChildren(self, dest, mapper, isfirst=0, nextSection=None):
!     for child in self._children:
!       if child.getObjectType() == "_content_":
!         dest.write(child.getContent())
!       else:
!         if isinstance(child, GRSection):
!           if child._mymapper.toplevel:
!             GDebug.printMesg(10, "Calling new controlling section")
!             child.processAsController(dest, mapper)
!           else:
!             child.process(dest, mapper, 1, nextSection)
! #            print nextSection, child._name
! #            if nextSection == child._name:
! #              break
          else:
!           child.process(dest, mapper, isfirst, nextSection)
  
    #
    #  getAncestorWithSource()
--- 223,282 ----
      GRLayoutElement.__init__(self, parent, type=type)
  
  
!   # Process all children, handling GRSections properly
!   def processChildren(self, dest, mapper,
!                       isfirst, firstSection, nextSection):
!     try:
!       print ">>>>in %s" % self._name
!     except:
!       pass
!     while 1:
!       for child in self._children:
!         print "handling child %s" % child._type
!         if child._type == "_content_":
!           dest.write(child.getContent())
          else:
!           if isinstance(child, GRSection):
!             if child._mymapper.toplevel:
!               GDebug.printMesg(10, "Calling new controlling section")
!               child.processAsController(dest, mapper)
!             else:
!               nextSection = child.process(dest, mapper, 1, firstSection, 
nextSection)
!               # If we are repeating on our section, then go no further until 
we're done
!               print "nextSection after child = %s" % nextSection._name
!             try:
!               print "returning %s" % nextSection._name
!             except:
!               print "returning %s" % nextSection
! 
!           else:
!             nextSection = child.process(dest, mapper, isfirst, firstSection, 
nextSection)
!             try:
!               print "subNextSection = %s" % nextSection._name
!             except:
!               print "subNextSection = %s" % nextSection
! 
! 
!       if nextSection != self:
!         try:
!           print "breaking from %s; nextSection=%s" % (self._name, 
nextSection._name)
!         except:
!           try:
!             print "breaking from %s; nextSection=%s" % (self._name, None)
!           except:
!             print "breaking from %s" % 
string.split(string.split(str(self))[0],'.')[1]
! 
!         break
!       else:
!         print "calling gotos"
!         firstSection, nextSection = self.getGotos(mapper)
! 
!     try:
!       print "<<<<out %s" % self._name
!     except:
!       print "<<<<out"
!     return nextSection
! 
  
    #
    #  getAncestorWithSource()
***************
*** 280,288 ****
    # Retrieve the first row of data, if available.
    # Handle default data if no rows retrieved.
    #
-   # TODO: What if the top section isn't bound to a source?
-   # TODO: Does this work? [ Hmmm... Answer: NO! ]
-   #
    def processAsController(self, dest, mapper):
  
      GDebug.printMesg(10,
--- 318,323 ----
***************
*** 292,327 ****
        # This is a dataless section...
        # simply process it's children
  
!       self.process(dest, mapper, 1, None)
  
      else:
        if mapper.getFirstRecord(self._source):
          # This is a data-bound section and there
          # was data returned, so process section
  
  
!         # Determine the next section to process our data.
!         # (i.e., handle section grouping)
!         (goto, gotoNext) = mapper.getFirstRecord(self._source)
! 
!         oldSection = None
! 
!         while goto:
! 
!           section = mapper.sectionMap[goto]._object
!           if gotoNext:
!             nextSection = mapper.sectionMap[gotoNext]._object._name
!           else:
!              gotoNext = None
! 
!           # Process the current data row starting at correct section
!           section.process(dest, mapper, (oldSection in 
section._childSections),
!                         nextSection)
! 
!           (goto, gotoNext) = mapper.getNextRecord(self._source)
!           GDebug.printMesg (10, "Goto is '%s'; next is '%s'" % (goto, 
gotoNext))
! 
!           oldSection = section._name
  
        else:
          # This is a data-bound section and there
--- 327,364 ----
        # This is a dataless section...
        # simply process it's children
  
!       self.process(dest, mapper, 1, None, None)
  
      else:
        if mapper.getFirstRecord(self._source):
          # This is a data-bound section and there
          # was data returned, so process section
  
+         firstSection, nextSection = self.getGotos(mapper,1)
  
!         print "nextSection = %s" % nextSection
!         self.process(dest, mapper, 1, self, nextSection)
! #
! #        oldSection = None
! #
! #
! #        while goto:
! #
! #          section = mapper.sectionMap[goto]._object
! #          if gotoNext:
! #            nextSection = mapper.sectionMap[gotoNext]._object._name
! #          else:
! #            nextSection = None
! #
! #          # Process the current data row starting at correct section
! #          section.process(dest, mapper, (oldSection in 
section._childSections),
! #                        firstSection, nextSection)
! #
! #          (goto, gotoNext) = mapper.getNextRecord(self._source)
! #          GDebug.printMesg (10, "Goto is '%s'; next is '%s'" % (goto, 
gotoNext))
! #
! #          oldSection = section._name
! #
  
        else:
          # This is a data-bound section and there
***************
*** 334,339 ****
--- 371,404 ----
  
  
    #
+   # Used internally to determine next section to move
+   #
+   def getGotos(self, mapper, first=0):
+     print "getGotos()  [%s]" % self._name
+     # Determine the next section to process our data.
+     # (i.e., handle section grouping)
+     if first:
+       goto, gotoNext = mapper.getFirstRecord(self._source)
+     else:
+       goto, gotoNext = mapper.getNextRecord(self._source)
+ 
+     # Get the actual GRSection objects
+     firstSection = mapper.sectionMap[goto]._object
+     if gotoNext:
+       nextSection = mapper.sectionMap[gotoNext]._object
+     else:
+       nextSection = None
+ 
+     try:
+       print "goto=%s; next=%s" % (firstSection._name, nextSection._name)
+     except:
+       print "goto=%s; next=%s" % (firstSection._name, None)
+ 
+     # And return them
+     return (firstSection, nextSection)
+ 
+ 
+   #
    #  getAncestorWithSource()
    #
    def getAncestorWithSource(self, source):
***************
*** 347,359 ****
  
    # Generic process() method.  Process the
    # current record and handle any children.
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
  
      GDebug.printMesg(10,"Repeating Section %s" % self._name)
      structuralComment(dest,"<!--[section:%s]-->" % self._name)
!     self.processChildren(dest, mapper, isfirst, nextSection)
      structuralComment(dest,"<!--[/section:%s]-->" % self._name)
      GDebug.printMesg(10,"Leaving section %s" % self._name)
  
  
  ############################################################
--- 412,425 ----
  
    # Generic process() method.  Process the
    # current record and handle any children.
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
  
      GDebug.printMesg(10,"Repeating Section %s" % self._name)
      structuralComment(dest,"<!--[section:%s]-->" % self._name)
!     nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
      structuralComment(dest,"<!--[/section:%s]-->" % self._name)
      GDebug.printMesg(10,"Leaving section %s" % self._name)
+     return nextSection
  
  
  ############################################################
***************
*** 377,384 ****
          dest.write(child.getContent())
      structuralComment(dest,"<!--[/default]-->")
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
!     pass
  
  
  
--- 443,450 ----
          dest.write(child.getContent())
      structuralComment(dest,"<!--[/default]-->")
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
!     return nextSection
  
  
  
***************
*** 392,401 ****
      self._section = None
      self.format = None
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      structuralComment(dest,"<!--[field:%s]-->" % self.name)
      dest.write (self._mymapper.getField(self.name, self.format))
      structuralComment(dest,"<!--[/field:%s]-->" % self.name)
  
  
  
--- 458,468 ----
      self._section = None
      self.format = None
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      structuralComment(dest,"<!--[field:%s]-->" % self.name)
      dest.write (self._mymapper.getField(self.name, self.format))
      structuralComment(dest,"<!--[/field:%s]-->" % self.name)
+     return nextSection
  
  
  
***************
*** 410,419 ****
      self.function = "count"
      self.format = None
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      structuralComment(dest,"<!--[summ:%s]-->" % self.name)
      dest.write (self._mymapper.getSummary(self.name, self.function, 
self.format))
      structuralComment(dest,"<!--[/summ:%s]-->" % self.name)
  
  
  
--- 477,487 ----
      self.function = "count"
      self.format = None
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      structuralComment(dest,"<!--[summ:%s]-->" % self.name)
      dest.write (self._mymapper.getSummary(self.name, self.function, 
self.format))
      structuralComment(dest,"<!--[/summ:%s]-->" % self.name)
+     return nextSection
  
  
  
***************
*** 428,437 ****
      GRLayoutElement.__init__(self, parent)
      GRStubParam.__init__(self, parent)
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      structuralComment(dest,"<!--[param:%s]-->" % self.name)
      dest.write (self.getFormattedValue())
      structuralComment(dest,"<!--[/summ:%s]-->" % self.name)
  
  
  
--- 496,506 ----
      GRLayoutElement.__init__(self, parent)
      GRStubParam.__init__(self, parent)
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      structuralComment(dest,"<!--[param:%s]-->" % self.name)
      dest.write (self.getFormattedValue())
      structuralComment(dest,"<!--[/summ:%s]-->" % self.name)
+     return nextSection
  
  
  
***************
*** 445,482 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRFirstRow')
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      if isfirst:
!       self.processChildren(dest, mapper, isfirst, nextSection)
  
  
  class GRNotFirstRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotFirstRow')
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      if not isfirst:
!       self.processChildren(dest, mapper, isfirst, nextSection)
  
  
  class GRLastRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRLastRow')
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      # TODO
      if not nextSection:
!       self.processChildren(dest, mapper, isfirst, nextSection)
  
  
  class GRNotLastRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotLastRow')
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      # TODO
      if nextSection:
!       self.processChildren(dest, mapper, isfirst, nextSection)
  
  
  
--- 514,556 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRFirstRow')
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      if isfirst:
!       nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
!     return nextSection
! 
  
  
  class GRNotFirstRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotFirstRow')
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      if not isfirst:
!       nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
!     return nextSection
  
  
  class GRLastRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRLastRow')
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      # TODO
      if not nextSection:
!       nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
!     return nextSection
  
  
  class GRNotLastRow(ContainerElement):
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotLastRow')
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      # TODO
      if nextSection:
!       nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
!     return nextSection
  
  
  
***************
*** 489,503 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRPassThru')
  
!   def process(self, dest, mapper, isfirst=0, nextSection=None):
      dest.write('<%s' % self._xmltag)
      for attr in self._loadedxmlattrs.keys():
        dest.write(' %s="%s"' % (attr, 
saxutils.escape(str(self._loadedxmlattrs[attr]))))
  
      if len(self._children):
        dest.write('>')
!       self.processChildren(dest, mapper, isfirst, nextSection)
        dest.write('</%s>' % self._xmltag)
      else:
        dest.write('/>')
  
--- 563,578 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRPassThru')
  
!   def process(self, dest, mapper, isfirst, firstSection, nextSection):
      dest.write('<%s' % self._xmltag)
      for attr in self._loadedxmlattrs.keys():
        dest.write(' %s="%s"' % (attr, 
saxutils.escape(str(self._loadedxmlattrs[attr]))))
  
      if len(self._children):
        dest.write('>')
!       nextSection = self.processChildren(dest, mapper, isfirst, firstSection, 
nextSection)
        dest.write('</%s>' % self._xmltag)
+       return nextSection
      else:
        dest.write('/>')
  



reply via email to

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