yes version 1.74.2 and  1.74.1 too
and yes session.id=form.vars.id is what i wanted to do

and session.mid = int(str(form.vars.id)) fixed it

the type of form.vars.id is <class 'gluon.sql.Reference'>
which does not pickle

On Dec 16, 9:38 pm, mdipierro <[email protected]> wrote:
> Let's summarize it.
>
>    session.id=form.vars.id
>
> does it work or not for you with web2py 1.74.2? If not, which is the
> python version? can you print form.vars.id and type(form.vars.id)?
>
> Massimo
>
> On Dec 16, 2:25 pm, selecta <[email protected]> wrote:
>
>
>
> > on a second thought this might be another bug than the first one
>
> > session.foo = form.vars.id
> > used to work
>
> > return form.vars.id
> > was just for the example and did also not work
>
> > On Dec 16, 9:22 pm, selecta <[email protected]> wrote:
>
> > > you guys are very picky i just wrote an easy example the original
> > > function was more complicated and cause an error that was very
> > > cryptic, btw something that should be improved too
>
> > > i tried to save the not existend var (form.vars.id) into a session
> > > variable which caused the following error
>
> > > session.mid = form.vars.id
>
> > > Error traceback
> > > Traceback (most recent call last):
> > >   File "/home//web2py/gluon/main.py", line 507, in wsgibase
> > >     session._try_store_on_disk(request, response)
> > >   File "/home//web2py/gluon/globals.py", line 375, in
> > > _try_store_on_disk
> > >     cPickle.dump(dict(self), response.session_file)
> > > PicklingError: Value returned by <function Reference_pickler at
> > > 0x98b225c> must be string or tuple
>
> > > In file: Framework
>
> > > no hint to what the actual line is that caused the problem, had to
> > > debug old school, deleting large to small blocks of code to narrow it
> > > down
>
> > > On Dec 16, 5:51 pm, mdipierro <[email protected]> wrote:
>
> > > > try
> > > > print form.vars.id
>
> > > > or
>
> > > > return str(form.vars.id)
>
> > > > On Dec 16, 8:50 am, Mengu <[email protected]> wrote:
>
> > > > > sorry, but why are you returning form.vars.id?
>
> > > > > On Dec 16, 3:42 pm, selecta <[email protected]> wrote:
>
> > > > > > in db.py
> > > > > > db.define_table('mytable',Field('myfield','string'))
>
> > > > > > in default.py
> > > > > > def index():
> > > > > >     form = SQLFORM(db.mytable)
> > > > > >     if form.accepts(request.vars, session):
> > > > > >         return form.vars.id
> > > > > >     response.flash = T('Welcome to web2py')
> > > > > >     return dict(message=T('Hello World'),form=form)
>
> > > > > > in index.html I added
> > > > > > {{=form}}
>
> > > > > > using the form athttp://127.0.0.1:8001/test/default/indexproduces
> > > > > > Traceback (most recent call last):
> > > > > >   File "/home//web2py/gluon/main.py", line 479, in wsgibase
> > > > > >     serve_controller(request, response, session)
> > > > > >   File "/home//web2py/gluon/main.py", line 194, in serve_controller
> > > > > >     page = run_controller_in(request.controller, request.function,
> > > > > > environment)
> > > > > >   File "/home//web2py/gluon/compileapp.py", line 435, in
> > > > > > run_controller_in
> > > > > >     vars = vars.xml()
> > > > > > TypeError: 'NoneType' object is not callable
>
> > > > > > used to work? is there a new mechanism to get the id of a newly
> > > > > > created record?

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" 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