mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-21 07:31:00 +00:00
1 line
2.9 KiB
JSON
1 line
2.9 KiB
JSON
[{"user_id": 34431, "stars": [], "topic_id": 40500, "date_created": 1309117723.058301, "message": "I have some middleware that saves a users account object to a session variable to avoid multiple DB hits. If I delete that user, the session object isn't deleted, so if the user returns, while their account is out of the DB, they can still return (until the session terminates)", "group_id": 81, "id": 1490492}, {"user_id": 34431, "stars": [], "topic_id": 40500, "date_created": 1309117821.3342259, "message": "What is the best way to make sure the session object gets deleted too? I thought I would be able to simply query the session DB and pull out the users session with their user_id but this isn't possible. I was thinking of saving the most recent session_id for every user as a field in the Model and then writing a quick signal to delete the session like that?", "group_id": 81, "id": 1490494}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121514.4603839, "message": "since you can't query on it, you'd have to loop over each one (bad, bad idea)", "group_id": 81, "id": 1490733}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121576.1137519, "message": "the real issue here is that you're deleting data (in almost all circumstances, it's better to have an inactive bit column for an object)", "group_id": 81, "id": 1490738}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121642.6078579, "message": "Conveniently for you, the default User table already has this (it's called active, and is accessible from the default admin)", "group_id": 81, "id": 1490743}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121663.4752891, "message": "Just use that instead of deleting the User, and you're all set!", "group_id": 81, "id": 1490745}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121380.7730789, "message": "Go have a look at the django_session table (it's not in the default admin, use a cli or gui program to actually connect to your db). It has columns for the session key, serialized and encoded session data, and the expiration date.", "group_id": 81, "id": 1490719}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121405.5896521, "message": "To see how to grab data from the session data, have a look at how django-extensions does it: https://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/commands/print_user_for_session.py", "group_id": 81, "id": 1490727}, {"user_id": 1126, "stars": [], "topic_id": 40500, "date_created": 1309121501.2049749, "message": "However, this is going to get extremely expensive very quickly, once that django_session table gets tons of rows in it", "group_id": 81, "id": 1490731}, {"user_id": 14640, "stars": [], "topic_id": 40500, "date_created": 1309171075.0062461, "message": " django-admin.py cleanup will delete all expired sessions", "group_id": 81, "id": 1494302}] |