Implementing a notification system using session table

43 views
Skip to first unread message

Octavian G

unread,
Aug 1, 2015, 7:12:06 AM8/1/15
to web2py-users
Hello,

     I'd like to implement a notification system for various events happening in the app. I'd like it to work with the web2py_session_appname table, because it would mean I could piggyback that select. For that, I'd like to add a field to the sessions table, pointing to the user's ID in auth_user. This way, when I have an event, I could look up users' sessions and update their session data to reflect the fact that they have new notifications.

     I added a field to the session table (in gluon/globals), so that when it gets created it has a new field, user_id. Problem is, it can't reference auth_user. Further, I need to insert the user id in that field when a user logs in.  How would I do that ?

     Is there another way to programatically get a user's session(s), provided they're stored in the DB ?

黄祥

unread,
Aug 1, 2015, 7:34:35 AM8/1/15
to web2py-users
perhaps you can look it into this discussion

yet it record it on the auth_event table in database, i think you can modify it to store it in session table.

best regards
stifan

Anthony

unread,
Aug 1, 2015, 10:26:49 AM8/1/15
to web2py-users
You might try redefining the sessions table after defining the auth tables using the redefine=True argument: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#redefine.

Anthony
Reply all
Reply to author
Forward
0 new messages