commit-gnue
[Top][All Lists]
Advanced

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

gnue/gnuef TODO src/DBobjectserver.py src/DBpos...


From: James Thompson
Subject: gnue/gnuef TODO src/DBobjectserver.py src/DBpos...
Date: Sat, 07 Oct 2000 22:37:53 -0700

CVSROOT:        /cvs
Module name:    gnue
Changes by:     James Thompson <address@hidden> 00/10/07 22:37:52

Modified files:
        gnuef          : TODO 
        gnuef/src      : DBobjectserver.py DBpostgresql.py GFClient.py 
                         GFController.py GFEvent.py GFForm.py 
                         GFGetOpt.py GFObjects.py UIbase.py 
                         UIwxpython.py 
Removed files:
        gnuef/src      : stack.py 

Log message:
        Clean up of some of the code base
        Added code comments
        Fixed null object in formToUI bug
        Removed unneeded files
        Updated TODO

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/TODO.diff?r1=1.6&r2=1.7
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/DBobjectserver.py.diff?r1=1.1&r2=1.2
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/DBpostgresql.py.diff?r1=1.3&r2=1.4
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFClient.py.diff?r1=1.12&r2=1.13
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFController.py.diff?r1=1.5&r2=1.6
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFEvent.py.diff?r1=1.5&r2=1.6
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFForm.py.diff?r1=1.15&r2=1.16
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFGetOpt.py.diff?r1=1.1&r2=1.2
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFObjects.py.diff?r1=1.12&r2=1.13
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/UIbase.py.diff?r1=1.4&r2=1.5
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/UIwxpython.py.diff?r1=1.8&r2=1.9
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/stack.py.diff?r1=1.1&r2=NONE

Patches:
Index: gnue/gnuef/TODO
diff -u gnue/gnuef/TODO:1.6 gnue/gnuef/TODO:1.7
--- gnue/gnuef/TODO:1.6 Sat Oct  7 17:03:40 2000
+++ gnue/gnuef/TODO     Sat Oct  7 22:37:52 2000
@@ -6,10 +6,6 @@
 
   fill in todo list (easy as there is a lot of DOs to TO) [everyone]
 
-  replace list stacks in the various files with a true 
-    stack class - initial stack.py written but not implemented or tested
-    (easy) [no one]
-
   Convert the form and view to support auto ajustment of grid system 
     to text based instead of pixel based (hard)
 
@@ -49,8 +45,15 @@
     sending info like current record count/status to UI
   
     add attribute system (hidden, uppercase, numeric, entry mask, etc, etc)
-
-
 
+  Add code to make a GUI startup failure roll into a text mode attempt
 
+  Move things like database init in GFForm out of __init__ and 
+  into a initialize routine that is called via some type of 
+  uiINITIALIZED event so that a UI windows can prompt for things
+  like name/password.  
+
+  move initialize function into the base object and have them
+  call the initializes of their children so we can get rid of 
+  more of the self.walk nonsense
 
Index: gnue/gnuef/src/DBobjectserver.py
diff -u gnue/gnuef/src/DBobjectserver.py:1.1 
gnue/gnuef/src/DBobjectserver.py:1.2
--- gnue/gnuef/src/DBobjectserver.py:1.1        Fri Oct  6 19:02:01 2000
+++ gnue/gnuef/src/DBobjectserver.py    Sat Oct  7 22:37:52 2000
@@ -13,6 +13,7 @@
 #
 
 import sys
+
 try:
   import CORBA
 except ImportError,ex:
@@ -45,7 +46,6 @@
   def disconnect(self):
       self.database.disconnect();
       self.database.release();
-
         
   def execQuery(self):
       self.resultSet = self.database.loadAll( self.tableName );
Index: gnue/gnuef/src/DBpostgresql.py
diff -u gnue/gnuef/src/DBpostgresql.py:1.3 gnue/gnuef/src/DBpostgresql.py:1.4
--- gnue/gnuef/src/DBpostgresql.py:1.3  Sat Oct  7 17:03:41 2000
+++ gnue/gnuef/src/DBpostgresql.py      Sat Oct  7 22:37:52 2000
@@ -12,20 +12,19 @@
 # Copyright (c) 2000 James Thompson
 #
 
-import GFOptions
 import pg
 import string
