commit-gnue
[Top][All Lists]
Advanced

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

gnue gnue-common/src/GObjects.py gnue-common/sr...


From: Jason Cater
Subject: gnue gnue-common/src/GObjects.py gnue-common/sr...
Date: Mon, 08 Oct 2001 08:38:14 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/10/08 08:38:14

Modified files:
        gnue-common/src: GObjects.py GParser.py 
        gnuef/src      : GFError.py GFEvent.py GFForm.py GFLibrary.py 
                         GFParser.py GFTrigger.py GFTriggerError.py 
        gnuef/src/GFObjects: GFBlock.py GFBox.py GFButton.py 
                             GFDataSource.py GFDatabase.py GFEntry.py 
                             GFLabel.py GFMsgBox.py GFOption.py 
        reports/samples/location: README zip-by-state.grd 
        reports/src    : GRLayout.py GRReport.py GRSortOptions.py 
                         GRSources.py 

Log message:
        * Updated GObject's new phaseInit system to
        automatically determine the number of phases
        necessary to do all the phaseInits (as opposed
        to defaulting to 5.)  The number of phases
        needed by an object is returned by _buildObject.
        
        * Updated Reports to use the new phaseInit system.
        
        * Modified reports/samples/location sample to use
        tables from forms/samples/zipcode instead of
        forms/samples/location.
        
        * Misc fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GObjects.py.diff?cvsroot=OldCVS&tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GParser.py.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFError.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFEvent.py.diff?cvsroot=OldCVS&tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFForm.py.diff?cvsroot=OldCVS&tr1=1.121&tr2=1.122&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFLibrary.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFParser.py.diff?cvsroot=OldCVS&tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFTrigger.py.diff?cvsroot=OldCVS&tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFTriggerError.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFBlock.py.diff?cvsroot=OldCVS&tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFBox.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFButton.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFDataSource.py.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFDatabase.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFEntry.py.diff?cvsroot=OldCVS&tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFLabel.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFMsgBox.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFOption.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/location/README.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/location/zip-by-state.grd.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRLayout.py.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRReport.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRSortOptions.py.diff?cvsroot=OldCVS&tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/src/GRSources.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/gnue-common/src/GObjects.py
diff -u gnue/gnue-common/src/GObjects.py:1.19 
gnue/gnue-common/src/GObjects.py:1.20
--- gnue/gnue-common/src/GObjects.py:1.19       Thu Sep 13 18:39:21 2001
+++ gnue/gnue-common/src/GObjects.py    Mon Oct  8 08:38:13 2001
@@ -13,7 +13,7 @@
 #
 # You should have received a copy of the GNU General Public 
 # License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # Copyright 2000, 2001 Free Software Foundation
@@ -29,14 +29,14 @@
 #
 import sys
 
-try: 
+try:
   from xml.sax import saxutils
-except ImportError: 
+except ImportError:
   print """
-   This GNUe tool requires PyXML to be installed. 
-   Please download and install PyXML from: 
+   This GNUe tool requires PyXML to be installed.
+   Please download and install PyXML from:
 
-      http://pyxml.sourceforge.net/ 
+      http://pyxml.sourceforge.net/
 
 """
   sys.exit()
@@ -66,7 +66,7 @@
   #
   # This will be the base of the new initialization system for gnue
   # each childs initialization function must call GObj.initialize()
-  # 
+  #
   #def initialize(self):
   #  GDebug.printMesg(6,"Initializing %s" % self.getObjectType())
   #  if self._children:
@@ -77,12 +77,10 @@
   #
   # phaseInit
   #
-  # TODO: Phase init should really get the size of the largest _inits
-  # TODO: array and use it instead of hardcoding 5 iterations
-  def phaseInit(self): 
-    for phase in range(5):
+  def phaseInit(self, iterations=5):
+    for phase in range(iterations):
       self._phaseInit(phase)
-      phase = phase + 1
+#      phase = phase + 1
 
   def _phaseInit(self,phase):
     if (len(self._inits) > phase) and (self._inits[phase] != None):
@@ -93,31 +91,33 @@
       for child in self._children:
         if isinstance(child, GObj):
           child._phaseInit(phase)
-    
+
 
   #
   # getObjectType
   #
   # Return the _type of this object
-  # 
+  #
   def getObjectType(self):
     return self._type
 
   # This function is called after the parsers have completely
-  # constructed. All children should be in place and 
+  # constructed. All children should be in place and
   # attributes and content should be set at this point.
+  # Return the number of phaseInit iterations your object will
+  # need.
   #
