Changeset 22
- Timestamp:
- 12/10/05 01:19:54
- Files:
-
- alamode.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
alamode.py
r21 r22 378 378 missing=object() 379 379 380 typenames = {'int': 'a whole number', 381 'long': 'a whole number', 382 'date': 'a date (of the form m/d/yyyy)', 383 'datetime': 'a date and time (of the form m/d/yyyy hh:mm:ss)', 384 'FixedPoint': 'a dollar amount', 385 'decimal': 'a dollar amount', 386 } 387 380 388 def coerce_in(paramMap, key, type, default=missing): 381 389 """coerce_in(paramMap, key, type, default=missing) -> instance of type. … … 393 401 else: 394 402 return default 395 return from_html.coerce(value, type) 403 404 try: 405 coerced = from_html.coerce(value, type) 406 except Exception, x: 407 msg = ("The value named '%s' should be %s, but the supplied value " 408 "(%s) could not be converted to that type.") 409 tname = type.__name__ 410 raise TypeError(msg % (key, typenames.get(tname, tname), value)) 411 return coerced 396 412 397 413 def coerce_out(obj, attr=missing, default=missing):