+import GFOptions
 
 class DBpostgresql:
   def __init__(self):
     if GFOptions.DEBUG:
       print "Postgresql database driver initializing"
     self.connection = None
-    
+
   def connect(self, host, dbname, user, passwd):
     if GFOptions.DEBUG:
       print "connecting"
-
     self.connection = pg.DB(dbname, host, -1, None, None, user, passwd)
     
   def disconnect(self):
@@ -40,47 +39,38 @@
 
   def insert(self,table,mask):
     self.connection.insert(table,mask)
-    print "returning mask"
-    print mask
     return mask
   
   def delete(self,table,mask):
     self.connection.delete(table,mask)
 
   def update(self,table,mask):
-    print "Updating %s " % (table)
-    print mask
     mask = self.connection.update(table,mask)
 
-  def query(self,table,mask):
-    print "database received this mask"
-    print mask
-    command = self.constructSQL('query',table, mask)
-    resultset = self.connection.query(command).dictresult()
-    return resultset
-
   def getFieldList(self,table):
     return self.connection.get_attnames(table)
 
-  def getResults(self):
+  #
+  # The code below has been written to be compatible with
+  # PyGreSql-3.0 wrapper functions.  And shoud eventually
+  # be offered back to PyGreSql maintainer for inclusion
+  # in that package (if they want it :)
+  #
+  def query(self,table,mask):
+    command = self.constructSQL('query',table, mask)
+    resultset = self.connection.query(command).dictresult()
     return resultset
-
+  
   def constructSQL(self, style, table, mask = None):
     sql = None
     fields = None
     qualifier = None
 
-    print "constructSQL here and I got a "
-    print mask
-    
     if style == 'query':
       action = "SELECT "
       location = "FROM %s " % (table)
       fields = " oid AS oid_%s, * " % (table)
       
-      # is this a better way
-      #fields = " oid AS oid_%s, %s " % (table, type(mask) == type({}) and 
string.join(mask.keys(), ',') or '*')
-      
       if type(mask) == type({}):
         fields = " oid AS oid_%s, %s " % (table, string.join(mask.keys(), ','))
         for fieldname in mask.keys():
@@ -90,8 +80,8 @@
             else:
               qualifier = "%s AND %s LIKE  '%s'" % (qualifier, 
fieldname,mask[fieldname])
       
-      sql = action + fields + location + (qualifier and qualifier or "")    
-
+      sql = action + fields + location + (qualifier and qualifier or "")
+      
     else:
       print "constructSQL: unsupport SQL statement type"
 
Index: gnue/gnuef/src/GFClient.py
diff -u gnue/gnuef/src/GFClient.py:1.12 gnue/gnuef/src/GFClient.py:1.13
--- gnue/gnuef/src/GFClient.py:1.12     Tue Oct  3 22:04:58 2000
+++ gnue/gnuef/src/GFClient.py  Sat Oct  7 22:37:52 2000
@@ -11,70 +11,48 @@
 # HISTORY:
 # Copyright (c) 2000 James Thompson
 #
+import os
 import sys
 import urllib
-import os
 import GFOptions
 from GFGetOpt import *
 from GFForm import *
 from GFController import *
 
-class GFClient:
-  def __init__(self):
-    self.version="0.0.2"
+_version = "0.0.2"
 
-  def run(self):
-    # The last argument is the URL of the form
-    if len(sys.argv) < 2 :
-      print "You must define a forms definition file.  Use GFClient.py -h for 
more information."
-      sys.exit()
-    else:
-      CmdOpt = GFGetOpt()
-      CmdOpt.parseOptions(sys.argv)
-      ui_type = CmdOpt.getOption('user_interface')#user interface
-      GFOptions.DEBUG = CmdOpt.getOption('debug_level')#debugging
-      help = CmdOpt.getOption('help')#display man page
-      version = CmdOpt.getOption('version')#display version information
-
-      if GFOptions.DEBUG:
-        print "Debug level =",GFOptions.DEBUG
-        
-      #assign form file from 1st free argument
-      try:
-        self.formfile = CmdOpt.getArgument(0) 
-      except:
-        if help :
-          # help -> this should really read a man page
-          if help == 1 :
-            print """
-Usage: GFClient.py [-h] [--help] [-d level] [--debug=level]
-      [-u uiType] [--user_interface=uiType] [-v] [--version]
+_usage = """
+Usage: %s [-h] [--help] [-d level] [--debug=level] \\
+       [-u uiType] [--user_interface=uiType] [-v] [--version]
+
+Supported uiTypes : gui, text
+
 Report bugs to address@hidden