-  # NOTE: Do not initialize datasources, etc at this point. 
-  #       This is only so content can be set, etc, after 
-  #       loading from XML. 
-  #
-  def _buildObject(self): 
-    pass
-
-  def getChildrenAsContent(self): 
-    content = "" 
-    for child in self._children: 
-      if isinstance(child, GContent): 
+  # NOTE: Do not initialize datasources, etc at this point.
+  #       This is only so content can be set, etc, after
+  #       loading from XML.
+  #
+  def _buildObject(self):
+    return len(self._inits)
+
+  def getChildrenAsContent(self):
+    content = ""
+    for child in self._children:
+      if isinstance(child, GContent):
         content = content + child._content
     return content
 
Index: gnue/gnue-common/src/GParser.py
diff -u gnue/gnue-common/src/GParser.py:1.21 
gnue/gnue-common/src/GParser.py:1.22
--- gnue/gnue-common/src/GParser.py:1.21        Sun Oct  7 02:28:34 2001
+++ gnue/gnue-common/src/GParser.py     Mon Oct  8 08:38:13 2001
@@ -13,7 +13,7 @@
 #
 # You should have received a copy of the GNU General Public 
 # License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # Copyright 2000 Free Software Foundation
@@ -29,16 +29,16 @@
 # HISTORY:
 #
 
-try: 
+try:
   from xml.sax import saxexts
   from xml.sax import saxlib
   from xml.sax import saxutils
-except ImportError: 
+except ImportError:
   print """
-   This GNUe tool requires PyXML to be installed. 
-   Please download and install PyXML from: 
+   This GNUe tool requires PyXML to be installed.
+   Please download and install PyXML from:
 
-      http://pyxml.sourceforge.net/ 
+      http://pyxml.sourceforge.net/
 
 """
   sys.exit()
@@ -53,9 +53,9 @@
 #
 # loadXMLObject
 #
-# This method loads an object from an XML file and 
-# returns that object.  If initialize is 1 (default), 
-# then the object is initialized and ready to go. 
+# This method loads an object from an XML file and
+# returns that object.  If initialize is 1 (default),
+# then the object is initialized and ready to go.
 #
 # (initialize=0 is currently not used -- will probably
 #  be used in the Forms/Reports Designer package where
@@ -107,10 +107,10 @@
 
     # TODO: initializeTree is depreciated but left in here for
     # TODO: backwards compatibility.
-    if hasattr(object,'initializeTree'):
-      object.initializeTree()
-    else:
-      object.phaseInit()
+#    if hasattr(object,'initializeTree'):
+#      object.initializeTree()
+#    else:
+    object.phaseInit()
 
   return object
 
@@ -182,7 +182,8 @@
     self.bootstrapflag = 0
     self.uniqueIDs = {}
     self.root = None
-
+    self._phaseInitCount = 0
+    
   def getRoot(self):
     return self.root
 
@@ -278,7 +279,9 @@
   def endElement(self, name):
     self.nameStack.pop(0)
     child = self.xmlStack.pop(0)
-    child._buildObject()
+    inits = child._buildObject()
+    self._phaseInitCount = (inits != None and inits > self._phaseInitCount \
+                            and inits or self._phaseInitCount)
     GDebug.printMesg(50, "</%s>" % name)
 
 
@@ -302,19 +305,19 @@
   def getContent(self):
     return self._content
 
-  def toXML(self): 
+  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: 
+    else:
       return self._content
 
-  def showTree(self, indent=0): 
+  def showTree(self, indent=0):
     print ' '*indent + 'GContent ' + `self._content`
 
-  def getObjectType(self): 
+  def getObjectType(self):
     return "_content_"
 
   #
@@ -323,5 +326,5 @@
   # Return a useful description of this object
   # Used by designer clients
   #
-  def getDescription(self): 
+  def getDescription(self):
     return "(Content)"
Index: gnue/gnuef/src/GFError.py
diff -u gnue/gnuef/src/GFError.py:1.3 gnue/gnuef/src/GFError.py:1.4
--- gnue/gnuef/src/GFError.py:1.3       Fri Apr 20 21:22:51 2001
+++ gnue/gnuef/src/GFError.py   Mon Oct  8 08:38:13 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 class DBError:
   def __init__(self, value):
