commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/GObjects.py common/src/GParser....


From: Jason Cater
Subject: gnue common/src/GObjects.py common/src/GParser....
Date: Sun, 28 Apr 2002 21:52:54 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/04/28 21:52:54

Modified files:
        common/src     : GObjects.py GParser.py GParserHelpers.py 
        reports/samples/foobulations: monthly.grd 
        reports/src    : GREngine.py GRLayout.py GRParser.py GRReport.py 

Log message:
        * Added XML Namespace support to GObject's dumpXML() (required for 
reports)
        * Fixed problem with GRParam's being added to their parents twice.
        * Made all GRD tags lowercase to make dumpXML() friendly
        * Misc bugfixed to Reports

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GObjects.py.diff?cvsroot=OldCVS&tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GParser.py.diff?cvsroot=OldCVS&tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GParserHelpers.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/foobulations/monthly.grd.diff?cvsroot=OldCVS&tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GREngine.py.diff?cvsroot=OldCVS&tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRLayout.py.diff?cvsroot=OldCVS&tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRParser.py.diff?cvsroot=OldCVS&tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRReport.py.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.34 gnue/common/src/GObjects.py:1.35
*** gnue/common/src/GObjects.py:1.34    Wed Apr 17 15:09:17 2002
--- gnue/common/src/GObjects.py Sun Apr 28 21:52:53 2002
***************
*** 1,14 ****
  #
  # This file is part of GNU Enterprise.
  #
! # GNU Enterprise is free software; you can redistribute it 
! # and/or modify it under the terms of the GNU General Public 
! # License as published by the Free Software Foundation; either 
  # version 2, or (at your option) any later version.
  #
! # GNU Enterprise is distributed in the hope that it will be 
! # useful, but WITHOUT ANY WARRANTY; without even the implied 
! # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  # PURPOSE. See the GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public
--- 1,14 ----
  #
  # This file is part of GNU Enterprise.
  #
! # GNU Enterprise is free software; you can redistribute it
! # and/or modify it under the terms of the GNU General Public
! # License as published by the Free Software Foundation; either
  # version 2, or (at your option) any later version.
  #
! # GNU Enterprise is distributed in the hope that it will be
! # useful, but WITHOUT ANY WARRANTY; without even the implied
! # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  # PURPOSE. See the GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public
***************
*** 101,109 ****
          content += child._content
      return content
  
!   def showTree(self, indent=0): 
      print ' ' * indent + `self._type` + `self`
!     for child in self._children: 
         child.showTree(indent + 2)
  
    #
--- 101,109 ----
          content += child._content
      return content
  
!   def showTree(self, indent=0):
      print ' ' * indent + `self._type` + `self`
!     for child in self._children:
         child.showTree(indent + 2)
  
    #
***************
*** 113,119 ****
    #
    def addChild(self, child):
      self._children.append(child)
!   
    def toXML(self):
      xml_outer = string.lower(self._type[2:])
      r = "<" + xml_outer + ">\n  <options>\n"
--- 113,119 ----
    #
    def addChild(self, child):
      self._children.append(child)
! 
    def toXML(self):
      xml_outer = string.lower(self._type[2:])
      r = "<" + xml_outer + ">\n  <options>\n"
***************
*** 137,159 ****
    #
    # Dumps an XML representation of the object
    #
!   def dumpXML(self, lookupDict, treeDump=None, gap="  "):
!     xmlEntity = string.lower(string.replace(self._type[2:],'_','-'))
!     xmlString = "%s<%s" % (gap[:-2],xmlEntity)
  
      indent = len(xmlString)
      pos = indent
!     for attribute in self.__dict__.keys():
        # skip keys beginning with _
        if attribute[0] == "_":
          continue
        val = self.__dict__[attribute]
!       if lookupDict[xmlEntity].has_key('Attributes') and \
!          lookupDict[xmlEntity]['Attributes'].has_key(attribute):
          if val != None and \
!            (not 
lookupDict[xmlEntity]['Attributes'][attribute].has_key('Default') or \
!             (lookupDict[xmlEntity]['Attributes'][attribute]['Default']) != 
(val)):
!           typecast = 
lookupDict[xmlEntity]['Attributes'][attribute]['Typecast']
            if typecast == GTypecast.boolean \
               and val == 1:
              addl = ' %s=""' % (attribute)
