There is a bug in keepvalues and crud. I fixed it in trunk but that
was not causing your problem.

This code works for me:

@auth.requires_login()
def customcreate():
    crud.settings.keepvalues = True
    if not session.create: session.create = []
    form = crud.create(db.ttt, onvalidation=r, onaccept=f)
    return dict(form=form)

def f(form): session.create.append(form.vars.id)
def r(form): form.vars.total_payd=form.vars.total_amount-
form.vars.total_credit

Massimo

On Jun 9, 9:35 pm, Rui Gomes <[email protected]> wrote:
> yes i set crud.settings.keepvalues=True, and what happen is when i call the
> function customcreate, the function don't return the form but a redirection
> to the index page, but if i try the same application with  1.62 version and
> work fine :(
>
> PS: i double check in different machines
>
> On Mon, Jun 8, 2009 at 3:26 PM, mdipierro <[email protected]> wrote:
>
> > I do not see how the last update may be causing this problem.
> > have you set crud.settings.keepvalues somewhere?
> > Is anybody else having problem with crud.create and the latest trunk?
>
> > Massimo
>
> > On Jun 8, 9:00 am, NewBeen <[email protected]> wrote:
> > > This last update break my application,
>
> > > now my function
>
> > > ### Controller ####
>
> > > @auth.requires_login()
> > > def customcreate():
>
> > >     try:
> > >         if session.create:
> > >             pass
> > >     except:
> > >         session.create=[]
>
> > >     try:
> > >         form = crud.create('databasedp',onvalidation=lambda form:r
> > > (form), onaccept=lambda form: f(form)) #i just put this here to debug
> > >     except Exception, inst:
> > >         print inst
>
> > >     return dict(form=form)
>
> > > def f(form):
>
> > >     if session.create:
> > >         session.create.append(form.vars.id)
> > >     else:
> > >         session.create=[form.vars.id]
>
> > > def r(form):
> > >     form.vars.total_payd=form.vars.total_amount-form.vars.total_credit
>
> > > ################################################################
>
> > > Always return
>
> > > #####
> > > (303, 'You are being redirected <a href="/Dominos_Times/default/
> > > index">here</a>'
> > > , {'Content-Type': 'text/html', 'Location': '/Dominos_Times/default/
> > > index'})
> > > ###
>
> > > But work fine in before this last update!
>
> > > On 8 Jun, 12:45, mdipierro <[email protected]> wrote:
>
> > > > in thunk in 5 minutes
>
> > > > crud.settings.keepvalues=True before calling crud.update()
>
> > > > On Jun 8, 5:14 am, NewBeen <[email protected]> wrote:
>
> > > > > Greetings,
>
> > > > > How can i do this put keepvalues=True when i use the function
> > > > > crud.create()
>
> > > > > i already try:
>
> > > > > ### CODE ###
>
> > > > > form = crud.create('databasedp',onvalidation=lambda form:r(form))
>
> > > > > def r(form):
> > > > >    if form.accepts(request.vars,session,keepvalues=True):
> > > > >         response.flash="Accept form"
>
> > > > > ### END ###
>
> > > > > and
>
> > > > > ### CODE ###
>
> > > > > form = crud.create('databasedp', onaccept=lambda form: f(form))
>
> > > > > def f(form):
> > > > >    if form.accepts(request.vars,session,keepvalues=True):
> > > > >         response.flash="Accept form"
>
> > > > > #### END ####
>
> > > > > But nothing of this work :( any ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to