Index: gnue/gnuef/src/GFEvent.py
diff -u gnue/gnuef/src/GFEvent.py:1.16 gnue/gnuef/src/GFEvent.py:1.17
--- gnue/gnuef/src/GFEvent.py:1.16      Thu Jun  7 12:58:15 2001
+++ gnue/gnuef/src/GFEvent.py   Mon Oct  8 08:38:13 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 # FILE:
 # GFEvent.py
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.121 gnue/gnuef/src/GFForm.py:1.122
--- gnue/gnuef/src/GFForm.py:1.121      Thu Sep 27 00:32:52 2001
+++ gnue/gnuef/src/GFForm.py    Mon Oct  8 08:38:13 2001
@@ -7,7 +7,7 @@
 # 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 
+# 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.
 #
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 # FILE:
 # GFForm.py
@@ -97,6 +97,8 @@
           i = i + 1
       else:
         i = i + 1
+        
+    return GFObj._buildObject(self)
 
   #
   # primaryInit
Index: gnue/gnuef/src/GFLibrary.py
diff -u gnue/gnuef/src/GFLibrary.py:1.3 gnue/gnuef/src/GFLibrary.py:1.4
--- gnue/gnuef/src/GFLibrary.py:1.3     Thu Sep 13 18:39:22 2001
+++ gnue/gnuef/src/GFLibrary.py Mon Oct  8 08:38:13 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 # FILE:
 # GFLibrary
@@ -44,10 +44,11 @@
     GObj.__init__(self, parent, type=type)
     self._loadedxmlattrs = {} # Set by parser
 
-  def _buildObject(self): 
-    if hasattr(self,'_xmltag'): 
+  def _buildObject(self):
+    if hasattr(self,'_xmltag'):
       self._type = 'GF%s' % self._xmltag
-    if not hasattr(self,'_importclass'): 
+    if not hasattr(self,'_importclass'):
       self._importclass = GFParser\
          .getXMLelements()[string.lower(self._type[9:])][0]
+    return GObj._buildObject(self)
 
Index: gnue/gnuef/src/GFObjects/GFBlock.py
diff -u gnue/gnuef/src/GFObjects/GFBlock.py:1.17 
gnue/gnuef/src/GFObjects/GFBlock.py:1.18
--- gnue/gnuef/src/GFObjects/GFBlock.py:1.17    Wed Sep 19 15:32:34 2001
+++ gnue/gnuef/src/GFObjects/GFBlock.py Mon Oct  8 08:38:14 2001
@@ -75,11 +75,12 @@
 
     if hasattr(self, 'rows'):
       self._rows = self.rows
-      
+
     if hasattr(self, 'rowSpacer'):
       self._gap = self.rowSpacer
 
     self.walk(self.__setChildRowSettings)
+    return GFObj._buildObject(self)
 
   def initialize(self):
     self._form = self.findParentOfType('GFForm')
Index: gnue/gnuef/src/GFObjects/GFBox.py
diff -u gnue/gnuef/src/GFObjects/GFBox.py:1.2 
gnue/gnuef/src/GFObjects/GFBox.py:1.3
--- gnue/gnuef/src/GFObjects/GFBox.py:1.2       Wed Jul 18 18:45:01 2001
+++ gnue/gnuef/src/GFObjects/GFBox.py   Mon Oct  8 08:38:14 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000. 2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 #
 # FILE:
Index: gnue/gnuef/src/GFObjects/GFButton.py
diff -u gnue/gnuef/src/GFObjects/GFButton.py:1.2 
gnue/gnuef/src/GFObjects/GFButton.py:1.3
--- gnue/gnuef/src/GFObjects/GFButton.py:1.2    Wed Jul 18 18:45:01 2001
+++ gnue/gnuef/src/GFObjects/GFButton.py        Mon Oct  8 08:38:14 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000. 2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 #
 # FILE:
Index: gnue/gnuef/src/GFObjects/GFDataSource.py
diff -u gnue/gnuef/src/GFObjects/GFDataSource.py:1.8 
gnue/gnuef/src/GFObjects/GFDataSource.py:1.9
--- gnue/gnuef/src/GFObjects/GFDataSource.py:1.8        Wed Sep 19 01:27:44 2001
+++ gnue/gnuef/src/GFObjects/GFDataSource.py    Mon Oct  8 08:38:14 2001
@@ -12,8 +12,8 @@
 # PURPOSE. See the GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public 
-# License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # Copyright 2000, 2001 Free Software Foundation
@@ -62,6 +62,8 @@
     # TODO Removing for now - jamest
     #self._form._triggerns[self.name] = self._dataObject.triggerExtensions
 
+  # TODO: The linking of master to detail should occur in GDataSource
+  # TODO: as both Forms and Reports is executing basically the same code...
   def secondaryInit(self):
     if hasattr(self, 'master') and self.master:
       self.master = string.lower(self.master)
