Strange behavior with firefox

4 views
Skip to first unread message

Jose

unread,
Jul 15, 2009, 2:30:33 PM7/15/09
to web2py Web Framework
The situation is the following one:



It is a wizard with four forms (in this massimo helped me a time ago):



solicitud -> domicilio1 -> domicilio2 -> domicilo3 -> final

The code is the following one:

def solicitud():
session.documento = None
session.vars = None

form = SQLFORM(db.MatriculasSolicitud, submit_button='Siguiente
>')

if form.accepts(request.vars, session):
session.documento =
request.vars.NumeroDocumento
redirect(URL(r=request, f='domicilio', args=['1']))
return dict(form=form)

def domicilio():
if session.documento is None:
redirect(URL(r=request, c='default', f='index'))

if not len(request.args) > 0:
redirect(URL(r=request, c='default', f='index'))

tipodom = request.args[0]
boton = 'Siguiente >'
proximo = 'domicilio'
if tipodom == '1':
idtipo = 2
parametro = '2'
elif tipodom == '2':
idtipo = 1
parametro = '3'
else:
idtipo = 4
boton = 'Aceptar'
proximo = 'final'
parametro = ''

form = SQLFORM(db.DomiciliosSolicitud, submit_button=boton)

if session.vars:
form.vars = session.vars

db.DomiciliosSolicitud.IdMatricula.default = session.documento
db.DomiciliosSolicitud.IdTipoDomicilio.default = idtipo

if form.accepts(request.vars, session):
if idtipo != 4:
session.vars = form.vars
else:
session.vars = None
redirect(URL(r=request, f=proximo, args=parametro))
return dict(form=form, tipodom=tipodom)


The domicilio loaded in domicilio1 will appear in the following forms,
being able to be modified in case of being necessary.

This works well with Opera and with IE, but with firefox the following
thing happens:

I fill the first form (solicitud): Ok
After filling the second form, acceptance and it does not go to the
third, but it shows me again the second. If the complete thing again,
now if it go to the third.
The same thing happens with the third one with regard to the quarter.

I repeat, with Opera and with IE it works well.
I it tried with firefox 3.0.x and 3.5 so much in windows as in
freebsd. Mistake is not produced, there are no messages of the
validators. Simply them it is necessary to load two times.

Regards
Jose

mdipierro

unread,
Jul 15, 2009, 3:48:54 PM7/15/09
to web2py Web Framework
I do not see the problem. Can you try (just out of curiosity) replace

session.vars = ...

with

session.vars = dict(...)

Jose

unread,
Jul 16, 2009, 6:34:40 PM7/16/09
to web2py Web Framework


On 15 jul, 19:48, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I do not see the problem. Can you try (just out of curiosity) replace
>
> session.vars = ...
>
> with
>
> session.vars = dict(...)
>

Do you say to create the dictionary with the names of the fields? I do
not know do like the code.

Before I wrote that this happens when I fill the forms 2, 3 and 4, was
wrong, only it happens in the second form (domicilio1 to domicilio2).

Also I tried with Konqueror and it works well.

Jose

mdipierro

unread,
Jul 16, 2009, 9:47:49 PM7/16/09
to web2py Web Framework
I mean replace

session.vars=form.vars

with

session.vars=dict(form.vars)

Does it change anything? Are these custom forms? How do the views look
like?

Jose

unread,
Jul 16, 2009, 10:18:15 PM7/16/09
to web2py Web Framework


On 17 jul, 01:47, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I mean replace
>
>   session.vars=form.vars
>
> with
>
>   session.vars=dict(form.vars)
>
> Does it change anything? Are these custom forms? How do the views look
> like?
>

Now from domicilio1 to domicilio2: Ok.
A mistake takes is produced from domicilio2 to domicilio3

Error traceback
Traceback (most recent call last):
File "/usr/home/jose/web2py2/gluon/restricted.py", line 176, in
restricted
exec ccode in environment
File "/usr/home/jose/web2py2/applications/autogestion/controllers/
solicitud.py", line 140, in <module>
File "/usr/home/jose/web2py2/gluon/globals.py", line 100, in
<lambda>
self._caller = lambda f: f()
File "/usr/home/jose/web2py2/applications/autogestion/controllers/
solicitud.py", line 60, in domicilio
if form.accepts(request.vars, session):
File "/usr/home/jose/web2py2/gluon/sqlhtml.py", line 839, in accepts
self.vars.id = self.table.insert(**fields)
AttributeError: 'dict' object has no attribute 'id'

Jose

mdipierro

unread,
Jul 16, 2009, 10:27:46 PM7/16/09
to web2py Web Framework
Now replace

form.vars = session.vars

with:

form.vars.update(session.vars )

this will fix the latter problem

Now I understand what is going not but not why the browser makes a
difference. You are trying to store a gluon.storage.Storage object in
the session. Session can serialize it but fails to de-serialize it
when the session is retrieved. So you have so take the form.vars and
convert to a dictionary when storing it session.

It is a rule in web2py that you cannot store objects in session (only
primitive types, lists, dicts and combinations).

Massimo

Jose

unread,
Jul 16, 2009, 10:42:21 PM7/16/09
to web2py Web Framework


On 17 jul, 02:27, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Now replace
>
>    form.vars = session.vars
>
> with:
>
>    form.vars.update(session.vars )
>
> this will fix the latter problem
>
> Now I understand what is going not but not why the browser makes a
> difference. You are trying to store a gluon.storage.Storage object in
> the session. Session can serialize it but fails to de-serialize it
> when the session is retrieved. So you have so take the form.vars and
> convert to a dictionary when storing it session.
>
> It is a rule in web2py that you cannot store objects in session (only
> primitive types, lists, dicts and combinations).
>
> Massimo
>

Now yes it works well. I do not also deal because the different
behaviors of the browsers.

Thank you very much for your help.

Jose
Reply all
Reply to author
Forward
0 new messages