Any time I see "FileField" in a subject line, my ears perk up, so I'll put in my thoughts on this subject.
On Dec 4, 2007 10:43 AM, Marc Garcia <[EMAIL PROTECTED]> wrote: > I've seen ticket #4339 ( http://code.djangoproject.com/ticket/4339 ) > about allowing django users to create FileFields or ImageFields that > overwrite files with same name. With the work being done in #5361, I'm doubting there'll be additions to FileField as it stands right now. Of course, I'm not a core maintainer, so I can't say for certain, but I'm the guy behind #5361, so call it an educated guess. That's not to say it won't happen, just probably not with that patch. > The ticket is in design decision needed. It's a little change, that > just add an extra feature and is not backward incompatible, so I think > that this stage is probably for thinking about if this change is > useful; so let me explain my case. I apologize for not knowing about this during the sprint, or I might have been able to make sure a decision was made. I haven't researched all the FileField tickets though, unfortunately. > I've a django application that allow each user to upload a picture in > their profiles (like an avatar). I prefer renaiming picture files to > the user name, for a best organitzation.For me it's meaningless > keeping history of my user pictures, so I want my files to be > overwritten. Makes sense so far. > What I can do without this patch is remove old files in my model > _save_FIELD_file method, but I think that it's not the right way. You're right, that isn't a very pretty way to go about it. > I think that my case isn't a special case, probably many people have > something like that, and probably there are many other cases where > file overwriting is useful. There may be, there may not be, but I think in light of #5361, there's a slightly different issue at work. The FileField updates will indeed make it possible to overwrite old files, and even clean up empty directories after deletion (#5966). It's just that neither of those are automatic, and making it happen isn't exactly straightforward. I started to write up some example code of how it would work after #5361 lands, but it ended being more complex than even I'm comfortable with. I'll see if there's a way to abstract out some of the os.path stuff in a way that will make it easier to do what you're asking. It might not be reasonable to do so, however, so you might just have to live with it being a little extra verbose. I'll mull it over while working on the code tonight and see what I come up with. -Gul P.S. I'll be taking this as a wake-up call to look at other FileField-related tickets to see what is/isn't going to be taken care of by #5361. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---