[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8660 - in trunk/gnue-forms/src: . GFObjects
From: |
reinhard |
Subject: |
[gnue] r8660 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Wed, 6 Sep 2006 06:38:58 -0500 (CDT) |
Author: reinhard
Date: 2006-09-06 06:38:57 -0500 (Wed, 06 Sep 2006)
New Revision: 8660
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Further cleanup of GFBlock.
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-09-06 11:06:04 UTC (rev 8659)
+++ trunk/gnue-forms/src/GFForm.py 2006-09-06 11:38:57 UTC (rev 8660)
@@ -812,7 +812,7 @@
if self._currentBlock is not None:
if self._currentBlock.mode == 'query':
return 'query'
- elif self._currentBlock.isEmpty():
+ elif self._currentBlock.is_empty():
return 'new'
else:
return 'edit'
@@ -1135,7 +1135,7 @@
# Are there any not yet posted changes in any of the blocks?
for block in self._logic._blockList:
- if block.isPending():
+ if block.get_record_status() in ('inserted', 'modified', 'deleted'):
return False
# Does a connection have any pending (already posted but not yet
@@ -1253,7 +1253,7 @@
'exMessage': sys.exc_info ()[1]}
self.refreshDisplay (self._currentBlock)
- if self._currentBlock.isEmpty ():
+ if self._currentBlock.is_empty ():
self.status_message (u_('Query returned no results.'))
else:
self.status_message (u_('Query successful.'))
@@ -1470,11 +1470,11 @@
currentBlock.transparent and not ( \
onlyInBlock or \
currentBlock.autoNextRecord and not ( \
- currentBlock.isEmpty() or \
- (not reverse and currentBlock.isLastRecord() and \
+ currentBlock.is_empty() or \
+ (not reverse and currentBlock.is_last_record() and \
not (currentBlock.autoCreate and \
currentBlock.editable in ('Y', 'new')) or \
- (reverse and currentBlock.isFirstRecord()) \
+ (reverse and currentBlock.is_first_record()) \
)))):
source = self._currentEntry._page.get_focus_order()
stayInBlock = False
@@ -1522,19 +1522,19 @@
# If we should navigate to the next record, do it...
if currentBlock is not None \
- and reverse and not currentBlock.isFirstRecord():
+ and reverse and not currentBlock.is_first_record():
currentBlock.prev_record()
self.changeFocus(nextEntry)
elif currentBlock is not None and not reverse and \
currentBlock.autoNextRecord and \
- not currentBlock.isEmpty() and \
+ not currentBlock.is_empty() and \
not (not currentBlock.autoCreate and \
- currentBlock.isLastRecord()):
+ currentBlock.is_last_record()):
currentBlock.next_record()
# If new record is empty, then the
# nextEntry logic has been taken care of...
- if currentBlock.isEmpty():
+ if currentBlock.is_empty():
return
else:
self.changeFocus(nextEntry)
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-09-06 11:06:04 UTC (rev
8659)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-09-06 11:38:57 UTC (rev
8660)
@@ -117,9 +117,9 @@
self._triggerFunctions = {
# Record status
'get_record_status': {'function': self.get_record_status},
- 'isEmpty': {'function': self.isEmpty}, # deprecated?
- 'isSaved': {'function': self.isSaved}, # deprecated?
- 'isPending': {'function': self.isPending}, # deprecated?
+ 'isSaved': {'function': self.is_saved}, # deprecated?
+ 'isPending': {'function': self.is_pending}, # deprecated?
+ 'isEmpty': {'function': self.is_empty}, # deprecated?
# Record navigation
'firstRecord': {'function': self.first_record},
@@ -172,22 +172,6 @@
# ---------------------------------------------------------------------------
- # Iterator support
- # ---------------------------------------------------------------------------
-
- def __iter__ (self):
- """
- Iterator support
-
- Allows you to do:
- for foo in myBlock:
- ....
- """
-
- return _BlockIter (self)
-
-
- # ---------------------------------------------------------------------------
# Object construction from xml
# ---------------------------------------------------------------------------
@@ -525,102 +509,57 @@
# ---------------------------------------------------------------------------
- def isSaved (self):
- """
- Returns True if the datasource the block is associated with is not pending
- any changes.
+ def is_saved(self):
+ """
+ Return True if the block is not pending any uncommited changes.
- This method is depreciated. Please use block.isPending () instead !
- """
+ This method is depreciated. Please use block.is_pending() instead !
+ """
- print "DEPRECIATION WARNING: the use of block.isSaved () is depreciated.",
\
- "Please use block.isPending () instead."
- return not self.isPending ()
+ assert gDebug(1, "DEPRECIATION WARNING: block.isSaved()")
+ return not self.is_pending()
# ---------------------------------------------------------------------------
- def isPending (self):
- """
- Returns True if the datasource the block is associated with is pending any
- changes.
- """
+ def is_pending(self):
+ """
+ Return True if the block is pending any uncommited changes.
+ """
- return self._resultSet and self._resultSet.isPending ()
+ return self._resultSet and self._resultSet.isPending()
# ---------------------------------------------------------------------------
- def isEmpty (self):
- """
- Returns True if the current record is empty.
+ def is_empty(self):
+ """
+ Return True if the current record is empty.
- Empty means that it has been newly inserted, but neither has any field been
- changed nor has a detail for this record been inserted with a status other
- than empty.
- """
+ Empty means that it has been newly inserted, but neither has any field
+ been changed nor has a detail for this record been inserted with a
+ status other than empty.
+ """
- return self._resultSet.current.isEmpty ()
+ return self._resultSet.current.isEmpty()
# ---------------------------------------------------------------------------
- def isFirstRecord (self):
- """
- Returns True if the current record is the first one in the ResultSet
- """
+ def is_first_record (self):
+ """
+ Returns True if the current record is the first one in the ResultSet
+ """
- return self._resultSet.isFirstRecord ()
+ return self._resultSet.isFirstRecord()
# ---------------------------------------------------------------------------
- def isLastRecord (self):
- """
- Returns True if the current record is the last one in the ResultSet.
- """
+ def is_last_record (self):
+ """
+ Returns True if the current record is the last one in the ResultSet.
+ """
- return self._resultSet.isLastRecord ()
+ return self._resultSet.isLastRecord ()
# ---------------------------------------------------------------------------
-
- def getResultSet (self):
- """
- Return the current ResultSet of the block.
- """
-
- return self._resultSet
-
- # ---------------------------------------------------------------------------
-
- def get_data(self, fieldnames):
- """
- Build a list of dictionaries of the current resultset using the fields
- defined by fieldnames.
-
- @param fieldnames: list of fieldnames to export per record
- @returns: list of dictionaries (one per record)
- """
-
- result = []
- if not fieldnames:
- fields = self._fieldMap.values()
- else:
- fields = [self._fieldMap[fld] for fld in fieldnames]
-
- for r in self._resultSet:
- add = {}
- for field in fields:
- fname = field.field
- if hasattr(field, 'fk_source'):
- value = field._allowedValues.get(r[fname])
- else:
- value = r[fname]
-
- add[fname] = value
-
- result.append(add)
-
- return result
-
-
- # ---------------------------------------------------------------------------
# Record Navigation
# ---------------------------------------------------------------------------
@@ -695,7 +634,7 @@
return
if self._resultSet.isLastRecord():
- if self.autoCreate and not self.isEmpty() and \
+ if self.autoCreate and not self.is_empty() and \
not self.editable in ('update', 'N'):
self.new_record()
return
@@ -810,6 +749,9 @@
currently pending it will be commited first.
"""
+ if self.mode == 'query':
+ return
+
if not self._form.endEditing():
return
@@ -838,6 +780,9 @@
copied anyway.
"""
+ if self.mode == 'query':
+ return
+
if not self._form.endEditing():
return
@@ -861,6 +806,9 @@
on the next commit, call or update.
"""
+ if self.mode == 'query':
+ return
+
if not self._form.endEditing():
return
@@ -883,6 +831,9 @@
Removes the deletion mark from the current record.
"""
+ if self.mode == 'query':
+ return
+
if not self._form.endEditing():
return
@@ -1156,6 +1107,48 @@
# ---------------------------------------------------------------------------
+ # Raw data access
+ # ---------------------------------------------------------------------------
+
+ def getResultSet (self):
+ """
+ Return the current ResultSet of the block.
+ """
+
+ return self._resultSet
+
+ # ---------------------------------------------------------------------------
+
+ def get_data(self, fieldnames):
+ """
+ Build a list of dictionaries of the current resultset using the fields
+ defined by fieldnames.
+
+ @param fieldnames: list of fieldnames to export per record
+ @returns: list of dictionaries (one per record)
+ """
+
+ result = []
+ if not fieldnames:
+ fields = self._fieldMap.values()
+ else:
+ fields = [self._fieldMap[fld] for fld in fieldnames]
+
+ for r in self._resultSet:
+ add = {}
+ for field in fields:
+ fname = field.field
+ if hasattr(field, 'fk_source'):
+ value = field._allowedValues.get(r[fname])
+ else:
+ value = r[fname]
+
+ add[fname] = value
+
+ result.append(add)
+
+ return result
+ # ---------------------------------------------------------------------------
# Helper Functions
# ---------------------------------------------------------------------------
@@ -1458,62 +1451,3 @@
value = result
return value
-
-
-# =============================================================================
-# Iterator class for a given GFBlock
-# =============================================================================
-
-class _BlockIter:
- """A simple iterator that lets you use a Block like:
-
- for record in myBlock:
- blah
- """
-
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
-
- def __init__ (self, block):
-
- self.block = block
- self.new = True
- self.done = False
-
-
- # ---------------------------------------------------------------------------
- # Return the iterator object itself
- # ---------------------------------------------------------------------------
-
- def __iter__ (self):
-
- return self
-
-
- # ---------------------------------------------------------------------------
- # Return the next item from the container
- # ---------------------------------------------------------------------------
-
- def next (self):
-
- if self.done:
- # Make sure to raise StopIteration on subsequent calls to next ()
- raise StopIteration
-
- elif self.new:
- self.block.jumpRecord (0)
- self.new = False
-
- elif self.block._resultSet.isLastRecord ():
- self.done = True
- raise StopIteration
-
- else:
- self.block.next_record()
-
- if self.block.isEmpty () and self.block._resultSet.isLastRecord ():
- self.done = True
- raise StopIteration
-
- return self.block
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8660 - in trunk/gnue-forms/src: . GFObjects,
reinhard <=