dabo Commit
Revision 6041
Date: 2010-09-30 06:43:58 -0700 (Thu, 30 Sep 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6041
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Added the locate() method, at the request of Paul, as a variant of the current
seek() method. This returns a boolean that indicates if a matching value was
found in the data. It has an optional 'movePointer' parameter (default=True);
setting that to False will return the boolean as usual, but will not change the
current RowNumber.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-09-30 05:55:18 UTC (rev 6040)
+++ trunk/dabo/biz/dBizobj.py 2010-09-30 13:43:58 UTC (rev 6041)
@@ -1294,6 +1294,25 @@
return self._CurrentCursor.hasPK(pk)
+ def locate(self, val, fld=None, caseSensitive=False, movePointer=True,
runRequery=True):
+ """ Search for a value in a field, and optionally move the
record pointer to the first
+ matching record. Returns the True or False, depending on
whether the value was found.
+
+ If runRequery is True, and the record pointer is moved, all
child bizobjs
+ will be requeried, and the afterPointerMove() hook method will
fire.
+
+ This is very similar to the seek() method, with two main
differences: there
+ is no concept of a near-match; either the value is found or it
isn't; the return
+ value is a boolean indicating if the match was found, not the
matching RowNumber.
+ """
+ ret = self._CurrentCursor.locate(val, fld, caseSensitive,
movePointer)
+ if ret:
+ if movePointer and runRequery:
+ self.requeryAllChildren()
+ self.afterPointerMove()
+ return ret
+
+
def seek(self, val, fld=None, caseSensitive=False, near=False,
runRequery=True):
""" Search for a value in a field, and move the record pointer
to the match.
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2010-09-30 05:55:18 UTC (rev 6040)
+++ trunk/dabo/db/dCursorMixin.py 2010-09-30 13:43:58 UTC (rev 6041)
@@ -1828,6 +1828,21 @@
self.RowNumber = rownum
+ def locate(self, val, fld=None, caseSensitive=True, movePointer=True):
+ """ Find the first row where the field value matches the passed
value.
+
+ Returns True or False, depending on whether a matching value
was located.
+ If 'fld' is not specified, the current sortColumn is used. If
'caseSensitive' is
+ set to False, string comparisons are done in a case-insensitive
fashion.
+
+ This is very similar to the seek() method, with two main
differences: there
+ is no concept of a near-match; either the value is found or it
isn't; the return
+ value is a boolean indicating if the match was found, not the
matching RowNumber.
+ """
+ recnum = self.seek(val, fld, caseSensitive=caseSensitive,
near=False, movePointer=movePointer)
+ return (recnum > -1)
+
+
def seek(self, val, fld=None, caseSensitive=True, near=False,
movePointer=True):
""" Find the first row where the field value matches the passed
value.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]