--- 137,198 ----
    #
    # Dumps an XML representation of the object
    #
! 
!   def getXmlTag(self):
!     return string.lower(string.replace(self._type[2:],'_','-'))
! 
!   def dumpXML(self, lookupDict, treeDump=None, gap="  ", xmlnamespaces={}):
!     xmlns = ""
!     xmlnsdef = ""
!     try:
!       if self._xmlnamespace:
!         try:
!           xmlns = xmlnamespaces[self._xmlnamespace] + ":"
!         except KeyError:
!           i = 0
!           xmlns = "out"
!           while xmlns in xmlnamespaces.values():
!             i += 1
!             xmlns = "out%s" % i
!           xmlnamespaces[self._xmlnamespace] = xmlns
!           xmlnsdef = ' xmlns:%s="%s"' % (xmlns, self._xmlnamespace)
!           xmlns += ":"
!     except AttributeError:
!       try:
!         if self._xmlchildnamespace:
!           if not xmlnamespaces.hasattr(self._xmlchildnamespace):
!             i = 0
!             ns = "out"
!             while ns in xmlnamespaces.values():
!               i += 1
!               ns = "out%s" % i
!             xmlnamespaces[self._xmlnamespace] = ns
!             xmlnsdef = ' xmlns:%s="%s"' % (ns, self._xmlchildnamespace)
!       except AttributeError:
!         pass
! 
!     xmlEntity = self.getXmlTag()
!     xmlString = "%s<%s%s%s" % (gap[:-2],xmlns, xmlEntity, xmlnsdef)
  
      indent = len(xmlString)
      pos = indent
!     attrs = self.__dict__.keys()
!     attrs.sort()
!     for attribute in attrs:
        # skip keys beginning with _
        if attribute[0] == "_":
          continue
        val = self.__dict__[attribute]
!       if (xmlns and attribute in self._listedAttributes) or \
!          (not xmlns and lookupDict[xmlEntity].has_key('Attributes') and \
!          lookupDict[xmlEntity]['Attributes'].has_key(attribute)):
          if val != None and \
!            (xmlns or (not 
lookupDict[xmlEntity]['Attributes'][attribute].has_key('Default') or \
!             (lookupDict[xmlEntity]['Attributes'][attribute]['Default']) != 
(val))):
!           try:
!             typecast = 
lookupDict[xmlEntity]['Attributes'][attribute]['Typecast']
!           except:
!             typecast = GTypecast.text
            if typecast == GTypecast.boolean \
               and val == 1:
              addl = ' %s=""' % (attribute)
***************
*** 180,191 ****
  
        if treeDump:
          for child in self._children:
!           xmlString += child.dumpXML(lookupDict, 1,gap+"  ")
  
        if hasContent:
!         xmlString += "</%s>\n" % (xmlEntity)
        else:
!         xmlString += "%s</%s>\n" % (gap[:-2], xmlEntity)
      else:
        xmlString += "/>\n"
      return xmlString
--- 219,231 ----
  
        if treeDump:
          for child in self._children:
!           xmlString += child.dumpXML(lookupDict, 1,gap+"  ",
!               xmlnamespaces=xmlnamespaces)
  
        if hasContent:
!         xmlString += "</%s%s>\n" % (xmlns, xmlEntity)
        else:
!         xmlString += "%s</%s%s>\n" % (gap[:-2], xmlns,xmlEntity)
      else:
        xmlString += "/>\n"
      return xmlString
Index: gnue/common/src/GParser.py
diff -c gnue/common/src/GParser.py:1.36 gnue/common/src/GParser.py:1.37
*** gnue/common/src/GParser.py:1.36     Wed Apr 17 15:09:17 2002
--- gnue/common/src/GParser.py  Sun Apr 28 21:52:53 2002
***************
*** 295,307 ****
      if self.xmlStack[0] != None:
  
        # Masqueraging namespace elements, then keep content
!       if self.xmlMasqueradeNamespaceElements and 
isinstance(self.xmlStack[0],self.xmlMasqueradeNamespaceElements):
!         GContent(self.xmlStack[0], text)
  
        # Should we keep the text?
!       elif self.xmlElements[self.nameStack[0]].get('MixedContent',0):# 
default(self.xmlElements[self.nameStack[0]],'MixedContent',0):
  
