Just to note my code looks like this:

@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:

            db.xreflection.game.default = xgame.id
            #weird stuff happens here!
            db.xreflection.card.default = xcard.id
            db.xreflection.reflection_type.default = reflection_id

            form = SQLFORM(db.xreflection)
            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)


*cheers

Reply via email to