On 05/12/2010 18:20, Alan Harris-Reid wrote:
Hi, When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/yyyy' format needs to be converted to a Python date-object or 'yyyy-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yy', but that can cause problems when data is retrieved). Question - at what point should the data be converted? a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called). b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command). In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing? Any opinions would be appreciated.
I would use a standardised 'international' form as much as possible, converting to it as early as possible and from it as late as possible. This applies to dates, text (using Unicode internally), etc. -- http://mail.python.org/mailman/listinfo/python-list