Making Session model and SessionStore classes more easily extendable
|Reported by:||sergeykolosov||Owned by:||sergeykolosov|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
While developing a feature the involves adding an extra database field to the Session model (thus creating a new session backend based on Django's one), I faced the need to copy almost everything from models.py, backends/db.py and backends/cached_db.py.
The reason why one have to do that, is the way that Session model is imported and used inside backends/db.py and backends/cached_db.py, and the way SessionStore class imported and used inside models.py.
Since the custom backend is a part of a shared package, which is intended to be used with multiple versions of Django, it's challenging to do that given the above.
I suggest the following changes:
- extract an abstract base model from Session;
- make Session class a property of SessionStore class, removing hardcoded usages;
- make key_prefix a property of SessionStore, defaulting to KEY_PREFIX;
- (anything else to make building a custom backend based on Django's one easier).
Change History (14)
comment:1 Changed 2 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:2 Changed 2 years ago by sergeykolosov
- Owner changed from nobody to sergeykolosov
- Status changed from new to assigned
comment:6 Changed 21 months ago by berkerpeksag
- Patch needs improvement set
- Version changed from 1.6 to master
comment:10 Changed 12 months ago by timgraham
- Triage Stage changed from Accepted to Ready for checkin
comment:11 Changed 12 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from assigned to closed