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 GR...


From: Jason Cater
Subject: gnue/reports/src GRDataMapper.py GRLayout.py GR...
Date: Sun, 05 Aug 2001 09:36:57 -0700

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

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

Log message:
        synching machines

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&tr2=1.3.2.1&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&tr2=1.6.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRParser.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.10&tr2=1.10.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRQueryBuilder.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.2&tr2=1.2.2.1&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
 
 
 ############################################################
Index: gnue/reports/src/GRParser.py
diff -u gnue/reports/src/GRParser.py:1.9 gnue/reports/src/GRParser.py:1.10
--- gnue/reports/src/GRParser.py:1.9    Wed Jun 20 15:33:38 2001
+++ gnue/reports/src/GRParser.py        Mon Jul  2 10:03:18 2001
@@ -36,7 +36,23 @@
 from GRSortOptions import *
 from GRLayout import *
 from gnue.common import GDataSource
+import copy, types
 
+
+
+
+
+
+########
+########  Please keep this file neat !!!
+########
+
+
+
+
+
+
+
 #######################################################
 # This method loads a report from an XML file and returns 
 # a GRReport object.  If initialize is 1 (default), then 
@@ -49,6 +65,162 @@
 
 
 
+xmlElements = None
+
+
+def getXMLelements(): 
+
+  global xmlElements
+
+  if xmlElements == None:
+
+    #
+    #
+    xmlElements = { 
+      'report':       {
+         'BaseClass': GRReport.GRReport, 
+         'Required': 1,
+         'SingleInstance': 1, 
+         'Attributes':  { 
+            'title':       {
+               'Typecast': char } } ,
+         'ParentTags':  None },
+
+      'parameters':   {
+         'BaseClass': GRParameters , 
+         'SingleInstance': 1, 
+         'ParentTags':  ('form',)}, 
+
+      'parameter':    {
+         'BaseClass': GRParameter, 
+         'Attributes': { 
+            'id':          {
+               'Required': 1, 
+               'Unique': 1, 
+               'Typecast': char },
+            'required':    {
+               'Typecast': bool, 
+               'Default': 0 },
+            'limited':     {
+               'Typecast': bool, 
+               'Default': 0 },
+            'default':     {
+               'Typecast': char },
+            'description': {
+               'Required': 1, 
+               'Typecast': char },
+            'source':      {
+               'Typecast': char }, 
+            'type':        {
+               'Typecast': char, 
+               'Default': "char" } }, 
+         'ParentTags':  ('parameters',) }, 
+
+      'sortoptions':  {
+         'BaseClass': GRSortOptions, 
+         'SingleInstance': 1, 
+         'ParentTags':  ('form',) }, 
+
+      'sortoption':   {
+         'BaseClass': GRSortOption,
+         'Attributes': { 
+            'id':          {
+               'Required': 1, 
+               'Unique': 1, 
+               'Typecast': char }, 
+            'description': {
+               'Required': 1, 
+               'Typecast': char },
+            'default':     {
+               'Typecast': bool, 
+               'Default': 0 } }, 
+         'ParentTags':  ('sortoptions',) },
+
+      'sortcolumn':   {
+         'BaseClass': GRSortColumn,
+         'Attributes': { 
+            'name':        {
+               'Required': 1, 
+               'Typecast': char } }, 
+         'ParentTags':  ('sortoption',) }, 
+
+      'layout':       {
+         'BaseClass': GRLayout,    
+         'Required': 1,
+         'SingleInstance': 1, 
+         'Attributes': { 
+            'format':      {
+               'Typecast': char } }, 
+         'ParentTags':  ('form',) }, 
+
+      'section':      {
+         'BaseClass': GRSection,   
+         'Required': 1,
+         'MixedContent': 1, 
+         'KeepWhitespace': 1, 
+         'Attributes': { 
+            'name':        {
+               'Typecast': char }, 
+            'source':      {
+               'Typecast': char } }, 
+         'ParentTags':  ('layout',) }, 
+
+      'default':      {
+         'BaseClass': GRDefault, 
+         'MixedContent': 1, 
+         'KeepWhitespace': 1, 
+         'ParentTags':  ('layout',) },
+
+      'field':        {
+         'BaseClass': GRField,     
+         'Attributes': { 
+            'name':        {
+               'Required': 1, 
+               'Typecast': char }, 
+            'source':      {
+               'Typecast': char }, 
+            'format':      {
+               'Typecast': char } }, 
+         'ParentTags':  ('layout',) }, 
+
+      'summ':         {
+         'BaseClass': GRField,     
+         'Attributes': { 
+            'name':        {
+               'Required': 1, 
+               'Typecast': char }, 
+            'function':    {
+               'Typecast': char, 
+               'Default': "count"}, 
+            'source':      {
+               'Typecast': char, 
+               'Default': None}, 
+            'section':     {
+               'Typecast': char }, 
+            'format':      {
+               'Typecast': char } }, 
+         'ParentTags':  ('layout',) }, 
+
+      'sources':      {
+         'BaseClass': GRSources, 
+         'SingleInstance': 1, 
+         'ParentTags':  ('form',) }, 
+
+      'datasource':   {
+         'BaseClass': GRDataSource,  
+         'Attributes': GDataSource.tagAttributes, 
+         'ParentTags':  ('sources',) } 
+    } 
+
+    #
+    # Add DataSource elements
+    #
+    xmlElements.update(GDataSource.xmlElements)
+
+
+  return xmlElements
+
+
 #######################################################
 #
 # xmlReportHandler
