Re: [web2py] Re: Best Method to implement a "like" button

2013-03-05 Thread Jaime Sempere
A little correction for any future visitor: compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s"), should be: compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" %row), Anyway the solution is great. Thanks a lot. El miƩrcoles, 12 de septiembre de 2012 00:54:45 UTC+2,

Re: [web2py] Re: Best Method to implement a "like" button

2012-09-18 Thread Mark Li
Thanks for the response guys! I'm going with rochabruno's method as it is the most straightfoward, I hadn't really looked into the compute capabilities. On Tuesday, September 11, 2012 3:55:21 PM UTC-7, rochacbruno wrote: > > The computation should be > > compute= lambda row: "%(username)s-%(song

Re: [web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread Bruno Rocha
The computation should be compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" % row --

Re: [web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread Bruno Rocha
db.define_table('likes', Field('username', 'reference auth_user'), Field('songname', 'reference songs'), Field('playlist_name', 'reference playlist'), Field('unique_key', unique=True, notnull=True, compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s"), ) Now on any

[web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread villas
Depends how you are displaying your list to do the liking and unliking. A few thoughts Make sure your composite index has the field which filters out the most records first. In your controller you may be able to cut out most queries by considering something like this: - Hit the DB once an

[web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread Mark Li
I went with the unique composite field index method (unique across 3 fields, not just 2), with my database as follows: db.define_table('likes', Field('username', 'reference auth_user'), Field('songname', 'reference songs'), Field('playlist_name', 'reference playlist')) if auth.is_log

[web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread villas
How about: in 'likes' make a unique composite index of both fields (created at DB level). Try to insert a record. If it fails (because of the index) then delete instead. On Monday, September 10, 2012 11:58:03 PM UTC+1, Mark Li wrote: > > I have 3 datatables as follows: > > > db.define_table(