[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnuef samples/helloworld.gfd src/GFForm.py...
From: |
James Thompson |
Subject: |
gnue/gnuef samples/helloworld.gfd src/GFForm.py... |
Date: |
Thu, 09 Nov 2000 11:56:11 -0800 |
CVSROOT: /cvs
Module name: gnue
Changes by: James Thompson <address@hidden> 00/11/09 11:56:11
Modified files:
gnuef/samples : helloworld.gfd
gnuef/src : GFForm.py GFObjects.py GFParser.py
Log message:
added support for triggers to reference values via
blockname.fields.fieldname
Note: UI does not update
code cleanup
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/samples/helloworld.gfd.diff?r1=1.2&r2=1.3
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFForm.py.diff?r1=1.35&r2=1.36
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFObjects.py.diff?r1=1.32&r2=1.33
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/gnuef/src/GFParser.py.diff?r1=1.6&r2=1.7
Patches:
Index: gnue/gnuef/samples/helloworld.gfd
diff -u gnue/gnuef/samples/helloworld.gfd:1.2
gnue/gnuef/samples/helloworld.gfd:1.3
--- gnue/gnuef/samples/helloworld.gfd:1.2 Tue Nov 7 21:02:47 2000
+++ gnue/gnuef/samples/helloworld.gfd Thu Nov 9 11:56:11 2000
@@ -4,7 +4,7 @@
<options>
<name>GNU Enterprise Login</name>
<version>0.0.2</version>
- <height>170</height>
+ <height>400</height>
<width>400</width>
</options>
@@ -13,16 +13,20 @@
<block name="HelloWorldBlock" datasource="nil">
<label text="User Name" x="20" y="10" />
<entry name="user" field="user" value="Type Here" x="20" y="20"
width="300" height="25">
+ </entry>
+ <label text="Password" x="20" y="40" />
+ <entry name="password" field="password" value="Type Here Part Two"
x="20" y="50" width="300" height="25" password="true">
<trigger type ="Pre-FocusOut">
#
#User name trigger
#
print "Trigger fired in block %s" % self.block.name
print "HelloWorldBlock.datasource = %s" % HelloWorldBlock.datasource
-print "User name updated to %s" % self.value</trigger>
+print "User name updated to %s" % HelloWorldBlock.fields.user
+print "User passwd updated to %s" % HelloWorldBlock.fields.password
+HelloWorldBlock.fields.user = "Wazzup!"
+print "User name updated to %s" % HelloWorldBlock.fields.user</trigger>
</entry>
- <label text="Password" x="20" y="40" />
- <entry name="password" field="password" value="Type Here Part Two"
x="20" y="50" width="300" height="25" password="true"/>
</block>
</page>
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.35 gnue/gnuef/src/GFForm.py:1.36
--- gnue/gnuef/src/GFForm.py:1.35 Tue Nov 7 21:00:26 2000
+++ gnue/gnuef/src/GFForm.py Thu Nov 9 11:56:11 2000
@@ -26,7 +26,6 @@
GFEventAware.__init__(self)
self.type = "GFForm"
self.currentObject = [self]
-# self.mode = 'normal'
# Event processing
self.incommingEvent = {'requestNEXTENTRY' : self.nextEntry,
@@ -311,9 +310,6 @@
self.updateRecordStatus()
self.updateTip()
-
-# self.updateStatus()
-
#
# previousEntry
#
@@ -346,9 +342,6 @@
self.updateRecordStatus()
self.updateTip()
-
-# self.updateStatus()
-
#
# changeFocus
#
@@ -367,7 +360,6 @@
self.dispatchEvent(GFEvent('gotoENTRY',self.currentEntry));
self.updateRecordStatus()
self.updateTip()
-# self.updateStatus()
#
# nextBlock
@@ -507,7 +499,8 @@
currentvalue = currentvalue[:self.currentEntry.cursorPosition] +
event.data + \
currentvalue[self.currentEntry.cursorPosition+1:]
- self.currentEntry.setValue(currentvalue)
+# self.currentEntry.setValue(currentvalue)
+ self.currentEntry.value = currentvalue
self.currentEntry.cursorPosition = self.currentEntry.cursorPosition + 1
self.dispatchEvent(GFEvent('updateENTRY',self.currentEntry));
else:
@@ -527,10 +520,13 @@
else:
return
- currentvalue = self.currentEntry.getValue()
+# currentvalue = self.currentEntry.getValue()
+ currentvalue = self.currentEntry.value
currentvalue = currentvalue[:self.currentEntry.cursorPosition] + \
currentvalue[self.currentEntry.cursorPosition+1:]
- self.currentEntry.setValue(currentvalue)
+# self.currentEntry.setValue(currentvalue)
+ self.currentEntry.value = currentvalue
+
self.dispatchEvent(GFEvent('updateENTRY',self.currentEntry));
Index: gnue/gnuef/src/GFObjects.py
diff -u gnue/gnuef/src/GFObjects.py:1.32 gnue/gnuef/src/GFObjects.py:1.33
--- gnue/gnuef/src/GFObjects.py:1.32 Tue Nov 7 21:00:26 2000
+++ gnue/gnuef/src/GFObjects.py Thu Nov 9 11:56:11 2000
@@ -36,7 +36,6 @@
self.trigger[key] = []
self.trigger[key].append(function)
-
def processTrigger(self, key):
if self.validTriggers.count(key):
if self.trigger.has_key(key):
@@ -69,27 +68,22 @@
def addChild(self, child):
self.children.append(child)
-# def initialize(self):
-# for child in self.children
-# child.initialize()
-
- #
- # Attributes
- #
- def setAttribute(self, key, value):
- self.attributes[key] = value
-
- def getAttributes(self):
- return self.attributes
-
- #
- # Utility functions
- #
def walk(self, function):
function(self)
if self.children:
for child in self.children:
child.walk(function)
+
+ def findParentOfType(self,type):
+ parentObject = self
+ while (parentObject.getObjectType() != type):
+ parentObject = parentObject.parent
+
+ return parentObject
+
+# def initialize(self):
+# for child in self.children
+# child.initialize()
#
# GFValue
@@ -112,36 +106,6 @@
return self.value
#
-# GFMultiValue
-#
-# An object that can store and retrieve a value
-#
-# Note: Do to the nature of the parser the
-# initial values of arguments are stored as
-# strings in the object. So we must keep a
-# seperate array to hold strings then
-# move them back and forth from the value attribute
-#
-class GFMultiValue(GFObj):
- # Add value attrib support
- def __init__(self, parent=None, value=None):
- self.value = value
-
- self.valueArray = []
- self.valueArray.append(value)
-
- self.type = "GFValue"
- GFObj.__init__(self, parent)
-
- def setValue(self, value):
- self.value = self.valueArray[self.block.currentRecord] = value
-
-
- def getValue(self):
- return self.value
-
-
-#
# GFPage
#
class GFPage(GFObj):
@@ -161,7 +125,7 @@
if not self.value:
GFValue.setValue(self,value)
-#
+############################################################
# GFBlock
#
# This object handles events from GFEntry widgets but doesn't
@@ -175,9 +139,11 @@
GFEventAware.__init__(self)
self.type = "GFBlock"
+ self.form = self.findParentOfType('GFForm')
self.dataSourceLink = None
self.mode = 'normal'
self.entryList = []
+ self.fields = GFFields(self)
self.currentRecord = 0
self.recordCount = 0
@@ -195,55 +161,30 @@
}
# register to recieve events from it's parent GFForm
- self.form = parent
- while (self.form.getObjectType() != 'GFForm'):
- self.form = self.form.parent
self.form.registerEventListener(self.processEvent)
- #register the form to recieve events from the block
+ # register the form to recieve events from the block
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 isSaved(self):
- return self.dataSourceLink.isSaved()
-
-
def buildEntryList(self, object):
if object.getObjectType() == 'GFEntry':
self.entryList.append(object)
-
+
+ def isSaved(self):
+ return self.dataSourceLink.isSaved()
+
#
- # updateDetail - makes block check to see if it needs to update itself
- # if so it forces the update automagically
- #
-
- def updateDetail(self,event):
+ # deleteRecord
+ #
+ def deleteRecord(self,event):
+ if event.data == self:
+ self.dataSourceLink.markForRemoval(self.currentRecord)
- if hasattr(self,'master'):
- masterBlock,masterField = string.split(self.master,'.')
- if masterBlock == event.data.name:
- fieldValue = self.form.findValue(masterBlock, masterField)
- self.dataSourceLink.clear()
- if len(fieldValue) > 0:
- if GFOptions.DEBUG:
- print "Master Field value is %s" % (fieldValue)
- ## clear the link
- self.dataSourceLink.setField(0,self.detail,fieldValue)
- self.dataSourceLink.query()
-
- self.recordCount =
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
- self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
- self.currentRecord = 0
-
-
#
# Adds a record to the current records in memory
#
@@ -251,17 +192,12 @@
if event.data == self:
self.dataSourceLink.new()
self.recordCount =
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
-
+
oldRecord = self.currentRecord
self.currentRecord = 0
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
self.dispatchEvent(GFEvent('requestPREVRECORD',None))
-
#self.dispatchEvent(GFEvent('uiUPDATESTATUS',[None,None,None,self.currentRecord,self.recordCount]))
-
-
-
-
#
# Moves the proper record into editing position
#
@@ -279,7 +215,6 @@
if self.currentRecord > self.recordCount : self.currentRecord = 0
self.dispatchEvent(GFEvent('switchRECORD',[oldRecord,self.currentRecord]));
- #
self.dispatchEvent(GFEvent('uiUPDATESTATUS',[None,None,None,self.currentRecord,self.recordCount]))
#
# recordSwitched
@@ -290,8 +225,10 @@
if self.mode == 'normal':
self.dispatchEvent(GFEvent('notifyMASTERSWITCH',self))
self.dispatchEvent(GFEvent('recordSWITCHED',event.data))
-
+ #
+ # processCommit
+ #
def processCommit(self, event):
if GFOptions.DEBUG:
print "processing commit"
@@ -306,17 +243,9 @@
self.dispatchEvent(GFEvent('requestPREVRECORD',None))
self.dispatchEvent(GFEvent('requestNEXTRECORD',None))
-
#self.dispatchEvent(GFEvent('uiUPDATESTATUS',[None,None,None,self.currentRecord,self.recordCount]))
self.mode='normal'
#
- # deleteRecord
- #
- def deleteRecord(self,event):
- if event.data == self:
- self.dataSourceLink.markForRemoval(self.currentRecord)
-
- #
# processQuery
#
def processQuery(self, event):
@@ -336,8 +265,6 @@
self.currentRecord = self.recordCount
self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
-# oldRecord = self.currentRecord
-
elif event.getEvent() == 'processQUERY':
if self.mode == 'query':
self.mode = 'normal'
@@ -352,8 +279,28 @@
self.currentRecord = 0
#self.dispatchEvent(GFEvent('uiUPDATESTATUS',[None,None,None,self.currentRecord,self.recordCount]))
+ #
+ # updateDetail - makes block check to see if it needs to update itself
+ # if so it forces the update automagically
+ #
+ def updateDetail(self,event):
+ if hasattr(self,'master'):
+ masterBlock,masterField = string.split(self.master,'.')
+ if masterBlock == event.data.name:
+ fieldValue = self.form.findValue(masterBlock, masterField)
+ self.dataSourceLink.clear()
+ if len(fieldValue) > 0:
+ if GFOptions.DEBUG:
+ print "Master Field value is %s" % (fieldValue)
+ ## clear the link
+ self.dataSourceLink.setField(0,self.detail,fieldValue)
+ self.dataSourceLink.query()
+
+ self.recordCount =
self.form.datasourceDictionary[self.datasource].getLastRecordNumber()
+ self.dispatchEvent(GFEvent('switchRECORD',[-1,0]));
+ self.currentRecord = 0
-#
+############################################################
# GFEntry
#
# Matches the Entry form tag in the gfd
@@ -379,9 +326,7 @@
}
# register to recieve events from it's parent GFBlock
- self.block = parent
- while (self.block.getObjectType() != 'GFBlock'):
- self.block = self.block.parent
+ self.block = self.findParentOfType('GFBlock')
self.block.registerEventListener(self.processEvent)
#register the block to recieve events from the entry
@@ -443,14 +388,8 @@
values[datasource.getField(count,fieldName)] = description
return values
-
-
-#
-# Data Access
-#
-
-#
+############################################################
#GFDataSource
#
# In memory store of data manipulated by forms
@@ -471,11 +410,8 @@
self.sql = None
- self.form = parent
- while (self.form.getObjectType() != 'GFForm'):
- self.form = self.form.parent
+ self.form = self.findParentOfType('GFForm')
-
def initialize(self):
if GFOptions.DEBUG:
print "Initializing datasource %s" % (self.name)
@@ -554,7 +490,6 @@
if self.resultSet[count][key] != None:
self.resultSet[count][key] = str(self.resultSet[count][key])
-
def commit(self):
if hasattr(self,'database'):
for count in range(len(self.resultSet)):
@@ -600,7 +535,6 @@
self.dataConnection.commit()
-
# Clean up record list
count = 0
self.resultSetStatus = []
@@ -671,8 +605,7 @@
self.emptyRecord[fieldName]=""
self.fieldList.append(fieldName)
-
-#
+############################################################
# GFDatabase
#
# The connection to a specific chunk of data
@@ -708,19 +641,39 @@
def getFieldList(self,table):
self.uniqueKey = self.link.getUniqueKey(table)
- return self.link.getFieldList(table)
+ return self.link.getFieldList(table)
-#
-# Unused objects
-#
-#
-#GFDataSet
-#
-class GFDataSet(GFObj):
- def __init__(self, parent=None):
- GFObj.__init__(self, parent)
- self.type = "GFDataSet"
+
+class GFFields:
+ def __init__(self,block):
+ self.block = block
+ print "the block is ",block
+ def __getattr__(self,name):
+ for item in self.block.entryList:
+ if item.name == name:
+ return item.value
+ return None
+
+ def __setattr__(self,name,value):
+ try:
+ for item in self.__dict__['block'].__dict__['entryList']:
+ if item.name == name:
+ item.__dict__['value'] = value
+ return
+ print "HI"
+ except KeyError:
+ print "Ho"
+ self.__dict__[name] = value
+ return
+
+
+
+
+
+
+
+
Index: gnue/gnuef/src/GFParser.py
diff -u gnue/gnuef/src/GFParser.py:1.6 gnue/gnuef/src/GFParser.py:1.7
--- gnue/gnuef/src/GFParser.py:1.6 Mon Oct 9 06:21:24 2000
+++ gnue/gnuef/src/GFParser.py Thu Nov 9 11:56:11 2000
@@ -165,7 +165,6 @@
'entry' : GFEntry,
# 'trigger': GFTrigger,
'datasource': GFDataSource,
- 'dataset': GFDataSet,
'database': GFDatabase
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnuef samples/helloworld.gfd src/GFForm.py...,
James Thompson <=