[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8679 - trunk/gnue-forms/src/GFObjects
From: |
reinhard |
Subject: |
[gnue] r8679 - trunk/gnue-forms/src/GFObjects |
Date: |
Wed, 13 Sep 2006 10:49:05 -0500 (CDT) |
Author: reinhard
Date: 2006-09-13 10:49:04 -0500 (Wed, 13 Sep 2006)
New Revision: 8679
Modified:
trunk/gnue-forms/src/GFObjects/GFBlock.py
trunk/gnue-forms/src/GFObjects/GFField.py
Log:
Keep the _recordSet object private to the block.
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-09-13 13:54:16 UTC (rev
8678)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-09-13 15:49:04 UTC (rev
8679)
@@ -358,7 +358,7 @@
# ---------------------------------------------------------------------------
- # Event handlers to be called from outside GF
+ # Event handlers for UI events (scrollbar or mouse wheel)
# ---------------------------------------------------------------------------
def _event_scroll_delta (self, adjustment):
@@ -412,6 +412,64 @@
# ---------------------------------------------------------------------------
+ # Field access
+ # ---------------------------------------------------------------------------
+
+ def get_value(self, field):
+ """
+ Return the value of the given field, depending on the block's state.
+
+ @param field: the GFField object.
+ """
+
+ if self.mode == 'query':
+ value = self._queryValues.get(field)
+
+ elif self.mode == 'init':
+ value = self._initializingRecord[field.field]
+
+ else:
+ if self._resultSet and self._resultSet.current:
+ value = self._resultSet.current.getField(field.field)
+ else:
+ value = None
+
+ return value
+
+ # ---------------------------------------------------------------------------
+
+ def set_value(self, field, value):
+ """
+ Set the value of the given field, depending on the block's state.
+
+ @param field: the GFField object.
+ """
+
+ if self.mode == 'query':
+ if value is None:
+ del self._block._queryValues[field]
+ else:
+ self._queryValues[field] = value
+
+ elif self.mode == 'init':
+ self._initializingRecord[field.field] = value
+
+ else:
+ self.processTrigger('Pre-Change')
+ field.processTrigger('Pre-Change')
+
+ self._resultSet.current[field.field] = value
+ if field.defaultToLast:
+ self._lastValues[field.field] = value
+
+ field.processTrigger('Post-Change')
+ self.processTrigger('Post-Change')
+
+ if self.mode != 'init':
+ field.value_changed()
+
+
+ # ---------------------------------------------------------------------------
# Status information
# ---------------------------------------------------------------------------
@@ -548,6 +606,7 @@
return self._resultSet.isLastRecord ()
+
# ---------------------------------------------------------------------------
# Record Navigation
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py 2006-09-13 13:54:16 UTC (rev
8678)
+++ trunk/gnue-forms/src/GFObjects/GFField.py 2006-09-13 15:49:04 UTC (rev
8679)
@@ -195,20 +195,8 @@
rtrim-attributes.
"""
- mode = self._block.mode
+ value = self._block.get_value(self)
- if mode == 'query':
- value = self._block._queryValues.get(self)
-
- elif mode == 'init':
- value = self._block._initializingRecord [self.field]
-
- else:
- if self._block._resultSet and self._block._resultSet.current:
- value = self._block._resultSet.current.getField(self.field)
- else:
- value = None
-
if value is None:
value = ''
@@ -235,43 +223,34 @@
PostChange-triggers will be fired on field- and block-level.
"""
- mode = self._block.mode
-
if isinstance(value, basestring):
if self.rtrim:
value = value.rstrip()
if self.ltrim:
value = value.lstrip()
- if mode == 'query':
- self._block._queryValues[self] = value
- if value is None:
- del self._block._queryValues[self]
+ self._block.set_value(self, value)
- elif mode == 'init':
- self._block._initializingRecord[self.field] = value
- else:
- self._block.processTrigger('Pre-Change')
- self.processTrigger('Pre-Change')
- self._block._resultSet.current[self.field] = value
+ # -------------------------------------------------------------------------
+ # Notification of value change
+ # -------------------------------------------------------------------------
- if self.defaultToLast:
- self._block._lastValues[self.field] = value
+ def value_changed(self):
+ """
+ Notify the field that the db or query value behind it has changed.
- self._block.processTrigger('Post-Change')
- self.processTrigger('Post-Change')
+ This function gets called whenever the user interface has to be
+ updated.
+ """
+ self._block._form.updateUIEntry(self)
- # If the field value of the current record has changed, update the UI
- if mode != 'init':
- self._block._form.updateUIEntry(self)
+ # If the field is a foreign key, move the result set to the
+ # selected value.
+ if hasattr(self, '_GFField__fk_resultSet'):
+ self.__fk_resultSet.findRecord({self.fk_key: self.getValue})
- # If the field is a foreign key, move the result set to the
- # selected value.
- if hasattr(self,'_GFField__fk_resultSet'):
- self.__fk_resultSet.findRecord({self.fk_key: value})
-
# -------------------------------------------------------------------------
# Implementation of virtual methods
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8679 - trunk/gnue-forms/src/GFObjects,
reinhard <=