@@ -61,47 +233,5 @@
 class xmlReportHandler (xmlHandler): 
   def __init__(self): 
     xmlHandler.__init__(self) 
-
-    #
-    # xmlElements=
-    #   {tagName: (baseClass, attributesHash, normalizeWhitespace?)}
-    #      
-    # attributesHash=
-    #   {attrName: (required?, uniqueID?, typecast, defaultValue)}
-    #
-    self.xmlElements = { 
-      'report':       (GRReport.GRReport, { 'title':       (0, 0, char, 
None)}, 1), 
-      'parameters':   (GRParameters,{                                  }, 1), 
-      'parameter':    (GRParameter, { 'id':          (1, 1, char, None), 
-                                      'required':    (0, 0, bool, 0), 
-                                      'limited':     (0, 0, bool, 0), 
-                                      'default':     (0, 0, char, None), 
-                                      'description': (1, 0, char, None), 
-                                      'source':      (0, 0, char, None), 
-                                      'type':        (0, 0, char, "char")}, 1),
-      'sortoptions':  (GRSortOptions,{                                 }, 1), 
-      'sortoption':   (GRSortOption,{ 'id':          (1, 1, char, None), 
-                                      'description': (1, 0, char, None), 
-                                      'default':     (0, 0, bool, 0)   }, 1),
-      'sortcolumn':   (GRSortColumn,{ 'name':        (1, 0, char, None)}, 1), 
-      '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), 
-      'summ':         (GRField,     { 'name':        (1, 0, char, None), 
-                                      'function':    (0, 0, char, "count"), 
-                                      'source':      (0, 0, char, None), 
-                                      'section':     (0, 0, char, None), 
-                                      'format':      (0, 0, char, None)}, 1), 
-      'sources':      (GRSources,   {                                  }, 1), 
-      'datasource':   (GRDataSource,  GDataSource.tagAttributes         , 1), 
-    } 
-
-    #
-    # Add DataSource elements
-    #
-    self.xmlElements.update(GDataSource.xmlElements)
 
