On Mon, May 11, 2009 at 8:45 AM, Armin Ronacher <armin.ronac...@active-4.com> wrote: > All bugs are fixed now except for #10788. Now the problem with > closing that one is that this one requires a design descision. I > updated the ticket accordingly for jacob or anyone else to decide on > it. My personal opinion is that I consider it bad design for the > application to depend on the final filename of an uploaded file on the > filesystem. This makes it nearly impossible to create "atomic" > uploads for unique filenames.
I've been thinking this one over a bit, while everybody else was cleaning up the rest of my mess (thanks, guys!), and I have to agree with you, at least to a point. I've only been able to come up with two general uses for having the filename available at that point, and both of them have a better approach available. If you're using the filename to store it somewhere else, typically for denormalization, it'd be better to do that post-save, since then you know the record actually got saved in the database. Otherwise, you might be trying to access the content of the file, which would be better using the direct file access, which can often save yourself a round-trip to the storage backend (which can be a big win for paid storage solutions, like S3). I won't completely discount the possibility that there's a legitimate use case for having the final filename available in the pre-save hook, but I just don't see it. I'll admit that it's a change to current behavior, but I'm not sure there's a good way to get it working reliably. I think it's possible to do it if we register our own pre-save hook directly when the FileField is attached to the model class, but even then, we can't guarantee that it's the first handler to get registered, much less should we be relying on the ordering of signal handlers anyway. Unless somebody sees something I don't, I'm not sure there's a good way to get it working, nor do I see much to be gained from doing so. -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 django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---