-            """
-            sys.exit()
-        elif version ==1 :
-          # version information 
-          print "GFClient v%s" % (self.version)
-          sys.exit()
-        else:
-          print "No Forms Definition File Specified.  Use GFClient -h for more 
information."
-          sys.exit()
-
-    # user interface type defaulting to gui currently
-    if ui_type == 'gui' :
-      self.ui = 'WXPYTHON'
-    elif ui_type == 'text' :
-      self.ui = 'PYNCURSES'
-    elif ui_type == 'java' :
-      print "JForms is on its way."
-      sys.exit()
-    elif ui_type == 'xul' :
-      print "XULForms is being considered."
+"""
+
+class GFClient:
+  def run(self):
+    # Parse command line options
+    CmdOpt = GFGetOpt()
+    CmdOpt.parseOptions(sys.argv)
+    ui_type = CmdOpt.getOption('user_interface')
+    GFOptions.DEBUG = CmdOpt.getOption('debug_level')
+    help = CmdOpt.getOption('help')
+    version = CmdOpt.getOption('version')
+
+    if GFOptions.DEBUG:
+      print "Debug level =",GFOptions.DEBUG
+            
+    # assign form file from 1st free argument
+    try:
+      self.formfile = CmdOpt.getArgument(0) 
+    except:
+      if help : print _usage % (sys.argv[0])
+      elif version : print "%s v%s" % (sys.argv[0], _version)
+      else: print "No Forms Definition File Specified.  Use GFClient -h for 
more information."
       sys.exit()
 
-    #
     # build the form object
-    #
     try:
       fp = urllib.urlopen(self.formfile)
     except:
@@ -83,16 +61,16 @@
     form = GFForm(fp)
     fp.close()
 
-    # determine the UI to use
-    if self.ui == 'PYNCURSES' :
-      import UIpyncurses
-      ui=UIpyncurses.GFUserInterface(form)
-
-    elif self.ui == 'WXPYTHON' :
+    # Initialize user interface (defaults to gui)
+    if ui_type == 'gui'  :
       import UIwxpython
       ui=UIwxpython.GFUserInterface(form)
+
+    if ui_type == 'text' : 
+      import UIpyncurses
+      ui=UIpyncurses.GFUserInterface(form)
 
-    #register events
+    # register event controller
     control = GFController(form, ui)
     
     # pass control to UI
Index: gnue/gnuef/src/GFController.py
diff -u gnue/gnuef/src/GFController.py:1.5 gnue/gnuef/src/GFController.py:1.6
--- gnue/gnuef/src/GFController.py:1.5  Sun Aug 27 20:06:37 2000
+++ gnue/gnuef/src/GFController.py      Sat Oct  7 22:37:52 2000
@@ -22,42 +22,10 @@
     GFEventAware.__init__(self)
     self.form = form
     self.ui = ui
-##    self.incommingEvent = {'requestNEXTPAGE' : self.nextPage,
-##                           'requestPREVPAGE' : self.previousPage,
-##                           'requestKEYPRESS' : self.keyPress,
-##                           'requestHOTKEY'   : self.hotKey,
-##                           'requestNEXTENTRY': self.nextEntry,
-##                           'gotoNEXTENTRY'   : self.gotoNextEntry
-##                           }
 
-##    self.formEvents = {'gfNEXTENTRY': self.changeViewFocus}
-
     ui.registerEventListener(form.processEvent)
     form.registerEventListener(ui.processEvent)
 
-##  def previousPage(self, event):
-##    pass
-
-##  def nextPage(self, event):
-##    self.ui.nextPage()
-    
-##  def keyPress(self, event):
-##    print event.data
-    
-##  def nextEntry(self, event):
-##    self.form.nextEntry()
-
-##  def gotoNextEntry(self,event):
-##    self.ui.nextPage()
-
-##  def changeViewFocus(self, event):
-##    self.ui.switchFocus(self.form.currentEntry)
-    
-##  def hotKey(self, event):
-##    print "Control key", event.data
-
-          
-          
 
 
 
