dabo Commit
Revision 4887
Date: 2008-12-27 08:07:29 -0800 (Sat, 27 Dec 2008)
Author: Ed
Trac: http://trac.dabodev.com/changeset/4887
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Added the method 'setValuesByDict()' to allow setting several fields with new
values by passing them to the bizobj as a dictionary in the form of: fieldName:
newValue. No UI updating is done.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2008-12-27 16:02:02 UTC (rev 4886)
+++ trunk/dabo/biz/dBizobj.py 2008-12-27 16:07:29 UTC (rev 4887)
@@ -1381,6 +1381,19 @@
return ret
+ def setValuesByDict(self, valDict, row=None):
+ """Allows you to set the value for multiple fields with one
call by passing a dict
+ containing the field names as keys, and the new values as
values.
+ """
+ cursor = self._CurrentCursor
+ if cursor is not None:
+ try:
+ ret = cursor.setValuesByDict(valDict, row)
+ except dException.NoRecordsException:
+ ret = False
+ return ret
+
+
_baseXML = """<?xml version="1.0" encoding="%s"?>
<dabocursor xmlns="http://www.dabodev.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2008-12-27 16:02:02 UTC (rev 4886)
+++ trunk/dabo/db/dCursorMixin.py 2008-12-27 16:07:29 UTC (rev 4887)
@@ -879,11 +879,18 @@
return True
+ def setValuesByDict(self, valDict, row=None):
+ """Set the value for multiple fields with one call by passing a
dict containing
+ the field names as keys, and the new values as values.
+ """
+ for fld, val in valDict.items():
+ self.setFieldVal(fld, val, row)
+
+
def setFieldVal(self, fld, val, row=None):
"""Set the value of the specified field."""
if self.RowCount <= 0:
raise dException.NoRecordsException(_("No records in
the data set"))
-
if row is None:
row = self.RowNumber
_______________________________________________
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]