def addto_playlist( udb, scuid, nwords): songs = systemdb.mquery( {'nwords':nwords, 'stype':'mv'}) snolist=[s['sno'] for s in songs[:10]] # a shelve db can't deliberately update like a dict, we need to # convert it to a dict and update by shelve.update() udic=dict(udb) udic[scuid]['playlist']=snolist udb.update( udic) print 'add {0} to user {1}'.format( snolist, scuid) udb.sync()
def func( self, d): songs = systemdb.mquery( { 'lang':6}) return { 'rtype':'song', 'rdata':songs}
def func( self, d): songs = systemdb.mquery( { 'lang':5, 'nwords': d+1}) return { 'rtype':'song', 'rdata':songs}