Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-05-20 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by olau):

 rizumu: This bug is not particular to the admin. Also what you're talking
 about is the situation where the user is supposed to control the filename.
 This bug is about the case where the programmer is supposed to control the
 filename (where currently there's no simple knob in Django to say "this
 filename, and I mean it, no underscores").

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-05-20 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by rizumu):

 Just a quick thought from a UI standpoint in the Admin, it sure would be
 nice when you add an image for there to be a pop-up that showed you the
 image and proposed three options. A similar pop-up for an image could post
 some meta-data.

 Would you like to:
 Overwrite the existing image with the new one? (sitewide)
 Save the new image under a different name? (affects only this instance)
 Use the existing image? (No need to create a new one with an _ in the
 name)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-05-11 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by nwelch):

 Overriding both _save and get_available_name seems to do the trick for me.
 It *seems* that it should be unnecessary to override both, but overwriting
 _save wasn't enough, and only overriding get_available_name resulted in an
 infinite loop since _save demands that the file not exist (i.e. it won't
 do an actual overwrite -- but rather a delete, then a write).

 {{{
 from django.core.files.storage import FileSystemStorage
 class OverwriteStorage(FileSystemStorage):
 def _save(self, name, content):
 if self.exists(name):
 self.delete(name)
 return super(OverwriteStorage, self)._save(name, content)
 def get_available_name(self, name):
 return name
 }}}

 I disclaim any copyright to the above code.  (I'm guessing it would be
 considered too trivial to be copyrighted anyway, but just in case)

 Also, while this is maybe a bit more likely to cause race conditions,
 nothing particularly harmful happens as a result.  The thread will just
 have to try again until it succeeds.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-03-10 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Changes (by miracle2k):

  * owner:  miracle2k => Gulopine

Comment:

 Apparently I screwed up that last comment pretty badly - sorry. Not sure
 why the status changed.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-03-10 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  miracle2k  

Status:  new   | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Changes (by miracle2k):

 * cc: miracle2k (added)
  * owner:  Gulopine => miracle2k
  * status:  reopened => new

Comment:

 Without having tried it, I don't think the code given my elaatifi
 (overriding _save) will work, since at this point get_available_name

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-01-21 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  reopened  | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by elaatifi):

 With Django's new file access API there is more flexibity to deal with
 such problems.

 I think it's not a good idea to override get_available_name since it's a
 public methode
 that shouldn't have a side effect (I suppose) due to his name

 {{{class OverwriteStorage(FileSystemStorage):
 def _save(self, name, content):
 if self.exists(name):
 self.delete(name)
 return super(OverwriteStorage, self)._save(name, content)
 }}}

 Thank you

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #4339: Override an existing file, using Model.save_FIELD_file method,

2009-01-20 Thread Django
#4339: Override an existing file, using Model.save_FIELD_file method,
---+
  Reporter:  elaat...@gmail.com| Owner:  Gulopine   

Status:  reopened  | Milestone: 

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  FileField 
db fs-rf-docs
 Stage:  Design decision needed| Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by olau):

 Actually, with the default backend you've got a DoS entry if you allow
 your users to upload a profile picture with an {{{ImageField}}} (even if
 you check the size of the stuff they upload) - since it will leave the
 orphaned images behind. The attacker just needs to reupload files to fill
 up the available disk space which may be scarce on shared hosting.

 In any case, the current behaviour doesn't really make a lot of sense when
 you override upload_to to set a filename (e.g. using the db id) instead of
 relying on the name from the browser.

 I think it should work this way: when you reupload a file, it should be
 the same as first deleting the old file and then writing the new one
 (maybe in reverse order, with a bit of code to handle the case where the
 names are identical). What do you think?

 BTW, there's a snippet here with a custom backend that always overwrites:

 http://www.djangosnippets.org/snippets/976/

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---