Index: gnue/gnuef/src/GFEvent.py
diff -u gnue/gnuef/src/GFEvent.py:1.5 gnue/gnuef/src/GFEvent.py:1.6
--- gnue/gnuef/src/GFEvent.py:1.5       Fri Oct  6 19:02:01 2000
+++ gnue/gnuef/src/GFEvent.py   Sat Oct  7 22:37:52 2000
@@ -9,7 +9,6 @@
 # HISTORY:
 # Copyright (c) 2000 James Thompson
 #
-
 import GFOptions
 
 #
@@ -23,11 +22,9 @@
   def getEvent(self):
     return self.event
 
-
 #
 # Base for and object that sends and receives events
 #
-
 class GFEventAware:
   def __init__(self):
     self.eventListener = []
@@ -51,7 +48,6 @@
     for function in self.eventListener:
       function(event)
               
-
   #
   # processEvent
   #
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.15 gnue/gnuef/src/GFForm.py:1.16
--- gnue/gnuef/src/GFForm.py:1.15       Sat Oct  7 15:11:59 2000
+++ gnue/gnuef/src/GFForm.py    Sat Oct  7 22:37:52 2000
@@ -51,7 +51,7 @@
                            'requestCOMMIT'     : self.executeCommit,
 
                            'recordSWITCHED'    : self.recordSwitched,
-
+                           'notifyMASTERSWITCH': self.notifyDetailBlocks,
 #                           'requestLOGIN'     : self.requestLogin,
                            'uiINITIALIZED'     : self.uiInitialized
 
@@ -107,7 +107,6 @@
   # routines that are used by the walk() method
   # suggesting a better way probably exists :)
   #
-    
   def setInitialFocus(self, object):
     if object.getObjectType() == 'GFBlock' and self.currentBlock == None:
       self.currentBlock = object
@@ -125,7 +124,7 @@
     if object.getObjectType() == 'GFEntry':
       object.initialize()
       object.value = object.block.dataSourceLink.getField(0,object.field)
-      
+
   def initDatabaseObjects(self, object):
     if object.getObjectType() =='GFDataSource':
       self.datasourceDictionary[object.name]=object
@@ -150,23 +149,26 @@
   # end of routines made for walking
   #
 
+  def findValue(self, blockname, fieldname):
+    for block in self.blockList:
+      if block.name == blockname:
+        for entry in block.entryList:
+          if entry.name == fieldname:
+            print "block %s with field %s found" % (block.name, entry.name)
+            value = entry.value
+            return value
+    return None
+      
   def toggleInsertMode(self,event):
-    if self.insertMode == 1:
-      self.insertMode = 0
-    else:
-      self.insertMode = 1
+    self.insertMode = not self.insertMode
 
-  #
-  # Event handlers
   #
-  # Methods called to deal with incomming events
+  # Incomming Event handlers
   #
 
   #
-  # nextRecord, prevRecord, newRecord
-  #
   # Mini functions that pass events on to lower level
-  # objects.  Will eventually do more
+  # objects.
   #
   def nextRecord(self, event):
     self.dispatchEvent(GFEvent('nextRECORD',self.currentBlock))
@@ -186,6 +188,12 @@
   def executeCommit(self, event):
     self.dispatchEvent(GFEvent('processCOMMIT',self.currentBlock))
 
+  def recordSwitched(self, event):
+    self.dispatchEvent(GFEvent('updateENTRY',event.data))
+
+  def notifyDetailBlocks(self, event):
+    self.dispatchEvent(GFEvent('updateDETAILBLOCK',event.data))
+
   #
   # nextEntry
   #
@@ -216,6 +224,7 @@
     nextEntry.processTrigger('Post-FocusIn')
 
     self.dispatchEvent(GFEvent('gotoENTRY',self.currentEntry));
+
   #
   # previousEntry
   #
@@ -223,7 +232,6 @@
   # focus change to the next data entry object
   #
   def previousEntry(self, event):
-
     # find last entry widget
     nextEntry = None
     for object in self.currentEntry.parent.children:
@@ -256,16 +264,14 @@
   def changeFocus(self, event):
     self.currentEntry.processTrigger('Pre-FocusOut')
     self.currentEntry.processTrigger('Post-FocusOut')
-
     event.data.processTrigger('Pre-FocusIn')
+
     self.currentEntry = event.data
+
     event.data.processTrigger('Post-FocusIn')
+
     self.dispatchEvent(GFEvent('gotoENTRY',self.currentEntry));
                         