@@ -90,11 +92,11 @@
   def __setResultSet(self, resultSet):
     self._currentResultSet = resultSet
     # Notify all the listeners (i.e., blocks) that the result set changed
-    for listener in self._resultSetListeners: 
+    for listener in self._resultSetListeners:
       listener(resultSet)
-  
 
-  def registerResultSetListener(self, listener): 
+
+  def registerResultSetListener(self, listener):
     self._resultSetListeners.append(listener)
 
 
Index: gnue/gnuef/src/GFObjects/GFDatabase.py
diff -u gnue/gnuef/src/GFObjects/GFDatabase.py:1.6 
gnue/gnuef/src/GFObjects/GFDatabase.py:1.7
--- gnue/gnuef/src/GFObjects/GFDatabase.py:1.6  Mon Sep 17 22:43:31 2001
+++ gnue/gnuef/src/GFObjects/GFDatabase.py      Mon Oct  8 08:38:14 2001
@@ -46,6 +46,7 @@
     
   def _buildObject(self):
     self.name = string.lower(self.name)
+    return GFObj._buildObject(self)
 
   def initialize(self):
     # Add our database connection information to the connections
Index: gnue/gnuef/src/GFObjects/GFEntry.py
diff -u gnue/gnuef/src/GFObjects/GFEntry.py:1.19 
gnue/gnuef/src/GFObjects/GFEntry.py:1.20
--- gnue/gnuef/src/GFObjects/GFEntry.py:1.19    Wed Sep 19 15:32:34 2001
+++ gnue/gnuef/src/GFObjects/GFEntry.py Mon Oct  8 08:38:14 2001
@@ -87,6 +87,8 @@
       del self.lowercase
       self.case = 'lower'
 
+    return GFValue._buildObject(self)    
+
   def initialize(self):
     if self.typecast == 'number':
       self._numeric = 1
Index: gnue/gnuef/src/GFObjects/GFLabel.py
diff -u gnue/gnuef/src/GFObjects/GFLabel.py:1.7 
gnue/gnuef/src/GFObjects/GFLabel.py:1.8
--- gnue/gnuef/src/GFObjects/GFLabel.py:1.7     Sun Sep 16 17:16:24 2001
+++ gnue/gnuef/src/GFObjects/GFLabel.py Mon Oct  8 08:38:14 2001
@@ -8,15 +8,15 @@
 #
 # 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 
+# 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 
-# License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000. 2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 #
 # FILE:
@@ -52,6 +52,7 @@
     if not hasattr(self, 'rows') and hasattr(self,'visibleCount'):
       self.rows = self.visibleCount
       del self.visibleCount
+    return GFValue._buildObject(self)
 
   def setValue(self, value):
     if not self._value:
Index: gnue/gnuef/src/GFObjects/GFMsgBox.py
diff -u gnue/gnuef/src/GFObjects/GFMsgBox.py:1.2 
gnue/gnuef/src/GFObjects/GFMsgBox.py:1.3
--- gnue/gnuef/src/GFObjects/GFMsgBox.py:1.2    Wed Jul 18 18:45:01 2001
+++ gnue/gnuef/src/GFObjects/GFMsgBox.py        Mon Oct  8 08:38:14 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000. 2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 #
 # FILE:
Index: gnue/gnuef/src/GFObjects/GFOption.py
diff -u gnue/gnuef/src/GFObjects/GFOption.py:1.4 
gnue/gnuef/src/GFObjects/GFOption.py:1.5
--- gnue/gnuef/src/GFObjects/GFOption.py:1.4    Thu Sep 13 18:39:22 2001
+++ gnue/gnuef/src/GFObjects/GFOption.py        Mon Oct  8 08:38:14 2001
@@ -2,7 +2,7 @@
 # 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 
+# 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.
 #
@@ -16,9 +16,8 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000. 2001 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
-#
 # FILE:
 # GFObjects.py
 #
@@ -28,7 +27,6 @@
 # NOTES:
 #
 # HISTORY:
-# Copyright (c) 2000 Free Software Foundation
 #
 
 from gnue.common.GObjects import * 
@@ -42,11 +40,12 @@
     self.name = name
     self.value = value
 
-  def _buildObject(self): 
-    if self.value == None: 
+  def _buildObject(self):
+    if self.value == None:
       self.value = self.getChildrenAsContent()
-      self._children = [] 
-      
+      self._children = []
+    return GObj._buildObject(self)
+
 
 
 
