Changeset 7077

Show
Ignore:
Timestamp:
02/03/12 13:25:36 (4 months ago)
Author:
paul
Message:

Fix to CursorRecord? to make:

"%(bogus_field)s" % self.Record

raise KeyError?("bogus_field")

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/db/__init__.py

    r6894 r7077  
    3636from dTable import dTable 
    3737from dDataSet import dDataSet 
     38from dabo.dException import FieldNotFoundException 
    3839 
    3940daboTypes = { 
     
    106107 
    107108        def __getitem__(self, key): 
    108             return self.__getattr__(key) 
     109            try: 
     110                val = self.__getattr__(key) 
     111            except FieldNotFoundException: 
     112                # __getitem__ added for a dict key-like interface, so convert 
     113                # the FieldNotFoundException to KeyError. 
     114                raise KeyError, key 
     115            return val 
    109116 
    110117        def __setitem__(self, key, val): 
    111             return self.__setattr__(key, val) 
     118            try: 
     119                return self.__setattr__(key, val) 
     120            except FieldNotFoundException: 
     121                # see comment in __getitem__ 
     122                raise KeyError, key 
    112123 
    113124    ## The rest of this block adds a property to the Record object