Beaker storing sessions in DB after user logout's.
Try to run another script that will delete your old session's every 1
min (like in cron, or daemon)

For the "online" I use another table in DB

# Online-статус
online_table = Table('online', metadata,
    Column('user_id', types.Integer, ForeignKey('users.id'),
nullable=False, primary_key=True),
    Column('time_off', types.Integer, default=0), # время офлайна
    Column('time_last', types.DateTime), # последнее уведомление
    Column('time_before', types.DateTime), # предпоследнее уведомление
    Column('ip', types.Unicode(50)), # IP
)

The script:

query = session.query(Online).all()

for item in query:
    now = datetime.datetime.now()
    delta = now - item.time_last
    if delta.seconds < 59: # онлайн
        pass
    elif 1259 > delta.seconds >= 60: # 1-20 минут
        if item.time_off != delta.seconds/60:
            tt =
session.query(Online).filter(Online.user_id==item.user_id).one()
            tt.time_off = delta.seconds/60
            session.add(tt)
            session.commit()
    else: # удалять запись
        tt =
session.query(Online).filter(Online.user_id==item.user_id).one()
        session.delete(tt)
        session.commit()


On 28 фев, 22:33, Joril <[email protected]> wrote:
> Hi everyone!
> I'm trying to list the online users of my app by analyzing Beaker's
> sessions directly from the sessionstore (type = sqla in my case). By
> "online user" I mean "her session has been accessed in the last 30
> minutes", and it works nicely.
> My current problem is that when a user logs out, the session doesn't
> get deleted, so she still results as online... Is there a way to
> intercept the logout process and remove the session?
>
> I'm using repoze.who FriendlyFormPlugin to handle login/logout.. I
> tried to subclass it and override identify() or challenge(), but when
> I try to gain access to the session, I get a "No object (name:
> session) has been registered for this thread". Am I going the wrong
> way?
>
> Many thanks in advance!
>
> (I'm using Pylons 1.0)

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to