Present in recent commits of versions 1.8 and 1.7
Commit: c1493879d98328040b36ad93cd104c0b3b546772
Commit: bbcbacf0ad4fc9aa89d13c35f4b084185b284a49
Summary summed it up. But maybe the Storage class should be calling
get_valid_name like the docs suggest. -see (_save)
[https://docs.djangoproject.com/en/1.7/howto/custom-file-storage/]
{{{
"_save(name, content)¶
Called by Storage.save(). The name will already have gone through
get_valid_name() and get_available_name(), and the content will be a File
object itself."
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24105>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Database layer (models, ORM) => File uploads/storage
* needs_tests: => 1
* needs_docs: => 1
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
This might be a reasonable change, but we need to think if it might break
backwards compatibility in any way. It will also need tests and docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:1>
* needs_better_patch: 0 => 1
Comment:
The patch raises a `SyntaxError` at the following line:
{{{#!diff
+ directory_name, filename =
os.path.split(self.upload_to(instance, filename)
}}}
The `else` clause is not needed:
{{{#!python
if callable(self.upload_to):
# do stuff
return os.path.join(self.get_directory_name(),
self.get_filename(filename))
}}}
Indentation should be 4 spaces.
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:2>
* version: 1.7 => master
Comment:
With this change, the documentation of get_valid_name should also be
updated to clarify that the passed name might come from `upload_to` also.
[https://docs.djangoproject.com/en/1.7/howto/custom-file-storage/]
{{{
get_valid_name(name)¶
Returns a filename suitable for use with the underlying storage system.
The name argument passed to this method is the original filename sent to
the server, after having any path information removed.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:3>
* status: new => assigned
* owner: nobody => abhaga
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:4>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
Comment:
I have created a pull request at
[https://github.com/django/django/pull/4603] with documentation & test
cases based on the original patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:5>
* cc: abhaga (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"9de9c240178bd9f61f55dad07e76ea458f0291f5" 9de9c240]:
{{{
#!CommitTicketReference repository=""
revision="9de9c240178bd9f61f55dad07e76ea458f0291f5"
Fixed #24105 -- Called Storage.get_valid_name() when upload_to is callable
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24105#comment:7>