On 10/28/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > I haven't been concentrating too much, since I'm pretty overloaded with > other things (both Django and real life) at the moment. But my general > impression is in line with yours, Marty: having two attributes and a > complex system of "if this and that then this happens" is flawed design. > Ideally, we should settle on one way to do this. For bonus points (and > strongly desired), make it easy to port from the existing code to the > new code -- e.g. via a simple search-and-replace -- if some kind of > backwards compatibility is needed.
Well, I can see two options for backwards-compatibility: - Tolerate either both strings and callables as values for upload_to: If a string is provided, it's passed to a utility function that returns a callable to process a strftime string. Then all the rest of the code could just assume a callable, but existing code would work unmodified. - Provide the utility function as a way to wrap existing upload_to argument strings. Something like this: Old: file = models.FileField(upload_to='%Y/%m/%d') New: from django.utils.dates import lazy_strftime file = models.FileField(upload_to=lazy_strftime('%Y/%m/%d')) Not exactly a pure search-and-replace (unless you use regex), but pretty close. And no, I'm not proposing any particular location for that utility function, just throwing it somewhere for the sake of an example. -Gul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---