dabo Commit
Revision 7077
Date: 2012-02-03 13:25:36 -0800 (Fri, 03 Feb 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7077

Changed:
U   trunk/dabo/db/__init__.py

Log:
Fix to CursorRecord to make:

  "%(bogus_field)s" % self.Record 

raise KeyError("bogus_field")



Diff:
Modified: trunk/dabo/db/__init__.py
===================================================================
--- trunk/dabo/db/__init__.py   2012-02-03 03:33:45 UTC (rev 7076)
+++ trunk/dabo/db/__init__.py   2012-02-03 21:25:36 UTC (rev 7077)
@@ -35,6 +35,7 @@
 from dConnectInfo import dConnectInfo
 from dTable import dTable
 from dDataSet import dDataSet
+from dabo.dException import FieldNotFoundException
 
 daboTypes = {
                "C": unicode,             ## text
@@ -105,10 +106,20 @@
                                self._cursor.setFieldVal(att, val)
 
                def __getitem__(self, key):
-                       return self.__getattr__(key)
+                       try:
+                               val = self.__getattr__(key)
+                       except FieldNotFoundException:
+                               # __getitem__ added for a dict key-like 
interface, so convert
+                               # the FieldNotFoundException to KeyError.
+                               raise KeyError, key
+                       return val
 
                def __setitem__(self, key, val):
-                       return self.__setattr__(key, val)
+                       try:
+                               return self.__setattr__(key, val)
+                       except FieldNotFoundException:
+                               # see comment in __getitem__
+                               raise KeyError, key
 
        ## The rest of this block adds a property to the Record object
        ## for each field, the sole purpose being to have the field



_______________________________________________
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]

Reply via email to