#34575: Storage Signals
-----------------------------------------+------------------------
Reporter: dopry | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
It would be nice if Storage emitted signals on file operations, so file
related processes can be implemented without tight coupling.
Use cases:
* purging files in CDNs
* generating derivative assets
* virus scanning
Proposed Signals:
* post_save
* post_delete
My initial thoughts on the implementation would be to modify
Storage.delete to delegate to ._delete like .save and to put the signal
triggering in .save and .delete. Alternatively, it could be implemented in
a Mixin like we are doing in our project.
{{{
storage_post_save = Signal()
storage_post_delete = Signal()
class SignalingStorageMixin:
def save(self, name, content, max_length=None):
super().save(name, content, max_length)
# send a signal so we can react as files are uploaded in order to
purge the cache.
storage_post_save.send(sender=self.__class__, name=name)
def delete(self, name):
"""
Delete the specified file from the storage system.
"""
super().delete(name)
storage_post_delete.send(sender=self.__class__, name=name)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34575>
Django <https://code.djangoproject.com/>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701882f20ae18-225b8c68-9453-4d63-a7e7-d1dff2c5c5a0-000000%40eu-central-1.amazonses.com.