Index: gnue/gnuef/src/GFParser.py
diff -u gnue/gnuef/src/GFParser.py:1.54 gnue/gnuef/src/GFParser.py:1.55
--- gnue/gnuef/src/GFParser.py:1.54     Tue Sep 18 23:23:20 2001
+++ gnue/gnuef/src/GFParser.py  Mon Oct  8 08:38:13 2001
@@ -12,11 +12,11 @@
 # PURPOSE. See the GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public 
-# License along with program; see the file COPYING. If not, 
+# License along with program; see the file COPYING. If not,
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 # FILE:
 # GFParser.py
Index: gnue/gnuef/src/GFTrigger.py
diff -u gnue/gnuef/src/GFTrigger.py:1.50 gnue/gnuef/src/GFTrigger.py:1.51
--- gnue/gnuef/src/GFTrigger.py:1.50    Sat Oct  6 14:34:47 2001
+++ gnue/gnuef/src/GFTrigger.py Mon Oct  8 08:38:13 2001
@@ -2,7 +2,7 @@
 # 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 
+# 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.
 #
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 #
 # FILE:
@@ -99,27 +99,28 @@
     self.language=language
     self._triggerns={}
     self.src = src
-    self.type = type  
+    self.type = type
     self.name = name
     self._inits   = [None,self.initialize]
-    if text != None: 
+    if text != None:
       GContent(self, text)
-    if self.type != None: 
+    if self.type != None:
       self._buildObject()
 
-  def _buildObject (self): 
+  def _buildObject (self):
     self.type=string.upper(self.type)
 
     # This is a hack for old forms that use "id" attr instead of "name"
-    if hasattr(self, 'id'): 
-      if self.name == None: 
+    if hasattr(self, 'id'):
+      if self.name == None:
         self.name = self.id
-      del self.__dict__['id']  
+      del self.__dict__['id']
+    return GObj._buildObject(self)
 
   #
   # Must be at least a phase 2 init
   #
-  def initialize(self): 
+  def initialize(self):
     self._form = self.findParentOfType('GFForm')
     self._triggerns.update( self._form._triggerns )
     self.__call__ = self.dummyFunction
Index: gnue/gnuef/src/GFTriggerError.py
diff -u gnue/gnuef/src/GFTriggerError.py:1.2 
gnue/gnuef/src/GFTriggerError.py:1.3
--- gnue/gnuef/src/GFTriggerError.py:1.2        Wed Apr 11 14:01:58 2001
+++ gnue/gnuef/src/GFTriggerError.py    Mon Oct  8 08:38:13 2001
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place 
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000 Free Software Foundation
+# Copyright 2000, 2001 Free Software Foundation
 #
 class TriggerError:
   def __init__(self, msg):
Index: gnue/reports/samples/location/README
diff -u gnue/reports/samples/location/README:1.1 
gnue/reports/samples/location/README:1.2
--- gnue/reports/samples/location/README:1.1    Tue May 29 22:23:38 2001
+++ gnue/reports/samples/location/README        Mon Oct  8 08:38:14 2001
@@ -1,2 +1,2 @@
 The examples in this directory use the tables defined in 
-the Forms samples/location/sql directory. 
+the Forms samples/zipcode directory. 
Index: gnue/reports/samples/location/zip-by-state.grd
diff -u gnue/reports/samples/location/zip-by-state.grd:1.5 
gnue/reports/samples/location/zip-by-state.grd:1.6
--- gnue/reports/samples/location/zip-by-state.grd:1.5  Wed Jun 20 06:45:59 2001
+++ gnue/reports/samples/location/zip-by-state.grd      Mon Oct  8 08:38:14 2001
@@ -2,18 +2,18 @@
 <report>
 
   <parameters> 
-    <parameter id="state" type="char" description="State"/> 
+    <parameter id="state_code" type="char" description="State"/> 
   </parameters>        
 
 
   <sortoptions> 
     <sortoption id="byZip" default="" description="By Zip Code, City Name">
-      <sortcolumn name="zipcode"/>
+      <sortcolumn name="zip"/>
       <sortcolumn name="city"/>
     </sortoption>
     <sortoption id="byCity" description="By City Name, Zip Code">
       <sortcolumn name="city"/>
-      <sortcolumn name="zipcode"/>
+      <sortcolumn name="zip"/>
     </sortoption>
   </sortoptions>
 
@@ -21,7 +21,7 @@
   <sources> 
     <datasource name="zips" database="gnue" table="zipcode"/>
     <datasource name="states" database="gnue" table="state" 
-       master="zips" detaillink="state" masterlink="state"/>
+       master="zips" detaillink="state" masterlink="state_code"/>
   </sources>
 
 