+    self.xmlElements = getXMLelements()
Index: gnue/reports/src/GRQueryBuilder.py
diff -u gnue/reports/src/GRQueryBuilder.py:1.1 
gnue/reports/src/GRQueryBuilder.py:1.2
--- gnue/reports/src/GRQueryBuilder.py:1.1      Fri Apr 13 11:28:02 2001
+++ gnue/reports/src/GRQueryBuilder.py  Mon Apr 23 09:28:06 2001
@@ -31,6 +31,7 @@
 
 from GRQuery import GRQueryElement
 import string 
+import sys
 
 #
 # Base class for GRQueryBuilders. Doesn't actually 
@@ -50,51 +51,48 @@
 
   def __init__(self): 
     self.languageElements = {
-       'QUERY':           ( 1, 999, 'SELECT %s',                 
self.handleQuery ),
-       'SUBQUERY':        ( 1, 999, 'SELECT %s',                 
self.handleQuery ),
-       'FIELDS':          ( 1, 999, '%s',                        ','      ),
-       'COLUMNS':         ( 1, 999, '%s',                        ','      ),
-       'FIELD':           ( 1,   1, '%s',                        
self.handleField ),
-       'SUBCOLUMN':       ( 1,   1, '%s',                        
self.handleField ),
-       'SOURCE':          ( 1,   1, '%s',                        
self.handleSource ),
-       'TABLE':           ( 1,   1, '%s',                        
self.handleTable ),
-       'FUNC':            ( 1,   1, '%s',                        
self.handleFunc ),
-       'COLUMN':          ( 1,   1, '%s',                        
self.handleColumn ),
-       'SOURCES':         ( 1, 999, ' FROM %s',                  ','      ),
-       'CONDITIONS':      ( 1, 999, ' WHERE (%s)',               ' AND '  ),
-       'GROUPBY':         ( 1, 999, ' GROUP BY %s',              ','      ),
-       'HAVING':          ( 1, 999, ' HAVING (%s)',              ' AND '       
   ),
-       'UNION':           ( 1, 999, ' UNION %s',                 ' UNION '     
   ),
-       'UNION:all':       ( 1, 999, ' UNION ALL %s',             ' UNION ALL ' 
   ),
-       'UNION:minus':     ( 1, 999, ' MINUS %s',                 ' MINUS '     
   ),
-       'UNION:intersect': ( 1, 999, ' INTERSECT %s',             ' INTERSECT ' 
   ),
-       'CONST':           ( 1,   1, '%s',                        
self.handleConst ),
+       'GRquery':           ( 1, 999, 'SELECT %s',                 
self.handleQuery ),
+       'GRsubquery':        ( 1, 999, 'SELECT %s',                 
self.handleQuery ),
+       'GRfields':          ( 1, 999, '%s',                        ','      ),
+       'GRcolumns':         ( 1, 999, '%s',                        ','      ),
+       'GRfield':           ( 1,   1, '%s',                        
self.handleField ),
+       'GRsubcolumn':       ( 1,   1, '%s',                        
self.handleField ),
+       'GRsource':          ( 1,   1, '%s',                        
self.handleSource ),
+       'GRtable':           ( 1,   1, '%s',                        
self.handleTable ),
+       'GRfunc':            ( 1,   1, '%s',                        
self.handleFunc ),
+       'GRcolumn':          ( 1,   1, '%s',                        
self.handleColumn ),
+       'GRsources':         ( 1, 999, ' FROM %s',                  ','      ),
+       'GRconditions':      ( 1, 999, ' WHERE (%s)',               ' AND '  ),
+       'GRgroupby':         ( 1, 999, ' GROUP BY %s',              ','      ),
+       'GRhaving':          ( 1, 999, ' HAVING (%s)',              ' AND '     
     ),
+       'GRunion':           ( 1, 999, ' UNION %s',                 ' UNION '   
     ),
+       'GRconst':           ( 1,   1, '%s',                        
self.handleConst ),
        #####
-       'ADD':             ( 2, 999, '(%s)',                      '+'      ),
-       'SUB':             ( 2, 999, '(%s)',                      '-'      ),
-       'MUL':             ( 2, 999, '(%s)',                      '*'      ),
-       'DIV':             ( 2, 999, '(%s)',                      '/'      ),
-       'AND':             ( 2, 999, '(%s)',                      ' AND '  ), 
-       'OR':              ( 2, 999, '(%s)',                      ' OR '   ), 
-       'NOT':             ( 1,   1, '(NOT %s)',                  None     ), 
-       'NEGATE':          ( 1,   1, '-%s',                       None     ),
-       'EQ':              ( 2,   2, '(%s = %s)',                 None     ),
-       'NE':              ( 2,   2, '(%s != %s)',                None     ),
-       'GT':              ( 2,   2, '(%s > %s)',                 None     ),
-       'GE':              ( 2,   2, '(%s >= %s)',                None     ),
-       'LT':              ( 2,   2, '(%s < %s)',                 None     ),
-       'LE':              ( 2,   2, '(%s <= %s)',                None     ),
-       'LIKE':            ( 2,   2, '%s LIKE %s',                None     ),
-       'NOTLIKE':         ( 2,   2, '%s NOT LIKE %s',            None     ),
-       'BETWEEN':         ( 3,   3, '%s BETWEEN %s AND %s',      None     ),
-       'NOTBETWEEN':      ( 3,   3, '%s NOT BETWEEN %s AND %s',  None     ), 
-       'COUNT':           ( 1,   1, 'COUNT(%s)',                 None     ), 
-       'COUNTDISTINCT':   ( 1,   1, 'COUNT(DISTINCT %s)',        None     ), 
-       'COUNTALL':        ( 0,   0, 'COUNT(*)',                  None     ), 
-       'SUM':             ( 1,   1, 'SUM(%s)',                   None     ), 
-       'AVG':             ( 1,   1, 'AVG(%s)',                   None     ), 
-       'MAX':             ( 1,   1, 'MAX(%s)',                   None     ), 
-       'MIN':             ( 1,   1, 'MIN(%s)',                   None     ), 
+       'GRadd':             ( 2, 999, '(%s)',                      '+'      ),
+       'GRsub':             ( 2, 999, '(%s)',                      '-'      ),
+       'GRmul':             ( 2, 999, '(%s)',                      '*'      ),
+       'GRdiv':             ( 2, 999, '(%s)',                      '/'      ),
+       'GRand':             ( 2, 999, '(%s)',                      ' AND '  ), 
+       'GRor':              ( 2, 999, '(%s)',                      ' OR '   ), 
+       'GRnot':             ( 1,   1, '(NOT %s)',                  None     ), 
+       'GRnegate':          ( 1,   1, '-%s',                       None     ),
+       'GReq':              ( 2,   2, '(%s = %s)',                 None     ),
+       'GRne':              ( 2,   2, '(%s != %s)',                None     ),
+       'GRgt':              ( 2,   2, '(%s > %s)',                 None     ),
+       'GRge':              ( 2,   2, '(%s >= %s)',                None     ),
+       'GRlt':              ( 2,   2, '(%s < %s)',                 None     ),
+       'GRle':              ( 2,   2, '(%s <= %s)',                None     ),
+       'GRlike':            ( 2,   2, '%s LIKE %s',                None     ),
+       'GRnotlike':         ( 2,   2, '%s NOT LIKE %s',            None     ),
+       'GRbetween':         ( 3,   3, '%s BETWEEN %s AND %s',      None     ),
+       'GRnotbetween':      ( 3,   3, '%s NOT BETWEEN %s AND %s',  None     ), 
+       'GRcount':           ( 1,   1, 'COUNT(%s)',                 None     ), 
+       'GRcountdistinct':   ( 1,   1, 'COUNT(DISTINCT %s)',        None     ), 
+       'GRcountall':        ( 0,   0, 'COUNT(*)',                  None     ), 
+       'GRsum':             ( 1,   1, 'SUM(%s)',                   None     ), 
+       'GRavg':             ( 1,   1, 'AVG(%s)',                   None     ), 
+       'GRmax':             ( 1,   1, 'MAX(%s)',                   None     ), 
+       'GRmin':             ( 1,   1, 'MIN(%s)',                   None     ), 
     }
 
     self.stringEnclosure = "'"
