dabo Commit
Revision 5655
Date: 2010-02-05 11:08:40 -0800 (Fri, 05 Feb 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5655
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Added biz.hasPK() method. It answers the question "is this PK value present in
the dataset?" It doesn't move the pointer or have any side-effects, and is
optimized to return the answer to this question as fast as possible.
I'm using this to determine if a lookup bizobj needs to be requeried or not.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-02-05 15:42:32 UTC (rev 5654)
+++ trunk/dabo/biz/dBizobj.py 2010-02-05 19:08:40 UTC (rev 5655)
@@ -1246,6 +1246,11 @@
raise dabo.dException.RowNotFoundException, _("PK Value
'%s' not found in the dataset") % str(pk)
+ def hasPK(self, pk):
+ """Return True if the passed PK value is present in the
dataset."""
+ return self._CurrentCursor.hasPK(pk)
+
+
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-02-05 15:42:32 UTC (rev 5654)
+++ trunk/dabo/db/dCursorMixin.py 2010-02-05 19:08:40 UTC (rev 5655)
@@ -1767,6 +1767,15 @@
return row
+ def hasPK(self, pk):
+ """Return True if the passed pk is present in the dataset."""
+ pks = (v[self.KeyField] for v in self._records)
+ for trial_pk in pks:
+ if trial_pk == pk:
+ return True
+ return False
+
+
def moveToPK(self, pk):
""" Find the record with the passed primary key, and make it
active.
_______________________________________________
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]