!         if self.xmlElements[self.nameStack[0]].get('KeepWhitespace',0): # 
default(self.xmlElements[self.nameStack[0]],'KeepWhitespace',0):
            GContent(self.xmlStack[0], text)
          else:
            # Normalize
--- 295,307 ----
      if self.xmlStack[0] != None:
  
        # Masqueraging namespace elements, then keep content
!       xmlns = self.xmlMasqueradeNamespaceElements and \
!           isinstance(self.xmlStack[0],self.xmlMasqueradeNamespaceElements)
  
        # Should we keep the text?
!       if xmlns or self.xmlElements[self.nameStack[0]].get('MixedContent',0):
  
!         if xmlns or 
self.xmlElements[self.nameStack[0]].get('KeepWhitespace',0):
            GContent(self.xmlStack[0], text)
          else:
            # Normalize
Index: gnue/common/src/GParserHelpers.py
diff -c gnue/common/src/GParserHelpers.py:1.4 
gnue/common/src/GParserHelpers.py:1.5
*** gnue/common/src/GParserHelpers.py:1.4       Wed Apr 17 15:09:17 2002
--- gnue/common/src/GParserHelpers.py   Sun Apr 28 21:52:53 2002
***************
*** 53,59 ****
    def toXML(self):
      return saxutils.escape(self._content)
  
!   def dumpXML(self, lookupDict, treeDump=None, gap=None, escape=1):
      if escape:
        return saxutils.escape(self._content)
      else:
--- 53,60 ----
    def toXML(self):
      return saxutils.escape(self._content)
  
!   def dumpXML(self, lookupDict, treeDump=None, gap=None,
!               escape=1, xmlnamespaces={}):
      if escape:
        return saxutils.escape(self._content)
      else:
Index: gnue/reports/samples/foobulations/monthly.grd
diff -c gnue/reports/samples/foobulations/monthly.grd:1.16 
gnue/reports/samples/foobulations/monthly.grd:1.17
*** gnue/reports/samples/foobulations/monthly.grd:1.16  Fri Apr 26 01:34:24 2002
--- gnue/reports/samples/foobulations/monthly.grd       Sun Apr 28 21:52:53 2002
***************
*** 4,12 ****
    <parameters>
       <parameter name="subtitle" description="Report Subtitle"
                  default="Subtitle Not Provided"/>
!      <parameter name="subtitle" description="Starting Date"
                  default="Subtitle Not Provided"/>
!      <parameter name="subtitle" description="Ending Date"
                  default="04/30/02"/>
    </parameters>
  
--- 4,12 ----
    <parameters>
       <parameter name="subtitle" description="Report Subtitle"
                  default="Subtitle Not Provided"/>
!      <parameter name="startdate" description="Starting Date"
                  default="Subtitle Not Provided"/>
!      <parameter name="enddate" description="Ending Date"
                  default="04/30/02"/>
    </parameters>
  
***************
*** 31,38 ****
          <section source="dtsFoo" name="nameBreak">
             <section name="details">
               <out:row>
!                 <firstRow><out:col><field name="name" 
section="nameBreak"/></out:col></firstRow>
!                 <notFirstRow><out:col/></notFirstRow>
                  <out:col align="center"><field name="foodate"/></out:col>
                  <out:col align="right"><field name="foobs"/></out:col>
              </out:row>
--- 31,38 ----
          <section source="dtsFoo" name="nameBreak">
             <section name="details">
               <out:row>
!                 <firstrow><out:col><field name="name" 
section="nameBreak"/></out:col></firstrow>
!                 <notfirstrow><out:col/></notfirstrow>
                  <out:col align="center"><field name="foodate"/></out:col>
                  <out:col align="right"><field name="foobs"/></out:col>
              </out:row>
Index: gnue/reports/src/GREngine.py
diff -c gnue/reports/src/GREngine.py:1.11 gnue/reports/src/GREngine.py:1.12
*** gnue/reports/src/GREngine.py:1.11   Mon Apr 15 01:39:25 2002
--- gnue/reports/src/GREngine.py        Sun Apr 28 21:52:53 2002
***************
*** 64,70 ****
      except IOError, msg:
        raise GRExceptions.ReportUnreadable, \
           "Unable to read the requested report definition\n  (%s)\n\n" % 
reportFile \
!          + "Additional Information:\n  %s" % msg
  
  
      #
