commit-gnue
[Top][All Lists]
Advanced

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

gnue gnue-common/src/GDataObjects.py gnue-commo...


From: James Thompson
Subject: gnue gnue-common/src/GDataObjects.py gnue-commo...
Date: Thu, 19 Jul 2001 14:49:57 -0700

CVSROOT:        /cvs
Module name:    gnue
Branch:         gnuef-new-datasources
Changes by:     James Thompson <address@hidden> 01/07/19 14:49:57

Modified files:
        gnue-common/src: GDataObjects.py GDataSource.py GObjects.py 
                         GParser.py 
        gnuef          : TODO 
        gnuef/src      : GFForm.py GFTrigger.py 
        gnuef/src/GFObjects: GFBlock.py GFDataSource.py GFEntry.py 
                             GFLabel.py 

Log message:
        Implemented phaseInit - makes it possible to have multiple 
initialization phases of the GObj tree
        Added some wrappers to GDataSource so the programmer can ignore the 
GDataObject it contains

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GDataObjects.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.7.2.3&tr2=1.7.2.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GDataSource.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.11.2.1&tr2=1.11.2.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GObjects.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.15&tr2=1.15.2.1&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GParser.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.18.2.1&tr2=1.18.2.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/TODO.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.55.2.1&tr2=1.55.2.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFForm.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.110.2.5&tr2=1.110.2.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFTrigger.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.40.2.2&tr2=1.40.2.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFBlock.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.4.2.4&tr2=1.4.2.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFDataSource.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.3.2.3&tr2=1.3.2.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFEntry.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.2.2.3&tr2=1.2.2.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFObjects/GFLabel.py.diff?cvsroot=OldCVS&only_with_tag=gnuef-new-datasources&tr1=1.1.2.2&tr2=1.1.2.3&r1=text&r2=text

Patches:
Index: gnue/gnue-common/src/GDataObjects.py
diff -u gnue/gnue-common/src/GDataObjects.py:1.6 
gnue/gnue-common/src/GDataObjects.py:1.7
--- gnue/gnue-common/src/GDataObjects.py:1.6    Tue May 29 19:54:11 2001
+++ gnue/gnue-common/src/GDataObjects.py        Tue Jun  5 08:57:45 2001
@@ -127,8 +127,8 @@
     criteria = {}
     for i in range(0, len(self._masterfields)): 
       GDebug.printMesg(10,"Adding criteria")
-      criteria[string.trim(self._detailfields[i])] = \
-          master.current.getField(string.trim(self._masterfields[i]))
+      criteria[string.strip(self._detailfields[i])] = \
+          master.current.getField(string.strip(self._masterfields[i]))
       GDebug.printMesg(10,master.current.getField(self._masterfields[i]))
     return self.createResultSet(criteria)
 
Index: gnue/gnue-common/src/GDataSource.py
diff -u gnue/gnue-common/src/GDataSource.py:1.10 
gnue/gnue-common/src/GDataSource.py:1.11
--- gnue/gnue-common/src/GDataSource.py:1.10    Tue Jun 26 21:18:28 2001
+++ gnue/gnue-common/src/GDataSource.py Wed Jul  4 17:24:11 2001
@@ -34,6 +34,7 @@
 import GObjects 
 import sys
 import GConnections
+import GTypecast
 
 
 ########################################################################
@@ -105,27 +106,27 @@
             'name':        {
                'Required': 1, 
                'Unique':   1, 
-               'Typecast': char }, 
+               'Typecast': GTypecast.name }, 
             'type':        {
-               'Typecast': char, 
+               'Typecast': GTypecast.name, 
                'Default':  "object" }, 
             'database':    {
-               'Typecast': char }, 
+               'Typecast': GTypecast.name }, 
             'table':       {
-               'Typecast': char }, 
+               'Typecast': GTypecast.name }, 
             'cache':       {
-               'Typecast': int },
+               'Typecast': GTypecast.whole },
             'prequery':    {
                'Typecast': bool, 
                'Default':  0 },
             'order_by':    {
-               'Typecast': char }, 
+               'Typecast': GTypecast.text }, 
             'master':      {
-               'Typecast': char }, 
+               'Typecast': GTypecast.name }, 
             'masterlink':  {
-               'Typecast': char }, 
+               'Typecast': GTypecast.text }, 
             'detaillink':  {
-               'Typecast': char } }
+               'Typecast': GTypecast.text } }
 
 
 
Index: gnue/gnue-common/src/GObjects.py
diff -u gnue/gnue-common/src/GObjects.py:1.14 
gnue/gnue-common/src/GObjects.py:1.15
--- gnue/gnue-common/src/GObjects.py:1.14       Wed Jul  4 17:24:11 2001
+++ gnue/gnue-common/src/GObjects.py    Thu Jul  5 10:52:42 2001
@@ -139,6 +139,8 @@
     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] == "_":
@@ -152,13 +154,19 @@
           typecast = lookupDict[xmlEntity]['Attributes'][attribute]['Typecast']
           if typecast == GTypecast.boolean \
              and val == 1:
-            xmlString = xmlString + ' %s=""' % (attribute)
+            addl = ' %s=""' % (attribute)
           elif typecast == GTypecast.names:
-            xmlString = xmlString + ' %s="%s"' % \
+            addl = ' %s="%s"' % \
                 (attribute, string.join(val,','))
           else: 
-            xmlString = xmlString + ' %s="%s"' % (attribute, 
saxutils.escape('%s' % val))
-        
+            addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % val))
+          if len(addl) + pos > 78: 
+            xmlString = xmlString + "\n" + " " * indent + addl
+            pos = indent
+          else: 
+            xmlString = xmlString + addl
+            pos = pos + len(addl)
+
     if len(self._children): 
       hasContent = 0 
       for child in self._children: 
@@ -179,7 +187,6 @@
     else: 
       xmlString = xmlString + "/>\n"      
     return xmlString
-
 
 
   def walk(self, function):
Index: gnue/gnue-common/src/GParser.py
diff -u gnue/gnue-common/src/GParser.py:1.17 
gnue/gnue-common/src/GParser.py:1.18
--- gnue/gnue-common/src/GParser.py:1.17        Fri Jun 29 15:55:58 2001
+++ gnue/gnue-common/src/GParser.py     Wed Jul  4 17:24:11 2001
@@ -46,6 +46,7 @@
 import string
 import sys
 import GDebug
+import GTypecast
 
 
 #######################################################
@@ -114,10 +115,13 @@
 #
 # This is for typecasting strings
 #
+# NOTE: This is a redefinition of GTypecast.text.
+#   This redefinition will be removed as soon as all
+#   references to it are changes.  You should be using
+#   GTypecast from now on.
+#
 #######################################################
-def char (value): 
-  # Do we convert '&lt;',etc stuff here?
-  return str(value)
+char  = GTypecast.text
 
 
 #######################################################
@@ -126,18 +130,13 @@
 #
 # This is for typecasting booleans
 #
+# NOTE: This is a redefinition of GTypecast.boolean. 
+#   This redefinition will be removed as soon as all
+#   references to it are changes.  You should be using
+#   GTypecast from now on. 
+#
 #######################################################
-def bool (value): 
-  if value == 0 or value == 1: 
-    return value
-
-  rv = string.lower(string.strip(value))
-  if len(rv): 
-    return not (rv[0] == 'n' or rv[0] == 'f' or rv == '0')
-  else: 
-    # This may seem counter-intuitive, but if attribute was present 
-    # without a specified value, then treat as true
-    return 1
+bool = GTypecast.boolean
 
 
 #######################################################
Index: gnue/gnuef/TODO
diff -u gnue/gnuef/TODO:1.56 gnue/gnuef/TODO:1.57
--- gnue/gnuef/TODO:1.56        Thu Jul 12 08:52:48 2001
+++ gnue/gnuef/TODO     Mon Jul 16 20:09:41 2001
@@ -84,7 +84,6 @@
 
 
 Features
-  Goto record shortcut
   Input masks 
   Mirrored Fields 
 
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.112 gnue/gnuef/src/GFForm.py:1.113
--- gnue/gnuef/src/GFForm.py:1.112      Thu Jul 12 20:56:13 2001
+++ gnue/gnuef/src/GFForm.py    Mon Jul 16 20:09:41 2001
@@ -783,6 +783,16 @@
             return message
     self._currentBlock.nextRecord()
 
+  def jumpRecord(self,count):
+    for block in self._blockList:
+      if hasattr(block,'master'):
+        masterBlock,masterField = string.split(block.master,'.')
+        if masterBlock == self._currentBlock.name:
+          if not block.isSaved():
+            message = GConfig.get('_msgNOTSAVED')
+            return message
+    self._currentBlock.jumpRecord(count)
+
 
   def toggleInsertMode(self):
     self._insertMode = not self._insertMode
Index: gnue/gnuef/src/GFObjects/GFBlock.py
diff -u gnue/gnuef/src/GFObjects/GFBlock.py:1.5 
gnue/gnuef/src/GFObjects/GFBlock.py:1.6
--- gnue/gnuef/src/GFObjects/GFBlock.py:1.5     Mon Jul 16 20:09:41 2001
+++ gnue/gnuef/src/GFObjects/GFBlock.py Wed Jul 18 15:45:01 2001
@@ -31,8 +31,7 @@
 # Copyright (c) 2000 Free Software Foundation
 #
 
-from gnue.common.GObjects import * 
-from gnue.common.dbdrivers.factory import factory
+#from gnue.common.GObjects import * 
 from gnue.forms.GFEvent import *
 from gnue.forms.GFObjects.GFDataSource import GFDataSource
 
@@ -41,7 +40,6 @@
 from GFObj import GFObj
 
 import string
-import types
 
 # These should really go somewhere else
 TRUE = 1
