def typeCheckAndConvert(self, val, aname, attr): #nulls always allowed (unless the db says no) if val is None: return val if _isDateKind(attr): if not (Date.isDateTime(val) or val is SYSDATE): val = DateTime.DateTimeFrom(val) val = _dateConvertToDB(val, attr) elif (_isNumber(attr) and not isinstance(val, types.FloatType) and not isinstance(val, types.IntType)): raise TypeError, ('trying to assign %s to %s and is not' ' a number') % (val, aname) elif _isString(attr) and not isinstance(val, types.StringType): raise TypeError, 'trying to assign %s to %s and is not a string' % ( val, aname) return val
def _dateConvertFromDB(val, type): if val is None: # DateTimeFrom can't handle None as an argument return None return DateTime.DateTimeFrom(sapdbapi.valTranslation[type](val))
def _dateConvertFromDB(val, type): return DateTime.DateTimeFrom(sapdbapi.valTranslation[type](val))