On 4/17/07, Gulopine <[EMAIL PROTECTED]> wrote:

> My main questions are these:
>
> * Am I right in thinking that Django's to_python method should be used
> for type coercion, rather than relying solely on backend drivers?

Historically, to_python existed for the manipulator framework to
convert text-based field input into a Python representation suitable
for use on a backend.

However, manipulators are going away, and conversion of this type has
been deferred to the field itself. The serializers have found a new
use for to_python (converting serialized strings into Python values),
but the domain remains the same - converting strings into data values.

Although some of the to_python methods are designed to convert non-str
input into valid Python output, I don't believe it has ever been the
intention that to_python be used for coercion. AFAIK, the database
backends _should_ be providing data in a valid and useful Python
format.

Coercion of the type you describe is not required for any field
currently supported. I would be hesitant to include coercion as a core
part of the framework unless there is a generic need to coerce
database values into Python values in some way other than that
performed by the database backend. Can you provide any use cases other
than your DurationField that require this sort of functionality?

> * Are there other situations than database access where this type of
> coercion might not be happening correctly?

The MySQL backend already contains code to coerce some date fields
(and on mysql_old, boolean fields, too). However, this is handled as a
data-correction interface on the MySQL backend, rather than a
field-level fix.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to