@@ -30,9 +30,9 @@
       ===========
       City: <field source="zips" name="city"/>
       <section name="zipdetail">
-        <field source="zips" name="zipcode"/>
+        <field source="zips" name="zip"/>
         <section name="statedetail" source="states">
-          <field source="states" name="description"/> (<field source="zips" 
name="state"/>)
+          <field source="states" name="description"/> (<field source="zips" 
name="state_code"/>)
         </section>
       </section>
       <default> 
Index: gnue/reports/src/GRLayout.py
diff -u gnue/reports/src/GRLayout.py:1.8 gnue/reports/src/GRLayout.py:1.9
--- gnue/reports/src/GRLayout.py:1.8    Sun Oct  7 02:28:35 2001
+++ gnue/reports/src/GRLayout.py        Mon Oct  8 08:38:14 2001
@@ -57,22 +57,25 @@
     GObj.__init__(self, parent, type='GRLayout')
 
 
-  def buildObject(self): 
-    # If there is more than one object attached to a layout 
+  def _buildObject(self):
+    # If there is more than one object attached to a layout
     # object, then create an unattached section to contain them.
-    if len(self._children) > 1: 
+    if len(self._children) > 1:
       temp = self._children
       self._children = []
       section = GRSection(self)
       section._children = temp
-      section.buildObject()
-    elif len(self._children) == 0: 
+      section._buildObject()
+    elif len(self._children) == 0:
       raise GRException.NoLayoutDefined, \
         "The layout section does not contain anything"
 
+    return GObj._buildObject(self)
+
+
   #
   # Prepare for running
-  # 
+  #
   def prepare(self, mapper, parameters):
 
     self._mapper = mapper
@@ -295,11 +298,11 @@
   def processDefault(self, dest, mapper): 
     structuralComment(dest,"<!--[default]-->")
     for child in self._children:
-      if child.getObjectType() == "_content_": 
+      if child.getObjectType() == "_content_":
         dest.write(child.getContent())
     structuralComment(dest,"<!--[/default]-->")
-    
-  def process(self, dest, mapper): 
+
+  def process(self, dest, mapper):
     pass
 
 
@@ -307,13 +310,13 @@
 #
 # <field> tag
 #
-class GRField (GRLayoutElement): 
+class GRField (GRLayoutElement):
   def __init__(self, parent):
     GRLayoutElement.__init__(self, parent, 'GRField')
     self._section = None
     self.format = None
 
-  def process(self, dest, mapper): 
+  def process(self, dest, mapper):
     structuralComment(dest,"<!--[field:%s]-->" % self.name)
     dest.write (self._mymapper.getField(self.name, self.format))
     structuralComment(dest,"<!--[/field:%s]-->" % self.name)
Index: gnue/reports/src/GRReport.py
diff -u gnue/reports/src/GRReport.py:1.10 gnue/reports/src/GRReport.py:1.11
--- gnue/reports/src/GRReport.py:1.10   Sun Oct  7 02:28:35 2001
+++ gnue/reports/src/GRReport.py        Mon Oct  8 08:38:14 2001
@@ -2,11 +2,11 @@
 # 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 
+# 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 
+# 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.
@@ -40,33 +40,37 @@
 import GRExceptions
 
 
-class GRReport(GObj): 
-  def __init__(self, parent=None): 
+class GRReport(GObj):
+  def __init__(self, parent=None):
     GObj.__init__(self, parent, type='GRReport')
     self._connections = None  # This will be set by GRParser.loadReport
+    self._inits = (self.initialize,)
+    self._datasourceDictionary = {}
 
-  def initializeTree(self): 
-    self.walk(self.buildDataSources)
-    self.initialize()
-
-  def buildDataSources(self, object): 
-    if object.getObjectType() == "GRDataSource": 
+  def initialize(self):
+    self.walk(self.__buildDataSources)
+    #self.initialize()
+
+  # TODO: Move into the datasource phaseInit
+  def __buildDataSources(self, object):
+    if object.getObjectType() == "GRDataSource":
       GDebug.printMesg(3,"Attaching DataSource %s to %s" \
-                         % (object.name, self._connections) )    
+                         % (object.name, self._connections) )
       object.setConnectionManager(self._connections)
+      self._datasourceDictionary[object.name] = object
 
   def dumpXML(self, treeDump=None, gap="  "):
     return GObj.dumpXML(self, \
         GRParser.xmlReportHandler().xmlElements, treeDump, gap)
+
 
-  
-  # 
+  #
   # Process the report and generate output per the report definition.
