Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#34575 closed New feature (wontfix)

Storage Signals

Reported by: Darrel O'Pry Owned by: nobody
Component: File uploads/storage Version: 4.2
Severity: Normal Keywords: storage signals
Cc: Darrel O'Pry Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

Change History (3)

comment:1 by Darrel O'Pry, 19 months ago

Cc: Darrel O'Pry added
Component: UncategorizedFile uploads/storage
Keywords: storage signals added
Type: UncategorizedNew feature

comment:2 by Natalia Bidart, 19 months ago

Resolution: wontfix
Status: newclosed

Hello Darrel! The current procedure to propose/request new features is to post a new message to the Django Forum to reach a wider audience and to get community consensus there. Once there is an agreement and desire to include the proposed feature in Django, this ticket can be re-opened. Thank you!

comment:3 by Darrel O'Pry, 19 months ago

Thanks for the feedback. I'm sorry but I'm not interested in yet another a login on yet another site.

Note: See TracTickets for help on using tickets.
Back to Top