-    
-
-
-
   #
   # nextBlock
   #
@@ -290,12 +296,10 @@
     self.currentBlock = nextBlock
     nextBlock.processTrigger('Post-FocusIn')
 
-
     # reset current entry 
     self.currentEntry = None
     self.currentBlock.walk(self.setInitialFocus)    
 
-
     # set current page
     pageWidget = self.currentBlock
     while pageWidget.getObjectType() != 'GFPage':
@@ -330,7 +334,6 @@
     self.currentEntry = None
     self.currentBlock.walk(self.setInitialFocus)    
 
-
     # set current page
     pageWidget = self.currentBlock
     while pageWidget.getObjectType() != 'GFPage':
@@ -401,15 +404,6 @@
     self.currentEntry.setValue(string)
     self.dispatchEvent(GFEvent('updateENTRY',self.currentEntry));
                                           
-  
-  #
-  # recordSwitched
-  #
-  # Tells the UI to update whenever an GFEntry signals that
-  # it has switched to a different record
-  #
-  def recordSwitched(self, event):
-    self.dispatchEvent(GFEvent('updateENTRY',event.data))
     
   #
   # requireLogin
@@ -426,25 +420,6 @@
     while self.loginInProgress:
       print "We're up dude!"
       pass
-
-
-##  #
-##  # processQuery
-##  # 
-##  def processQuery(self, event):
-##    if event.getEvent() == 'requestQUERY':
-##      if self.mode != 'query':
-##        self.mode = 'query'
-##        # check the current data is saved
-##      else:
-##        self.mode = 'normal'
-      
-##      #clear the current datasource
-
-##    elif event.getEvent() == 'processQUERY':
-##      # to be done 
-##      pass
-
 
 
 
Index: gnue/gnuef/src/GFGetOpt.py
diff -u gnue/gnuef/src/GFGetOpt.py:1.1 gnue/gnuef/src/GFGetOpt.py:1.2
--- gnue/gnuef/src/GFGetOpt.py:1.1      Fri Sep 29 15:30:04 2000
+++ gnue/gnuef/src/GFGetOpt.py  Sat Oct  7 22:37:52 2000
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #------------------------------------------------------------------------------
 # GNU Enterprise : Command Line Argument Processing
 # (c) 2000 Free Software Foundation
@@ -10,34 +9,48 @@
 class GFGetOpt:
   def __init__(self):
     # set defaults
-    self.cmdopt = { 'user_interface' : 'gui', 'debug_level' : 0, 'help' : 0, 
'version': 0 }
-    self.cmdarg = {}
+    self.cmdopt = { 'user_interface' : 'gui',
+                    'debug_level'    : 0,
+                    'help'           : 0,
+                    'version'        : 0 }
+    self.cmdarg = []
 
   def parseOptions(self,args):  
-
     # Parse command line for options
-    options, args = getopt.getopt(args[1:], 'u:d:hv', ['user_interface=', 
'debug_level=','help','version'])
+    options, args = getopt.getopt(args[1:],
+                                  'u:d:hv',
+                                  ['user_interface=', 
'debug_level=','help','version'])
 
     for opt in options:
       if opt[0] in ('--debug','-d'):
         self.cmdopt['debug_level'] = opt[1]
-      if opt[0] in ('--user_interface','-u'):
+      elif opt[0] in ('--user_interface','-u'):
         self.cmdopt['user_interface'] = opt[1]
-      if opt[0] in ('--help','-h'):
+      elif opt[0] in ('--help','-h'):
         self.cmdopt['help'] = 1
-      if opt[0] in ('--version','-v'):
+      elif opt[0] in ('--version','-v'):
         self.cmdopt['version'] = 1
-#      print opt
 
-    #no python masta to tell me how to avoid the i
-    i = 0
     for arg in args:
-      self.cmdarg[i] = arg
-      i = i + 1
-#      print self.cmdarg
+      self.cmdarg.append(arg)
 
   def getOption(self,option):
     return self.cmdopt[option]
 
   def getArgument(self,arg):
     return self.cmdarg[arg]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: gnue/gnuef/src/GFObjects.py