-  # Destination must be a file handle (StringIO will work as well) 
+  # Destination must be a file handle (StringIO will work as well)
   #
   def process(self, dest, userParameters={}, userSortOption=None, \
-      includeStructuralComments=0): 
- 
+      includeStructuralComments=0):
+
     import GRDataMapper
 
     # Connect to databases
@@ -83,10 +87,10 @@
     #
     # Raise exceptions if _sources or _parameters is None
     #
-    if sources == None: 
+    if sources == None:
       raise NoSourcesSection, "No <sources> section has been defined."
 
-    if layout == None: 
+    if layout == None:
       raise NoLayoutSection, "No <layout> section has been defined."
 
 
@@ -105,23 +109,23 @@
 
     # Write common header information
     dest.write ('<?xml version="1.0"?>\n')
-    dest.write ("<GNUe-report-output>\n") 
+    dest.write ("<GNUe-report-output>\n")
     dest.write ("  <GNUe-report-request>\n")
     dest.write ( parameters.getRunOptionsAsXML() )
-    dest.write ( sortoptions.getRunOptionsAsXML() ) 
+    dest.write ( sortoptions.getRunOptionsAsXML() )
     dest.write ("  </GNUe-report-request>\n")
 
     layout.process(dest, includeStructuralComments)
 
-    dest.write ("</GNUe-report-output>\n") 
+    dest.write ("</GNUe-report-output>\n")
 
 
 
-  def getChildOfType(self, type): 
+  def getChildOfType(self, type):
     rv = None
-    for child in self._children: 
-      if child.getObjectType() == type: 
-        rv = child 
+    for child in self._children:
+      if child.getObjectType() == type:
+        rv = child
         break
     return rv
 
Index: gnue/reports/src/GRSortOptions.py
diff -u gnue/reports/src/GRSortOptions.py:1.3 
gnue/reports/src/GRSortOptions.py:1.4
--- gnue/reports/src/GRSortOptions.py:1.3       Sun Oct  7 02:28:35 2001
+++ gnue/reports/src/GRSortOptions.py   Mon Oct  8 08:38:14 2001
@@ -34,58 +34,59 @@
 
 
 #
-# 
 #
-class GRSortOptions (GObj): 
+#
+class GRSortOptions (GObj):
 
-  def __init__(self, parent): 
+  def __init__(self, parent):
     GObj.__init__(self, parent, type='GRSortOptions')
     self._sortoption = None
     self._default = None
 
   #
-  # Return an xml markup of the user supplied or default  
+  # Return an xml markup of the user supplied or default
   # sort option used to run the current report
   #
-  def getRunOptionsAsXML(self): 
-    if self.getSortOption() == None: 
+  def getRunOptionsAsXML(self):
+    if self.getSortOption() == None:
       return ""
-    else: 
+    else:
       return '    <GNUe-request-sortoption id="%s"/>\n' % self.getSortOption()
 
   #
-  # Set the sort option to use 
+  # Set the sort option to use
   #
-  def setSortOption(self, sortoption): 
+  def setSortOption(self, sortoption):
     self._sortoption = sortoption
 
   #
   # Return the selected sort option
   #
-  def getSortOption(self): 
-    if self._sortoption != None: 
-      return self._sortoption 
-    else: 
+  def getSortOption(self):
+    if self._sortoption != None:
+      return self._sortoption
+    else:
       return self._default
 
+#
 #
-# 
 #
-class GRSortOption (GObj): 
-  def __init__(self, parent): 
+class GRSortOption (GObj):
+  def __init__(self, parent):
     GObj.__init__(self, parent, type='GRSortOption')
     self.default = 0
 
-  def buildObject(self): 
-    if self.default: 
+  def _buildObject(self):
+    if self.default:
       self._parent._default = self.id
+    return GObj._buildObject(self)
 
 
+#
 #
-# 
 #
-class GRSortColumn (GObj): 
-  def __init__(self, parent): 
+class GRSortColumn (GObj):
+  def __init__(self, parent):
     GObj.__init__(self, parent, type='GRSortColumn')
 
 
Index: gnue/reports/src/GRSources.py
diff -u gnue/reports/src/GRSources.py:1.4 gnue/reports/src/GRSources.py:1.5
--- gnue/reports/src/GRSources.py:1.4   Wed Jun  6 01:25:00 2001
+++ gnue/reports/src/GRSources.py       Mon Oct  8 08:38:14 2001
@@ -13,7 +13,7 @@
 #
 # You should have received a copy of the GNU General Public 
 # License along with program; see the file COPYING. If not, 