--- 64,70 ----
      except IOError, msg:
        raise GRExceptions.ReportUnreadable, \
           "Unable to read the requested report definition\n  (%s)\n\n" % 
reportFile \
!          + "Additional Information:\n  %s" % msgi
  
  
      #
Index: gnue/reports/src/GRLayout.py
diff -c gnue/reports/src/GRLayout.py:1.32 gnue/reports/src/GRLayout.py:1.33
*** gnue/reports/src/GRLayout.py:1.32   Fri Apr 26 01:34:26 2002
--- gnue/reports/src/GRLayout.py        Sun Apr 28 21:52:53 2002
***************
*** 81,88 ****
  
    def initialize(self):
      # Find the xml namespace in use by any child passthru objects
!     self._xmlnamespace = self._findNamespace(self)
!     self._parent._namespace = self._xmlnamespace
  
  
    # Find the xml namespace in use by any child passthru objects
--- 81,88 ----
  
    def initialize(self):
      # Find the xml namespace in use by any child passthru objects
!     self._xmlchildnamespace = self._findNamespace(self)
!     self._parent._namespace = self._xmlchildnamespace
  
  
    # Find the xml namespace in use by any child passthru objects
***************
*** 486,492 ****
    _typestub = 'GRParam'
  
    def __init__(self, parent):
!     GRLayoutElement.__init__(self, parent)
      GRStubParam.__init__(self, parent)
  
    def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
--- 486,495 ----
    _typestub = 'GRParam'
  
    def __init__(self, parent):
!     # This is passed parent=None so that
!     # the GObj.__init__ doesn't add this
!     # object twice to its parent (icky)
!     GRLayoutElement.__init__(self, parent=None)
      GRStubParam.__init__(self, parent)
  
    def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
***************
*** 567,569 ****
--- 570,576 ----
        dest.write('/>')
  
      return nextSection
+ 
+   def getXmlTag(self):
+     return self._xmltag
+ 
Index: gnue/reports/src/GRParser.py
diff -c gnue/reports/src/GRParser.py:1.23 gnue/reports/src/GRParser.py:1.24
*** gnue/reports/src/GRParser.py:1.23   Sun Apr 14 01:19:37 2002
--- gnue/reports/src/GRParser.py        Sun Apr 28 21:52:53 2002
***************
*** 175,199 ****
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'firstRow':      {
           'BaseClass': GRLayout.GRFirstRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'notFirstRow':      {
           'BaseClass': GRLayout.GRNotFirstRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'lastRow':      {
           'BaseClass': GRLayout.GRLastRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'notLastRow':      {
           'BaseClass': GRLayout.GRNotLastRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
--- 175,199 ----
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'firstrow':      {
           'BaseClass': GRLayout.GRFirstRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'notfirstrow':      {
           'BaseClass': GRLayout.GRNotFirstRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'lastrow':      {
           'BaseClass': GRLayout.GRLastRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
           'ParentTags':  ('section',) },
  
!       'notlastrow':      {
           'BaseClass': GRLayout.GRNotLastRow,
           'MixedContent': 1,
           'KeepWhitespace': 1,
Index: gnue/reports/src/GRReport.py
diff -c gnue/reports/src/GRReport.py:1.21 gnue/reports/src/GRReport.py:1.22
*** gnue/reports/src/GRReport.py:1.21   Fri Apr 12 18:21:34 2002
--- gnue/reports/src/GRReport.py        Sun Apr 28 21:52:53 2002
***************
*** 58,64 ****
  
    def dumpXML(self, treeDump=1, gap="  "):
      return GObj.dumpXML(self,
!         GRParser.getXMLelements(), treeDump, gap)
  
  
    #
--- 58,64 ----
  
    def dumpXML(self, treeDump=1, gap="  "):
      return GObj.dumpXML(self,
!         GRParser.getXMLelements(), treeDump, gap, xmlnamespaces={})
  
  
    #
***************
*** 107,114 ****
      # Write common header information
      if not omitGNUeXML:
  
!       if layout._xmlnamespace:
!         ns = ' xmlns="%s"' % layout._xmlnamespace
        else:
          ns = ""
  
--- 107,114 ----
      # Write common header information
      if not omitGNUeXML:
  
!       if layout._xmlchildnamespace:
!         ns = ' xmlns="%s"' % layout._xmlchildnamespace
        else:
          ns = ""
  



reply via email to

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