diff -u gnue/gnuef/src/GFObjects.py:1.12 gnue/gnuef/src/GFObjects.py:1.13
--- gnue/gnuef/src/GFObjects.py:1.12    Sat Oct  7 17:03:41 2000
+++ gnue/gnuef/src/GFObjects.py Sat Oct  7 22:37:52 2000
@@ -3,14 +3,13 @@
 # GFObjects.py
 #
 # DESCRIPTION:
-# The majority of the objects that make of a form
+# The majority of the objects that make up a form
 #
 # NOTES:
 #
 # HISTORY:
 # Copyright (c) 2000 James Thompson
 #
-
 from GFTrigger import *
 from GFEvent import *
 import GFOptions
@@ -57,7 +56,7 @@
     if self.children:
       for child in self.children:
         child.walk(function)
-    
+        
 #
 # GFValue
 #
@@ -96,8 +95,6 @@
     if not self.value:
       GFValue.setValue(self,value)
 
-
-
 #
 # GFBlock
 #
@@ -114,6 +111,7 @@
     
     self.dataSourceLink = None
     self.mode = 'normal'
+    self.entryList = []
     
     self.currentRecord = 0
     self.recordCount = 0
@@ -125,7 +123,8 @@
                            'recordSWITCHED': self.recordSwitched,
                            'initQUERY'     : self.processQuery,
                            'processQUERY'  : self.processQuery,
-                           'processCOMMIT' : self.processCommit
+                           'processCOMMIT' : self.processCommit,
+                           'updateDETAILBLOCK'  : self.updateDetail
                            }
     
     # register to recieve events from it's parent GFForm
@@ -138,10 +137,32 @@
     self.registerEventListener(self.form.processEvent)
 
   def initialize(self):
+
+    self.walk(self.buildEntryList)
     self.dataSourceLink = self.form.datasourceDictionary[self.datasource]
     self.recordCount = 
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
 #    GFObj.initialize()
 
+  def buildEntryList(self, object):
+    if object.getObjectType() == 'GFEntry':
+       self.entryList.append(object)
+
+  #
+  # updateDetail - makes block check to see if it needs to update itself
+  # if so it forces the update automagically
+  # 
+
+  def updateDetail(self,event):
+    if self.__dict__.has_key('masterBlock'):
+      if self.masterBlock == event.data.name:
+        fieldValue = self.form.findValue(self.masterBlock, self.masterField)
+
+        ## clear the link
+        #self.dataSourceLink.clear()
+        #self.dataSourceLink.setField(0,self.masterField,fieldValue)
+        #self.dataSourceLink.query()
+        
+
   #
   # Adds a record to the current records in memory
   #
@@ -177,6 +198,7 @@
   def recordSwitched(self, event):
     if GFOptions.DEBUG:
       print event.data, " just switched records"
+    self.dispatchEvent(GFEvent('notifyMASTERSWITCH',self))
     self.dispatchEvent(GFEvent('recordSWITCHED',event.data))
 
   def processCommit(self, event):
@@ -189,27 +211,28 @@
   # processQuery
   #
   def processQuery(self, event):
-    if event.getEvent() == 'initQUERY':
-      # need to add:  check the current data is saved
-      self.dataSourceLink.clear()
-      self.recordCount = 
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
-      self.currentRecord = self.recordCount
-      self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
-      if self.mode != 'query':
-        print "Start Query"
-        self.mode = 'query'
-      else:
-        print "Abort Query"
-        self.mode = 'normal'
-        
-    elif event.getEvent() == 'processQUERY':
-      if self.mode == 'query':
-        self.dispatchEvent(GFEvent('switchRECORD',[0,0]));
-        self.dataSourceLink.query()
+    if event.data == self:
+      if event.getEvent() == 'initQUERY':
+        # need to add:  check the current data is saved
+        self.dataSourceLink.clear()
         self.recordCount = 
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
+        self.currentRecord = self.recordCount
         self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
-        self.currentRecord = 0
-        self.mode = 'normal'
+        if self.mode != 'query':
+          print "Start Query"
+          self.mode = 'query'
+        else:
+          print "Abort Query"
+          self.mode = 'normal'
+        
+      elif event.getEvent() == 'processQUERY':
+        if self.mode == 'query':
+          self.dispatchEvent(GFEvent('switchRECORD',[0,0]));
+          self.dataSourceLink.query()
+          self.recordCount = 
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
+          self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
+          self.currentRecord = 0
+          self.mode = 'normal'
                                 
 
 #
