etianen/django-reversion — Issue #114: Share model registration between multiple RevisionManagers
Author: SystemParadox
Created: 2011-12-06 16:11:28+00:00
State: open

Hi.

I'm currently implementing a RevisionManager that will allow the 'before' revision to be saved, by hooking into pre_save instead of post_save. I would like to provide a way to link this manager to the default one (or any other 'normal' manager), so that they will share exactly the same model registration, to avoid having to add a duplicate call to register() my manager for every model.

I currently have them sharing the same _registered_models dictionary, but this doesn't connect up the signals. I have a few ideas, but all of them have downsides:
1. Change all models to call my register() method and pass that to the default manager (undesirable, I would like to avoid having to change the models if possible)
2. Provide some sort of hook into RevisionManager.register() to call my register() method (where? Need to guarantee that no models have been registered)
3. Wait until all models have been registered and then add signals in an iterator (where? Need to guarantee that all models have been registered)
4. Replace default_revision_manager with some sort of stack that managers can be subscribed to?

Please share if you have any thoughts on how I should or shouldn't go about doing this.

Thanks.
Simon