0

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/yyyy', 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.

Alan

asked Dec 5, 2010 at 18:24

2 Answers 2

2

I think it belongs in the validation. You want a date, but the web page inputs strings only, so the validator needs to check if the value van be converted to a date, and from that point on your application should process it like a date.

answered Dec 5, 2010 at 18:33
Sign up to request clarification or add additional context in comments.

Comments

1

I could be wrong, but I think there is no definite answer to this question. It depends on "language" level your framework provides. For example, if another parts of the framework accept data in non-canonical form and then convert it to an internal canonical form, it this case it would worth to support some input date formats that are expected.

I always prefer to build strict frameworks and convert data in front-ends.

answered Dec 5, 2010 at 18:39

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.