Roundtrip SQL data especially datetime

Diez B. Roggisch deets at nospam.web.de
Sun Dec 17 10:34:07 EST 2006


> 
> The advantage of static typing in this context is that the variable still 
> holds the type even if the value happens to be null. Any value that has been 
> exposed to user input comes back as a string and has to be validated and 
> converted to the correct data type. Static typing provides a convenient 
> place to generically find out what that type is, to drive a 
> validator/convertor. There are many ways to do the equivalent in Python, and 
> I'm interested in any suggestions that save me some work.

While this information in statically typed languages _can_ be used (but 
not always is, in a web context), it also is available in the database 
schema, which ultimately decides what it groks and what not.

But this is - especially in web-development - only half the truth. 
Because even such a simple thing as reading a float value from the user 
gets complicated in the presence of different locales. It buys you 
nothing then to have static type declarations available.

A decent framework for webdevelopment, as e.g. TurboGears, allows you to 
declare form field validation and coercion rules, thus on a higher 
application level (your code), you only deal with the correctly typed 
values.

Diez



More information about the Python-list mailing list