Re: FileField should be a context manager

2011-12-09 Thread Ian Kelly
On Fri, Dec 9, 2011 at 11:49 AM, Florian Apolloner wrote: > > > On Thursday, December 8, 2011 11:36:53 PM UTC+1, Alex_Gaynor wrote: >> >> It isn't alreayd?!?!  All file objects django exposes should be context >> managers, I thought I added that to a base mixin class a while ago, but >> apparently

Re: FileField should be a context manager

2011-12-09 Thread Florian Apolloner
On Thursday, December 8, 2011 11:36:53 PM UTC+1, Alex_Gaynor wrote: > It isn't alreayd?!?! All file objects django exposes should be context > managers, I thought I added that to a base mixin class a while ago, but > apparently I didn't add it to the right thing. > Your memory serves you wel

Re: FileField should be a context manager

2011-12-08 Thread Alex Gaynor
On Thu, Dec 8, 2011 at 5:35 PM, Jacob Kaplan-Moss wrote: > On Thu, Dec 8, 2011 at 2:07 PM, Martin Chase > wrote: > > This shouldn't be backwards incompatible, just implementing the > > __exit__ and __enter__ methods. > > > > Use case: > > > > class Obj(models.Model): > >file_field = models.F

Re: FileField should be a context manager

2011-12-08 Thread Jacob Kaplan-Moss
On Thu, Dec 8, 2011 at 2:07 PM, Martin Chase wrote: > This shouldn't be backwards incompatible, just implementing the > __exit__ and __enter__ methods. > > Use case: > >  class Obj(models.Model): >    file_field = models.FileField(upload_to="test") > ... >  obj = Obj() >  obj.file_field.save(filen

FileField should be a context manager

2011-12-08 Thread Martin Chase
This shouldn't be backwards incompatible, just implementing the __exit__ and __enter__ methods. Use case: class Obj(models.Model): file_field = models.FileField(upload_to="test") ... obj = Obj() obj.file_field.save(filename, content) ... with obj.file_field.open() as a_file: a_fil