Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally avoid global event hooks #55

Open
adscib opened this issue Mar 15, 2023 · 2 comments
Open

Optionally avoid global event hooks #55

adscib opened this issue Mar 15, 2023 · 2 comments

Comments

@adscib
Copy link
Contributor

adscib commented Mar 15, 2023

I played around with the library a bit and found that I can customize different behaviors by subclassing the sqlalchemy-file classes. I can do it without modifying the library code at all, the only thing that trips me is the global setup for event hooks. Is there any chance there could be an option to disable this global setup, or at least remove the hooks after loading the module? It would make the library quite a bit more flexible. In particular, #54 could be implemented externally. I'm not sure what's the right mechanism for that that's backwards compatible, though.

@jowilf
Copy link
Owner

jowilf commented Mar 23, 2023

Yes, I tried to make it easier to override File class for a custom logic. But you need to specify upload_type when declaring your FileField.

Column(FileField(upload_type=MyCustomFileClass))

I can add an option to disable/enable the changes tracking.
But this can lead to inconsistencies between your database and your object storage.

@adscib
Copy link
Contributor Author

adscib commented Mar 27, 2023

Indeed, I can subclass File and that works very well. I would also like to subclass StorageManager, but I don't see a way to update event hooks to use that subclass instead, so I was thinking if there was an option not to register them automatically, I could do that manually with my subclass instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants