[gnue] r9458 - trunk/gnue-forms/src/GFObjects

[email protected]
Newsgroups gmane.comp.cms.gnue.cvs
Message-ID <[email protected]>
Author: reinhard
Date: 2007-03-31 16:22:13 -0500 (Sat, 31 Mar 2007)
New Revision: 9458

Modified:
   trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Added new block function search_record to search within the current result set.


Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py	2007-03-31 21:21:37 UTC (rev 9457)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py	2007-03-31 21:22:13 UTC (rev 9458)
@@ -51,8 +51,8 @@
 
     Within the result set, blocks maintain a pointer to a current record which
     can be moved around with the L{first_record}, L{prev_record},
-    L{next_record}, L{last_record}, L{goto_record}, and L{jump_records}
-    methods.
+    L{next_record}, L{last_record}, L{goto_record}, L{jump_records}, and
+    L{search_record} methods.
 
     Read and write access to the data of the current record (and the
     surrounding records) is possible with the L{get_value} and L{set_value}
@@ -178,6 +178,7 @@
                 'last_record': {'function': self.last_record},
                 'goto_record': {'function': self.goto_record},
                 'jump_records': {'function': self.jump_records},
+                'search_record': {'function': self.search_record},
 
                 # Record status
                 'get_record_status': {'function': self.get_record_status},
@@ -816,7 +817,28 @@
 
         self.goto_record(record_number)
 
+    # -------------------------------------------------------------------------
 
+    def search_record(self, **params):
+        """
+        Search for (and jump to) the first record matching a set of field
+        values.
+
+        @param params: search conditions in the notation C{fieldname=value}
+            where the fieldname is the name of a GFField.
+        @returns: True if a record was found, False otherwise.
+        """
+
+
+        # First, convert the fieldname/value pairs to column/value pairs.
+        cond = {}
+        for (fieldname, value) in params.iteritems():
+            field = self._fieldMap[fieldname]
+            cond[field.field] = field.reverse_lookup(value)
+
+        self.__resultset.findRecord(cond)
+
+
     # -------------------------------------------------------------------------
     # Status information
     # -------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.