Changeset 362

Show
Ignore:
Timestamp:
05/19/08 22:16:04 (7 months ago)
Author:
johnbywater
Message:

Defending against non-integer encoded record id values.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/dm/db.py

    r356 r362  
    183183        def get(self, className, id): 
    184184            "Retreive record of domain object." 
     185            try: 
     186                id = int(id) 
     187            except: 
     188                msg = "Couldn't cast id to int for %s: %s" % (className, id) 
     189                raise Exception, msg 
    185190            recordClass = self.getRecordClass(className) 
    186191            return recordClass.get(id)  # todo: pass transaction 
     
    11341139                if self.meta.attributeDbNames[name].isDomainObjectRef: 
    11351140                    name += '_id' 
     1141            if name == 'id': 
     1142                value = int(value) 
    11361143            # todo: expand for all database systems 
    11371144            sqlSafeValue = sqlrepr(value, 'postgres')