@@ -102,10 +100,10 @@
 
 
   def generateStatement (self, query): 
-    return handleElements (query)
+    return self.handleElements (query)
 
 
-  def generateStatement (self, element): 
+  def handleElements (self, element): 
 
     if not self.languageElements.has_key(element.type): 
       print "Warning: Element %s is not supported by this driver." % 
element.type
@@ -117,7 +115,7 @@
        finalString, joinString = self.languageElements[element.type]
 
     for e in element.children: 
-      children.append (self.generateStatement(e))
+      children.append (self.handleElements(e))
 
     if type(joinString) == type(self.generateStatement):
       children = joinString(element, children)
@@ -147,63 +145,54 @@
 
 
   def handleQuery (self, element, children): 
-    if element.attributes.has_key ('uniqueness') and 
len(element.attributes['uniqueness'])>0:
-      children[0:0] = element.attributes['id']
-      return ['%s %s' % (element.attributes['uniqueness'], 
string.join(children,''))]
+    if element.__dict__.has_key ('uniqueness') and len(element.uniqueness)>0:
+      children.insert(0,element.uniqueness)
+      return ['%s %s' % (element.uniqueness, string.join(children,''))]
     else: 
       return [string.join(children,'')]
 
 
   def handleUnion (self, element, children): 
-    if element.attributes.has_key ('type') and 
len(element.attributes['type'])>0:
-      return ['%s %s' % (element.attributes['uniqueness'], 
string.join(children,''))]
+    if element.__dict__.has_key ('join') and len(element.join)>0:
+      return ['%s %s' % (element.uniqueness, string.join(children,''))]
     else: 
       return [string.join(children,'')]
 
 
   def handleFunc (self, element, children): 