-# write to the Free Software Foundation, Inc., 59 Temple Place 
+# write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # Copyright 2000, 2001 Free Software Foundation
@@ -58,53 +58,86 @@
 
   # Used internally by self.prepare()
   # Connects to databases
-  def __initConnections(self, object): 
-    if object.getObjectType() == "GRDataSource": 
+  def __initConnections(self, object):
+    if object.getObjectType() == "GRDataSource":
       GDebug.printMesg(3,"Connecting DataSource %s to %s" \
-                         % (object.name, object.database) )    
+                         % (object.name, object.database) )
       object.connect()
       self._datasourceDictionary[object.name] = object
 
-  def __connectMasterDetail(self, object): 
-    if object.getObjectType() == "GRDataSource" and object.master != None: 
+  def __connectMasterDetail(self, object):
+    if object.getObjectType() == "GRDataSource" and object.master != None:
       GDebug.printMesg(3,"Linking detail '%s' to master '%s'" \
                          % (object.name, object.master) )
-      if self._datasourceDictionary.has_key(object.master): 
+      if self._datasourceDictionary.has_key(object.master):
         self._datasourceDictionary[object.master] \
-            .getDataObject().addDetailDataObject(object.getDataObject(), 
+            .getDataObject().addDetailDataObject(object.getDataObject(),
                                                  object)
-      else: 
+      else:
         raise GRExceptions.MasterSourceNotFound, \
            "Detail source '%s' references non-existant master '%s'" \
                          % (object.name, object.master)
 
-  def __setUserOptions(self, object): 
-    if object.getObjectType() == 'GRParam': 
-      object._value = self._parameters.getParameter(object.name) 
+  def __setUserOptions(self, object):
+    if object.getObjectType() == 'GRParam':
+      object._value = self._parameters.getParameter(object.name)
 
-#    if object.getObjectType() == 'GRSortOption': 
+#    if object.getObjectType() == 'GRSortOption':
 #      pass
 
 
-  def getDataSource(self, source): 
+  def getDataSource(self, source):
     return self._datasourceDictionary[source]
 
 
-class GRDataSource (GDataSource): 
+class GRDataSource (GDataSource):
   def __init__(self, parent):
     GDataSource.__init__(self, parent, 'GRDataSource')
     self.master = None
 
-  #  Used in GRSources.__connectMasterDetail to link detail datasource to 
+    self._inits =[self.primaryInit, self.secondaryInit]
+    self._currentResultSet = None
+    self._resultSetListeners = []
+
+  # Called by dbdrivers whenever this datasource's master has changed
+  def masterResultSetChanged(self, masterResultSet, detailResultSet):
+    self._masterResultSet = masterResultSet
+    self.__setResultSet( detailResultSet )
+
+  def primaryInit(self):
+    self._report = self.findParentOfType('GRReport')
+    GDebug.printMesg(10,"Setting %s to connect mgr %s" 
%(self.name,self._report._connections))
+    self.setConnectionManager(self._report._connections)
+    self.initialize()
+    self.connect()
+
+  # TODO: The linking of master to detail should occur in GDataSource
+  # TODO: as both Forms and Reports is executing basically the same code...
+  def secondaryInit(self):
+    if hasattr(self, 'master') and self.master:
+      self.master = string.lower(self.master)
+      GDebug.printMesg(3,"Linking detail '%s' to master '%s'" \
+                         % (self.name, self.master) )
+
+      if self._report._datasourceDictionary.has_key(self.master):
+        self._report._datasourceDictionary[self.master] \
+            .getDataObject().addDetailDataObject(self.getDataObject(),
+                                                 self)
+      else:
+        raise StandardError, \
+           "Detail source '%s' references non-existant master '%s'" \
+                         % (self.name, self.master)
+
+  #  Used in GRSources.__connectMasterDetail to link detail datasource to
   #  master source.  Called by GDataObjects.ResultSet when master changed
-  #  This will actually be over-written by GRDataMapper but at the time 
-  #  the master-detail must be linked, the GRDataMapper will not have been 
+  #  This will actually be over-written by GRDataMapper but at the time
+  #  the master-detail must be linked, the GRDataMapper will not have been
   #  created yet.  [Yes, it's fugly]
-  def masterResultSetChanged(self, masterResultSet, detailResultSet): 
+  def masterResultSetChanged(self, masterResultSet, detailResultSet):
     pass
 
-class GRConditions(GCondition): 
-  def __init__(self, parent): 
-    GCondition.__init__(self, parent, 'GRCondition') 
+class GRConditions(GCondition):
+  def __init__(self, parent):
+    GCondition.__init__(self, parent, 'GRCondition')
 
 



reply via email to

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