Index: gnue/gnuef/src/GFObjects/GFDataSource.py
diff -u gnue/gnuef/src/GFObjects/GFDataSource.py:1.3 
gnue/gnuef/src/GFObjects/GFDataSource.py:1.4
--- gnue/gnuef/src/GFObjects/GFDataSource.py:1.3        Wed Jul 11 16:06:46 2001
+++ gnue/gnuef/src/GFObjects/GFDataSource.py    Tue Jul 17 06:43:09 2001
@@ -188,31 +188,23 @@
   def commit(self):
     if hasattr(self,'database'):
       for count in range(len(self.resultSet)):
-        GDebug.printMesg(2, "record %s is %s \n %s" % (count, 
self.resultSetStatus[count],self.resultSet[count]))
-        mask = {}
-        for key in self.resultSet[count].keys():
-          if key in self.dataConnection.getFieldList(self.table).keys() or \
-             key == self.uniqueKey:
-            mask[key]=self.resultSet[count][key]
+        if self.resultSetStatus[count] in ('modified', 'deleted'):
+          GDebug.printMesg(2, "record %s is %s \n %s" % (count, 
self.resultSetStatus[count],self.resultSet[count]))
+          mask = {}
+          for key in self.resultSet[count].keys():
+            if key in self.dataConnection.getFieldList(self.table).keys() or \
+               key == self.uniqueKey:
+              mask[key]=self.resultSet[count][key]
 
-        GDebug.printMesg(10, "will be passing\n%s"% mask)
+          GDebug.printMesg(10, "will be passing\n%s"% mask)
                                                   
-        if self.resultSetStatus[count] in ('modified', 'deleted'):
           if self.resultSet[count].has_key(self.uniqueKey):
             if self.resultSetStatus[count]  == 'modified':
-              # record never in database so just mark for cleanup
-              # self.resultSet[count][self.uniqueKey] = -1
-              
-              # elif self.resultSet[count][self.uniqueKey] > 0:
               GDebug.printMesg(1, "updating the record")
               self.dataConnection.update(self.table,mask)
             else:
               GDebug.printMesg(1,"deleting the record")
-              #mask[self.uniqueKey] = \
-              #  mask[self.uniqueKey] * -1
               self.dataConnection.delete(self.table,mask)
-              # flip negative again so upcomming list purge see's the negatives
-              #mask[self.uniqueKey] = -1
               
           else:
             GDebug.printMesg(1, "Inserting the record")
Index: gnue/gnuef/src/GFObjects/GFEntry.py
diff -u gnue/gnuef/src/GFObjects/GFEntry.py:1.5 
gnue/gnuef/src/GFObjects/GFEntry.py:1.6
--- gnue/gnuef/src/GFObjects/GFEntry.py:1.5     Mon Jul 16 20:09:41 2001
+++ gnue/gnuef/src/GFObjects/GFEntry.py Wed Jul 18 15:45:01 2001
@@ -31,18 +31,10 @@
 # Copyright (c) 2000 Free Software Foundation
 #
 
-from gnue.common.GObjects import * 
-from gnue.common.dbdrivers.factory import factory
-
 from gnue.common import GDebug
 from gnue.common import GConfig
 from GFValue import GFValue
 import string
-import types
-
-# These should really go somewhere else
-TRUE = 1
-FALSE = 0
 
 ############################################################
 # GFEntry
Index: gnue/gnuef/src/GFObjects/GFLabel.py
diff -u gnue/gnuef/src/GFObjects/GFLabel.py:1.2 
gnue/gnuef/src/GFObjects/GFLabel.py:1.3
--- gnue/gnuef/src/GFObjects/GFLabel.py:1.2     Mon Jul 16 20:09:41 2001
+++ gnue/gnuef/src/GFObjects/GFLabel.py Wed Jul 18 15:45:01 2001
@@ -31,21 +31,9 @@
 # Copyright (c) 2000 Free Software Foundation
 #
 
-from gnue.common.GObjects import * 
-from gnue.common.dbdrivers.factory import factory
-
-from gnue.common import GDebug
 from gnue.common import GConfig
 from GFValue import GFValue
 
-import string
-import types
-
-
-# These should really go somewhere else
-TRUE = 1
-FALSE = 0
-
 #
 #GFLabel
 #
@@ -59,7 +47,6 @@
   def setValue(self, value):
     if not self._value:
       GFValue.setValue(self,value)
-
 
   def initialize(self):
     self._block = self.findParentOfType('GFBlock')
Index: gnue/gnuef/src/GFTrigger.py
diff -u gnue/gnuef/src/GFTrigger.py:1.41 gnue/gnuef/src/GFTrigger.py:1.42
--- gnue/gnuef/src/GFTrigger.py:1.41    Thu Jul 12 20:56:13 2001
+++ gnue/gnuef/src/GFTrigger.py Wed Jul 18 15:45:01 2001
@@ -29,7 +29,6 @@
 #
 
 import sys
-#from GFObjects import *
 from GFEvent import *
 from GFTriggerError import *
 from gnue.common.GParser import GContent



reply via email to

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