Anyone able to help with this? No pressure, just hoping I can get some insight from one of the Gurus :-)
*cheers On Thu, Nov 10, 2011 at 11:22 AM, Andrew Evans <andrew.rusty...@gmail.com>wrote: > Hello I am trying to randomly select from entries in my database then > store that random result. The problem is its storing the wrong result (I > think its storing the previous random selection) > > Any ideas how I can achieve my goal? > > > @auth.requires_login() > def xreflection(): > game_id = request.args(0) > reflection_id = request.args(1) > if reflection_id == None: > return dict(redirect(URL('error','invalid'))) > if (game_id == None): > return dict(redirect(URL('error','invalid'))) > gameDB = db(db.xgame.id == int(game_id)).select() or > redirect(URL('error','invalid')) > cardDB = db(db.xcard.type == > int(reflection_id)).select(orderby='<random>',limitby=(0,1)) or > redirect(URL('error','invalid')) > for xcard in cardDB: > for xgame in gameDB: > > form = SQLFORM(db.xreflection) > db.xreflection.game.default = xgame.id > #weird stuff happens here! > db.xreflection.card.default = xcard.id > > db.xreflection.reflection_type.default = reflection_id > if form.accepts(request.vars, session): > db.notification.insert(receptient = xgame.userinfo, title > = form.vars.title, description = 'has responded to',type = > reflection_id,xgame=xgame.id) > session.flash = 'You have successfully reflected.' > return dict(redirect(URL('view','xgame',args=xgame.id))) > elif form.errors: > response.flash = 'Please correct the highlighted fields' > return dict(form=form, xgame=xgame,xcard=xcard) > else: > return dict(form=form, xgame=xgame,xcard=xcard) > >