onlinestatus

29 views
Skip to first unread message

pk

unread,
Jan 3, 2011, 5:13:47 PM1/3/11
to web2py-users
hi together,

i have a function for the onlineuser:

usersall=db(db.online.last_visit>time.time()-dt)
(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
return TABLE(*[TD(user.user_name) for user in usersall])

but i will to get all the onlineuser which are friends of mine.
here is my friendsdatabasetable:

#########################################################################
## Tabelle Freunde
#########################################################################
db.define_table('friends',
SQLField('userid',
default=auth.user.id if auth.user else 0,
writable=False, readable=False),
SQLField('hauptperson',
default=auth.user.user_name if auth.user else
0,
writable=False, readable=False,
label='Hauptperson'),
SQLField('freund', label='Freund'),
SQLField('freundseit', 'datetime',
default=request.now, label='Freund seit'),
SQLField('bestaetigt','boolean', default=False))

db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')

how can i get this list and how can i do the name clickable???

thanks for your help

peter

pk

unread,
Jan 4, 2011, 9:34:17 AM1/4/11
to web2py-users
can nobody help me???

Richard Vézina

unread,
Jan 4, 2011, 10:40:56 AM1/4/11
to web...@googlegroups.com
The model are missing for db.online

Richard

pk

unread,
Jan 4, 2011, 2:43:54 PM1/4/11
to web2py-users
#########################################################################
## Tabelle Onlineuser
#########################################################################
db.define_table('online',
SQLField('user_id',db.auth_user),
SQLField('last_visit','integer'))

Richard Vézina

unread,
Jan 4, 2011, 3:05:46 PM1/4/11
to web...@googlegroups.com
On Mon, Jan 3, 2011 at 5:13 PM, pk <peter.k...@youngdesigners.de> wrote:
hi together,

i have a function for the onlineuser:

usersall=db(db.online.last_visit>time.time()-dt)
(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)

This line should be :

 db(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)

Richard Vézina

unread,
Jan 4, 2011, 3:04:11 PM1/4/11
to web...@googlegroups.com
Ok and how do you fill up this table?

By the way SQLField is deprecated... Use Field() instead.


Richard

pk

unread,
Jan 4, 2011, 5:46:23 PM1/4/11
to web2py-users
@auth.requires_login()
def keepalive():
import time
db(db.online.id>0).delete() #evtl. weglassen
if auth.user.id:
if db(db.online.user_id==auth.user.id).count()==0:

db.online.insert(user_id=auth.user.id,last_visit=time.time())
else:

db(db.online.user_id==auth.user.id).update(last_visit=time.time())
dt = 5000
usersall=db(db.online.last_visit>time.time()-dt)
(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
return TABLE(*[TD(user.user_name) for user in usersall])


but what i need is not the auth.user which are online, i need the user
from another table for example friends.

mdipierro

unread,
Jan 4, 2011, 5:56:25 PM1/4/11
to web2py-users
There is a way add this functionality to gluon/contrib/comer_server.py
which is going to be more reliable (exact!) and faster (no db
access!).

I will add it in the next few days.

Massimo

pk

unread,
Jan 4, 2011, 6:13:06 PM1/4/11
to web2py-users
perfect. can you inform me massimo?
Message has been deleted

Richard Vézina

unread,
Jan 5, 2011, 10:39:04 AM1/5/11
to web...@googlegroups.com


On Wed, Jan 5, 2011 at 8:14 AM, Arun K.Rajeevan <the1...@gmail.com> wrote:
On Tuesday, January 4, 2011 3:05:46 PM UTC-5, Richard wrote:


On Mon, Jan 3, 2011 at 5:13 PM, pk <peter.k...@youngdesigners.de> wrote:
hi together,

i have a function for the onlineuser:

usersall=db(db.online.last_visit>time.time()-dt)
(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)

This line should be :

 db(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)

That's correct, may be some formatting problem, that's actually 
usersall=db((db.online.last_visit>time.time()-dt) & (db.online.user_id==db.auth_user.id)).select(db.auth_user.ALL) 

??

Richard

Reply all
Reply to author
Forward
0 new messages