On 14 ago, 19:18, VP <vtp2...@gmail.com> wrote:
> I have one table called "category", and another table called "post".
> When a new post is inserted, I want to increment "count" (an attribute
> of category) of the appropriate category.
>
> Unfortunately, I don't know how to access the post object right after
> it is inserted to find out which category was entered in order to
> increment the approach category entry.
>
> Can someone show me how to do this?
>
> Thanks.

Option 1

    form = SQLFORM(db.mytable)

    if form.accepts(request.vars, session):
        category = form.vars.category
        #code here
        ...
        redirect(a_url)
    elif form.errors:
        response.flash = 'errors'
    return dict(form=form)

Option 2

using onaccept: http://www.web2py.com/book/default/chapter/07

Jose

Reply via email to