[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnuef samples/zipcode/zip_code.gfd src/GFF...
From: |
James Thompson |
Subject: |
gnue/gnuef samples/zipcode/zip_code.gfd src/GFF... |
Date: |
Sun, 22 Oct 2000 19:36:59 -0700 |
CVSROOT: /cvs
Module name: gnue
Changes by: James Thompson <address@hidden> 00/10/22 19:36:58
Modified files:
gnuef/samples/zipcode: zip_code.gfd
gnuef/src : GFForm.py GFObjects.py UIbase.py UIwxpython.py
Log message:
Blocks now support foreign key input validation against a datasource
Dropdown listbox supported in UIwxpython. Still needs event links
to/from the form
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/samples/zipcode/zip_code.gfd.diff?r1=1.9&r2=1.10
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFForm.py.diff?r1=1.24&r2=1.25
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFObjects.py.diff?r1=1.23&r2=1.24
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/UIbase.py.diff?r1=1.9&r2=1.10
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/UIwxpython.py.diff?r1=1.17&r2=1.18
Patches:
Index: gnue/gnuef/samples/zipcode/zip_code.gfd
diff -u gnue/gnuef/samples/zipcode/zip_code.gfd:1.9
gnue/gnuef/samples/zipcode/zip_code.gfd:1.10
--- gnue/gnuef/samples/zipcode/zip_code.gfd:1.9 Sun Oct 22 16:26:43 2000
+++ gnue/gnuef/samples/zipcode/zip_code.gfd Sun Oct 22 19:36:58 2000
@@ -10,6 +10,7 @@
<database name="gnue" provider="postgresql" dbname="gnue" host="gnue"/>
<datasource name="zips" database="gnue" table="zip_code" cache="5"/>
+ <datasource name="validator" database="gnue" table="states" prequery="" />
<page>
@@ -19,7 +20,7 @@
</entry>
<label text="State" x="65" y="10"/>
- <entry name="state" field="state" x="65" y="20" width="150" height="20"
visibleCount="10" uppercase=""/>
+ <entry name="state" field="state" x="65" y="20" width="150" height="20"
visibleCount="10" uppercase="" foreign_key="validator.state"
foreign_key_description="description" style="text"/>
<label text="Zip" x="125" y="10"/>
<entry name="zip" field="zip" x="125" y="20" width="150" height="20"
visibleCount="10" numeric="" max_length="5"/>
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.24 gnue/gnuef/src/GFForm.py:1.25
--- gnue/gnuef/src/GFForm.py:1.24 Sun Oct 22 16:26:43 2000
+++ gnue/gnuef/src/GFForm.py Sun Oct 22 19:36:58 2000
@@ -230,6 +230,7 @@
def nextEntry(self, event):
nextEntry = None
keepNext = 0
+ if not self.currentEntry.verifyValue(): return
for object in self.currentEntry.parent.children:
# Put the first field as the next to rollover
if object.getObjectType()=='GFEntry'and not
object.__dict__.has_key('hidden'):
Index: gnue/gnuef/src/GFObjects.py
diff -u gnue/gnuef/src/GFObjects.py:1.23 gnue/gnuef/src/GFObjects.py:1.24
--- gnue/gnuef/src/GFObjects.py:1.23 Sat Oct 21 09:06:19 2000
+++ gnue/gnuef/src/GFObjects.py Sun Oct 22 19:36:58 2000
@@ -15,6 +15,7 @@
from GFEvent import *
from DBfactory import DBfactory
import GFOptions
+import string
#
#!!Hack warning!!, have moved GFTriggerAware into this file
@@ -232,7 +233,9 @@
self.recordCount =
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
- self.currentRecord = 0
+ self.currentRecord = 0
+
+
#
# Adds a record to the current records in memory
#
@@ -241,16 +244,6 @@
self.dataSourceLink.new()
self.recordCount =
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
-# testing code to see if the jump below was screwing up the
-# new record code
-# while self.currentRecord != self.recordCount:
-# self.dispatchEvent(GFEvent('requestNEXTRECORD',None))
-
-# Working code but adding new records doesn't look purdy :)
-# oldRecord = self.currentRecord
-# self.currentRecord = self.recordCount
-#
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
-
oldRecord = self.currentRecord
self.currentRecord = 0
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
@@ -392,6 +385,41 @@
self.dispatchEvent(GFEvent('uiNEXTRECORD',self))
self.dispatchEvent(GFEvent('recordSWITCHED',self));
+ #
+ # verifyValue
+ #
+ def verifyValue(self):
+ value = 1
+ if self.__dict__.has_key('foreign_key'):
+ value = 0
+ datasourceName,fieldName = string.split(self.foreign_key,'.')
+ datasource = self.block.form.datasourceDictionary[datasourceName]
+
+ for count in range(datasource.getLastRecordNumber()):
+ if datasource.getField(count,fieldName) == self.value:
+ value = 1
+ break
+
+ return value
+ #
+ # allowedValues
+ #
+ def allowedValues(self):
+ values = {}
+ if self.__dict__.has_key('foreign_key'):
+ datasourceName,fieldName = string.split(self.foreign_key,'.')
+ datasource = self.block.form.datasourceDictionary[datasourceName]
+
+ for count in range(datasource.getLastRecordNumber()+1):
+ if self.__dict__.has_key('foreign_key_description'):
+ description = datasource.getField(count,self.foreign_key_description)
+ else:
+ description = None
+
+ values[datasource.getField(count,fieldName)] = description
+ return values
+
+
#
# Data Access
@@ -442,8 +470,9 @@
self.clear()
- # just for the heck of it
- # self.query()
+ if self.__dict__.has_key('prequery'):
+ self.query()
+ print self.resultSet
def clear(self):
self.resultSet = []
Index: gnue/gnuef/src/UIbase.py
diff -u gnue/gnuef/src/UIbase.py:1.9 gnue/gnuef/src/UIbase.py:1.10
--- gnue/gnuef/src/UIbase.py:1.9 Sun Oct 22 16:26:43 2000
+++ gnue/gnuef/src/UIbase.py Sun Oct 22 19:36:58 2000
@@ -44,7 +44,7 @@
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,
+ 'GFEntry': self.entryHandler,
'GFForm': self.formHandler
}
@@ -99,7 +99,10 @@
# If the current object is a container then add the
# just created first created widget to it's widget list
if self.currentObject[0].getObjectType() in self.containerWidgets:
- self.currentWidget.insert(0,widget[0])
+ self.currentWidget.insert(0,widget[0])
+
+ if self.currentObject[0].__dict__.has_key('foreign_key'):
+ print "Allowed Values: ",self.currentObject[0].allowedValues()
except KeyError:
pass
Index: gnue/gnuef/src/UIwxpython.py
diff -u gnue/gnuef/src/UIwxpython.py:1.17 gnue/gnuef/src/UIwxpython.py:1.18
--- gnue/gnuef/src/UIwxpython.py:1.17 Sun Oct 22 16:26:43 2000
+++ gnue/gnuef/src/UIwxpython.py Sun Oct 22 19:36:58 2000
@@ -33,12 +33,7 @@
'GFLabel':
"""wxStaticText(container, -1, object.text,
wxDLG_PNT(container,wxPoint(int(object.x),int(object.y))),
- wxDefaultSize)""",
- 'GFEntry':
- """wxTextCtrl(container, -1, object.value,
- wxDLG_PNT(container,wxPoint(int(object.x),
- int(object.y) +
(spacer*(int(object.height)/2)))),
-
wxSize(int(object.width),int(object.height)),style=object.style)"""
+ wxDefaultSize)"""
}
self.keyEvents = {WXK_PRIOR: GFEvent('requestPREVBLOCK'),
@@ -252,15 +247,15 @@
#jamest this is probably wrong way to do but be patient. :)
- if object.getObjectType() == 'GFEntry':
- #set default style
- setattr(object,'style',wxSIMPLE_BORDER)
- try:
- if string.lower(object.password) == 'true':
- #set style to read only
- setattr(object,'style',wxTE_PASSWORD)
- except:
- pass
+# if object.getObjectType() == 'GFEntry':
+# #set default style
+# setattr(object,'style',wxSIMPLE_BORDER)
+# try:
+# if string.lower(object.password) == 'true':
+# #set style to read only
+# setattr(object,'style',wxTE_PASSWORD)
+# except:
+# pass
if not object.__dict__.has_key('visibleCount'):
# count = int(object.visibleCount)
@@ -302,5 +297,56 @@
self.currentWidget = [frame.panel]
self.SetTopWindow(frame)
return frame
+
+
+ def entryHandler(self):
+ object = self.currentObject[0]
+ container = self.currentWidget[0]
+
+ widget = []
+ if not object.__dict__.has_key('visibleCount'):
+ object.visibleCount = 1
+
+ count = int(object.visibleCount)
+
+
+ if object.__dict__.has_key('style'):
+ style = object.style
+ else:
+ style = 'text'
+
+ for spacer in range(count):
+ spacer = int(spacer)
+
+ if style == 'dropdown':
+ choices = []
+ values = object.allowedValues()
+ for key in values.keys():
+ choices.append(values[key])
+
+ newWidget = wxComboBox(container, -1, "",
+ wxDLG_PNT(container,
+ wxPoint(int(object.x),int(object.y) +
+ (spacer*(int(object.height)/2)))),
+ wxSize(int(object.width),int(object.height)),choices,
+ wxCB_READONLY)
+
+ else:
+ newWidget = wxTextCtrl(container, -1, object.value,
+ wxDLG_PNT(container,
+ wxPoint(int(object.x),int(object.y) +
+
(spacer*(int(object.height)/2)))),
+ wxSize(int(object.width),int(object.height)))
+
+
+ EVT_CHAR(newWidget, self.uiEventTrap)
+ EVT_MOUSE_EVENTS(newWidget, self.uiEventTrap)
+
+ widget.append(newWidget)
+
+ return widget
+
+
+
- gnue/gnuef samples/zipcode/zip_code.gfd src/GFF...,
James Thompson <=