Re: [Django] #26495: Saving StringIO using custom storage class may result in empty content written to file

2016-04-21 Thread Django
#26495: Saving StringIO using custom storage class may result in empty content
written to file
-+-
 Reporter:  m-novikov|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  File |  Version:  master
  uploads/storage|
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * type:  Uncategorized => Cleanup/optimization
 * stage:  Unreviewed => Ready for checkin


Comment:

 It's a bit odd to me that `bool(file)` is based on the file's name, but in
 light of that, I guess this makes sense.

--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.d462d068377c726e08f817988fbc070d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26495: Saving StringIO using custom storage class may result in empty content written to file

2016-04-21 Thread Django
#26495: Saving StringIO using custom storage class may result in empty content
written to file
-+-
 Reporter:  m-novikov|Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  File |  Version:  master
  uploads/storage|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham ):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"4d1c229ee5cb210e8b592a8d9c87d4a66864328e" 4d1c229e]:
 {{{
 #!CommitTicketReference repository=""
 revision="4d1c229ee5cb210e8b592a8d9c87d4a66864328e"
 Fixed #26495 -- Added name arg to Storage.save()'s File wrapping.
 }}}

--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.8de0a136d28dfb81c96fbe1b7823a0bb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26495: Saving StringIO using custom storage class may result in empty content written to file

2016-04-15 Thread Django
#26495: Saving StringIO using custom storage class may result in empty content
written to file
-+-
 Reporter:  m-novikov|Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  File |  Version:  master
  uploads/storage|
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by m-novikov):

 * has_patch:  0 => 1


--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.ca44ca87d8898a447f0140f1dee5bff9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26495: Saving StringIO using custom storage class may result in empty content written to file

2016-04-12 Thread Django
#26495: Saving StringIO using custom storage class may result in empty content
written to file
-+-
 Reporter:  m-novikov|Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  File |  Version:  master
  uploads/storage|
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by m-novikov):

 Patch https://github.com/django/django/pull/6448

--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6addffed2345f023ccc33cbcf0b06f2b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26495: Saving StringIO using custom storage class may result in empty content written to file (was: Storage save method wraps StringIO in File object which is identified as False.)

2016-04-12 Thread Django
#26495: Saving StringIO using custom storage class may result in empty content
written to file
-+-
 Reporter:  m-novikov|Owner:  nobody
 Type:  Uncategorized|   Status:  new
Component:  File |  Version:  master
  uploads/storage|
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by m-novikov:

Old description:

> https://github.com/django/django/blob/master/django/core/files/storage.py#L50
> {{{
> #!python
> class Storage(object):
>
> def save(self, name, content, max_length=None):
> ...
> if not hasattr(content, 'chunks'):
> content = File(content)
> }}}
> For example if custom storage uses requests with post query.
> {{{
> #!python
> import requests
> class CustomStorage(object):
> def _save(self, name, content, max_length=None):
>   requests.post('http://testhost.org/upload', data=content)
> }}}
> But it will result in empty upload as bool(content) is False.
> Possibly better to pass a name to File object. To ensure bool(content) is
> True
> {{{
> #!python
> if not hasattr(content, 'chunks'):
> content = File(content, name=name)
> }}}

New description:

 https://github.com/django/django/blob/master/django/core/files/storage.py#L50
 {{{
 #!python
 class Storage(object):

 def save(self, name, content, max_length=None):
 ...
 if not hasattr(content, 'chunks'):
 content = File(content)
 }}}
 For example if custom storage uses requests with post query and we are
 saving StringIO object.
 {{{
 #!python
 from StringIO import StringIO

 from django.core.files.storage import Storage
 import requests

 class CustomStorage(Storage):
 def _save(self, name, content, max_length=None):
   requests.post('http://testhost.org/upload', data=content)
 custom_storage = CustomStorage()
 custom_storage.save('new_name', StringIO('content'))
 }}}
 But it will result in empty upload as bool(content) is False.
 Possibly better to pass a name to File object. To ensure bool(content) is
 True
 {{{
 #!python
 if not hasattr(content, 'chunks'):
 content = File(content, name=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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.c7cf305dd91385c2bd44ac93127f852f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.