commit-gnue
[Top][All Lists]
Advanced

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

r5798 - in trunk/gnue-forms/src: . GFObjects


From: jcater
Subject: r5798 - in trunk/gnue-forms/src: . GFObjects
Date: Sun, 9 May 2004 00:13:48 -0500 (CDT)

Author: jcater
Date: 2004-05-09 00:13:47 -0500 (Sun, 09 May 2004)
New Revision: 5798

Modified:
   trunk/gnue-forms/src/GFObjects/GFBlock.py
   trunk/gnue-forms/src/GFParser.py
Log:
started on datasource.detailmin and detailmax; fixed traceback caused when 
block has a trigger

Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2004-05-09 04:14:46 UTC (rev 
5797)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2004-05-09 05:13:47 UTC (rev 
5798)
@@ -218,6 +218,16 @@
 
     self._dataSourceLink = form._datasourceDictionary[self.datasource]
 
+    # Get min and max child rows, if applicable
+    try:
+      self._minChildRows = self._dataSourceLink.detailmin
+    except AttributeError:
+      self._minChildRows = 0
+    try:
+      self._maxChildRows = self._dataSourceLink.detailmax
+    except AttributeError:
+      self._maxChildRows = None
+
     # We will monitor our own resultSet changes
     self._dataSourceLink.registerResultSetListener(self._loadResultSet)
 
@@ -240,7 +250,10 @@
   def getFocusOrder(self):
     list = []
     for field in self._children:
-      list += field._entryList
+      try:
+        list += field._entryList
+      except AttributeError:
+        pass # Triggers, etc
 
     return GFContainer.getFocusOrder(self,list)
 
@@ -250,11 +263,19 @@
   #
   def isSaved(self):
     """
-    Returns a positive value if the datasource the block is associated
-    with is saved
+    Returns True if the datasource the block is associated
+    with is not pending any changes.
     """
-    return self._resultSet == None or not self._resultSet.isPending()
+    # TODO: Find all uses of isSaved() and replace with: not isPending()
+    return not self.isPending()
 
+  def isPending(self):
+    """
+    Returns True if the datasource the block is associated
+    with is pending any changes.
+    """
+    return self._resultSet and self._resultSet.isPending()
+
   #
   # deleteRecord
   #
@@ -281,8 +302,21 @@
       self._recordCount = self._resultSet.getRecordCount()
     else:
       # This means no results were returned from a query.
-      self.newRecord()
+# #       if self._minChildRows:
+# #         # If datasource.detailmin is set, create some blank
+# #         # (but non-empty) records
+# #         while self._recordCount < self._minChildRows:
+# #           self.newRecord()
+# #           # Force the record to no longer be
+# #           field = self._fieldList[0]
+# #           field.setValue(field.getValue())
+# #         self.firstRecord()
+# #       else:
+        # Otherwise, give us a single empty record to work from
+        self.newRecord()
 
+
+
   #
   # isEmpty()
   #

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2004-05-09 04:14:46 UTC (rev 5797)
+++ trunk/gnue-forms/src/GFParser.py    2004-05-09 05:13:47 UTC (rev 5798)
@@ -1055,16 +1055,42 @@
     #
     # Add DataSource elements
     #
-    xmlElements.update(
-      GDataSource.getXMLelements(
+    datasourceElems = GDataSource.getXMLelements(
         updates={'datasource': {
                    'BaseClass': GFObjects.GFDataSource,
                    'ParentTags': ('form',) },
                  'cparam': {
                    'BaseClass': GFObjects.GFCParam }
-                 }))
+                 })
 
+    # TODO: This may get moved to GCommon's datasources,
+    # TODO: but first have to determine if it will confuse
+    # TODO: development for other tools.
+    datasourceElems['datasource']['Attributes'].update( {
+            'detailmin':  {
+               'Label': _('M/D Min Child Rows'),
+               'Description': 'If this datasource is the child in a '
+                              'master/detail relationship, this property '
+                              'specifies the minimum number of child '
+                              'records that must be present for a commit '
+                              'to be valid. Usually, this is 0 (for '
+                              'one-to-many relationships) or 1 '
+                              '(for one-to-one relationships).',
+               'Default': 0,
+               'Typecast': GTypecast.whole },
+            'detailmax':  {
+               'Label': _('M/D Max Child Rows'),
+               'Description': 'If this datasource is the child in a '
+                              'master/detail relationship, this property '
+                              'specifies the maximum number of child '
+                              'records that can be created. Usually, this '
+                              'is either omitted (for one-to-many '
+                              'relationships) or 1 (for one-to-one '
+                              'relationships).',
+               'Typecast': GTypecast.whole } })
 
+    xmlElements.update( datasourceElems )
+
     #
     # Add trigger elements
     #





reply via email to

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