-    return ['%s(%s)' % (element.attributes['name'], string.join(children,','))]
+    return ['%s(%s)' % (element.name, string.join(children,','))]
 
 
   def handleField (self, element, children): 
-    if element.attributes.has_key ('id') and len(element.attributes['id'])>0:
-      children[0:0] = element.attributes['id']
+    if element.__dict__.has_key ('id') and len(element.id)>0:
+      children.append(element.id)
       return ['%s AS %s' % tuple(children)]
     else: 
       return [children[0]]
 
 
   def handleSource (self, element, children): 
-    if element.attributes.has_key ('id') and len(element.attributes['id'])>0:
-      children[0:0] = element.attributes['id']
+    if element.__dict__.has_key ('id') and len(element.id)>0:
+      children.append(element.id)
       return ['%s AS %s' % tuple(children)]
     else: 
       return [children[0]]
 
 
   def handleColumn (self, element, children): 
-    if element.attributes.has_key ('name') and 
len(element.attributes['name'])>0:
-      children[0:0] = element.attributes['name']
-      return ['%s AS %s' % tuple(children)]
-    else: 
-      return [children[0]]
-
+    return [element.name]
 
   def handleTable (self, element, children): 
-    if element.attributes.has_key ('name') and 
len(element.attributes['name'])>0:
-      children[0:0] = element.attributes['name']
-      return ['%s AS %s' % tuple(children)]
-    else: 
-      return [children[0]]
+    return [element.name]
 
 
   def handleConst (self, element, children): 
-    if element.attributes['type'] == 'string': 
+    if element.datatype == 'string': 
       result = '%s%s%s' % (self.stringEnclosure, 
         string.replace(element.value, self.stringEnclosure, 
                                       self.stringEscapedEnclosure), 
         self.stringEnclosure)
-    elif element.attributes['type'] == 'number': 
+    elif element.datatype == 'number': 
       result = string.trim(element.value) 
     else: 
       # For now, default to string behavior



reply via email to

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