Index: gnue/gnuef/src/UIbase.py
diff -u gnue/gnuef/src/UIbase.py:1.4 gnue/gnuef/src/UIbase.py:1.5
--- gnue/gnuef/src/UIbase.py:1.4        Tue Oct  3 22:04:58 2000
+++ gnue/gnuef/src/UIbase.py    Sat Oct  7 22:37:52 2000
@@ -25,7 +25,6 @@
     GFEventAware.__init__(self)
 
     self.form = form;
-    
     self.formToUI = {}                   # the GFObj to UI widget cross ref
     
     self.currentObject = [form]          # the current GFForm object
@@ -35,26 +34,21 @@
 
     self.pageList = []                   # A list of pages
     
-    self.uiEvents = {  'uiNEXTENTRY'   : self.eventError,
-                       'uiPREVENTRY'   : self.eventError,
-                       'uiCHANGEFOCUS' : self.eventError,
-                       'uiKEYPRESS'    : self.eventError}
-
-    self.keyEvents = {}
+    self.keyEvents = {}                  # Keyboard events from the widget set 
the
+                                         # UI is expected to respond to
+    self.incommingEvents = {}            # Events the UI is expected to 
respond to
     
-    #
-    # functions used to build the widgets
-    #
-    self.widgetConstructorFunction = {
-      'GFPage': self.pageHandler,
-      'GFLabel': self.stdHandler,
+
+    self.widgetConstructorFunction = {   # A dictionary of functions used by 
buildUI
+      'GFPage': self.pageHandler,        # to build the widgets.  Can override 
in 
+      'GFLabel': self.stdHandler,        # UI specific module if necessary
       'GFEntry': self.stdHandler,
       'GFForm': self.formHandler
-#      'GFDataSource': self.notVisible 
       }
 
     #
-    # python code used by the stdConstructor method
+    # Python code used by the stdConstructor method
+    # Must override in specific UI modules
     #
     self.widgetConstructorCode = {
       'GFLabel': """print 'GFLabel not defined'""",
@@ -62,13 +56,14 @@
       'GFForm' : """print 'GFForm not defined'"""
       }
 
+    #
+    # Call the UI specific onInit function
+    #
     self.onInit(form)
 
-  def notVisible(self):
-    pass
-
   #
-  # stdHandler
+  # placeholder Handlers that should be overriden
+  # in the UI specific module
   #
   def stdHandler(self):
     print "Warning : stdHandler for UI not defined"
@@ -78,14 +73,6 @@
     print "Warning : pageHandler for UI not defined"
 
   #
-  # error event when UI base isn't redefined by it's child
-  #
-  def eventError(self,event):
-    print "Event error occured.  UI system did not redefine"
-    print "the event handler for ",event.getEvent
-    
-
-  #
   # buildUI
   #
   # Creates the user interface from the form definition
@@ -94,9 +81,10 @@
   # form objects to the UI counterparts
   #
   def buildUI(self):
-    # Create the widget and add it to the widget tree
     try:
       widget = 
self.widgetConstructorFunction[self.currentObject[0].getObjectType()] ()
+      if widget == None:
+        print "WTF: %s" % (self.currentObject[0].getObjectType())
       self.formToUI[self.currentObject[0]] = widget
       if self.currentObject[0].getObjectType() in self.containerWidgets:
         self.currentWidget.insert(0,widget)
Index: gnue/gnuef/src/UIwxpython.py
diff -u gnue/gnuef/src/UIwxpython.py:1.8 gnue/gnuef/src/UIwxpython.py:1.9
--- gnue/gnuef/src/UIwxpython.py:1.8    Sat Oct  7 15:11:59 2000
+++ gnue/gnuef/src/UIwxpython.py        Sat Oct  7 22:37:52 2000
@@ -14,13 +14,13 @@
 from GFEvent import *
 from UIbase import *
 import string
+
 #
 # GFUserInterface
 #
 # The public interface to the User Interface
 # All UIs must provide this class
 #
-#class GFUserInterface(GFUserInterfaceBase, wxApp):
 class GFUserInterface(wxApp,GFUserInterfaceBase):
   def __init__(self, form):
     wxApp.__init__(self,0)
@@ -38,8 +38,6 @@
                                
wxDLG_PNT(container,wxPoint(int(object.x),int(object.y))),
                                
wxSize(int(object.width),int(object.height)),style=object.style)"""
                              }
-
-
     
     self.keyEvents = {WXK_PRIOR:  GFEvent('requestPREVBLOCK'),
                       WXK_NEXT:   GFEvent('requestNEXTBLOCK'),
@@ -67,20 +65,58 @@
                            'gotoPAGE'   : self.gotoPage
                           }
 
+    # Create the UI from the GFForm passed in
     self.buildUI()
+
+    # Make the first page of the UI visible
     self.pageList[0].Show(TRUE)
+
+    # Only one page at a time can be visible
     self.visiblePage = self.pageList[0]
 
+  #
+  # Misc functions
+  #
+  def mainLoop(self):
+    self.MainLoop() # simply call the wxApp's MainLoop method
+    
+  def OnInit(self):
+    # This is needed to keep wxApp happy
+    # don't put code in here, put it in onInit()
+    return true
+
+  def nextPage(self):
+    self.pageList[0].Show(FALSE)
+    self.pageList.append(self.pageList.pop(0)) # Rotates the pages
+    self.pageList[0].Show(TRUE)
+    
+  #
+  # Event handlers
+  #
+  # Methods called to deal with incomming events
+  #
+  def switchFocus(self, event):
+    self.formToUI[event.data].SetFocus()
+
+  def updateEntry(self,event):
+    self.formToUI[event.data].SetValue(event.data.getValue())
+    self.formToUI[event.data].SetInsertionPoint(event.data.cursorPosition)
+
+  def gotoPage(self, event):
+    self.visiblePage.Show(FALSE)
+    self.formToUI[event.data].Show(TRUE)
+    self.visiblePage = self.formToUI[event.data]
+    self.visiblePage.Show(TRUE)
     
   #
   # uiEventTrap traps wxPython events and converts
   # them to GFForms UI requests
   #
   def uiEventTrap(self, event):
+    action = None
     #
     # KeyBoard Events
     #
-    action = None
     if event.GetEventType() == wxEVT_CHAR:
       if event.ShiftDown() == TRUE and event.KeyCode() == WXK_TAB:
         action = GFEvent('requestPREVENTRY')
@@ -97,20 +133,13 @@
     # Mouse Events
     #
     elif event.GetEventType() == wxEVT_LEFT_DOWN:
-      # hack for swig
+      # hack for swig shortcomming 
       eo = event.GetEventObject()
       object = wxPyTypeCast(eo, 'wxWindow')
       
       for key in self.formToUI.keys():  # got to be a better way
-        if self.formToUI[key] == None:
-          print
-          print "UIwxpython.py - formToUI contains a None object - this 
probably shouldn't happen"
-          print "but it is.  This is a reminder to look into UIbase.buildUI() 
to see "
-          print "what is going on"
-          print
-        else:
-          if self.formToUI[key].GetId() == object.GetId():
-            action = GFEvent('requestFOCUS',key)
+        if self.formToUI[key].GetId() == object.GetId():
+          action = GFEvent('requestFOCUS',key)
     #
     # Unhandled events
     #
@@ -167,46 +196,7 @@
 
     self.currentWidget = [frame.panel]
     self.SetTopWindow(frame)
-
-  #
-  # misc crap
-  #
-  def mainLoop(self):
-    # simply call the wxApp's MainLoop method
-    self.MainLoop()
-    
-  def OnInit(self):
-    # needed to keep wxApp happy
-    #
-    # don't put code in here, put it in onInit()
-    #
-
-    return true
-
-  def nextPage(self):
-    self.pageList[0].Show(FALSE)
-    self.pageList.append(self.pageList.pop(0))
-    self.pageList[0].Show(TRUE)
-
-    
-  #
-  # Event handlers
-  #
-  # Methods called to deal with incomming events
-  #
-  def switchFocus(self, event):
-    self.formToUI[event.data].SetFocus()
-
-  def updateEntry(self,event):
-    self.formToUI[event.data].SetValue(event.data.getValue())
-    self.formToUI[event.data].SetInsertionPoint(event.data.cursorPosition)
-
-
-  def gotoPage(self, event):
-    self.visiblePage.Show(FALSE)
-    self.formToUI[event.data].Show(TRUE)
-    self.visiblePage = self.formToUI[event.data]
-    self.visiblePage.Show(TRUE)
+    return frame
 
 
 



reply via email to

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