bug in crud with load and ajax=false

38 views
Skip to first unread message

apple

unread,
Jul 19, 2011, 6:44:59 AM7/19/11
to web2py-users
The following works fine with the SQLFORM line and ajax=false or
ajax=true. However replacing SQLFORM line with the CRUD line it works
with ajax=true but fails with ajax=false, generating one of those
annoying "restricted errors". I am guessing related to previous issue
with request.vars and load?

CONTROLLER
def test():
return dict()
def testload():
form=crud.update(db.customer,"1")
#form=SQLFORM(db.customer,"1")
return dict(form=XML(form.xml()))
TEST.HTML VIEW
{{extend 'layout.html'}}
{{=LOAD(c='crm',f='testload.load', ajax=False, ajax_trap=True)}}
TESTLOAD.LOAD VIEW
{{=form}}

apple

unread,
Jul 19, 2011, 8:56:08 AM7/19/11
to web2py-users
I note that when ajax=False then request.vars is a dict rather than a
storage object.

Anthony

unread,
Jul 19, 2011, 9:50:37 AM7/19/11
to web...@googlegroups.com
Good catch. I'll submit a patch.

On Tuesday, July 19, 2011 8:56:08 AM UTC-4, apple wrote:
I note that when ajax=False then request.vars is a dict rather than a
storage object.

Anthony

unread,
Jul 19, 2011, 12:40:50 PM7/19/11
to web...@googlegroups.com
Oops, forgot we already fixed that in trunk, so it will be work properly in the next release.
 
Anthony

apple

unread,
Jul 19, 2011, 4:28:45 PM7/19/11
to web2py-users
I downloaded the nightly build source and copied it on top of my
web2py directory. Still get the request.vars as dict. Is that
expected?

apple

unread,
Jul 19, 2011, 4:35:31 PM7/19/11
to web2py-users
I just noticed all the files on the "nightly build" except directories
are dated 26th June. Is this not updated nightly?

Anthony

unread,
Jul 19, 2011, 4:39:11 PM7/19/11
to web...@googlegroups.com
Nightly build is not the same as trunk -- I'm not sure when it was last updated. You can pull trunk from the Google Code repository via Mercurial (you need to have Mercurial installed): http://code.google.com/p/web2py/source/checkout. Or you can just change the two relevant lines in your own copy of compileapp.py: http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#126 (change lines 124-125 in 1.97.1 to what's in lines 126-127 in trunk) -- it just uses Storage(vars) in place of vars.
 
Anthony

On Tuesday, July 19, 2011 4:28:45 PM UTC-4, apple wrote:
I downloaded the nightly build source and copied it on top of my
web2py directory. Still get the request.vars as dict. Is that
expected?

Anthony

unread,
Jul 19, 2011, 4:40:39 PM7/19/11
to web...@googlegroups.com
Right, not really updated nightly. I think that build was originally intended to encourage testing before new releases, but few people actually do any testing.
 
Anthony

On Tuesday, July 19, 2011 4:35:31 PM UTC-4, apple wrote:
I just noticed all the files on the "nightly build" except directories
are dated 26th June. Is this not updated nightly?

Sebastian E. Ovide

unread,
Jul 19, 2011, 4:50:58 PM7/19/11
to web...@googlegroups.com
:D I've noticed it !
--
Sebastian E. Ovide




Sebastian E. Ovide

unread,
Jul 20, 2011, 5:38:18 AM7/20/11
to web...@googlegroups.com
Hi Anthony,

I have not tested the trunk yet, but I have change those two lines

            other_request.vars = Storage(vars)
            other_request.get_vars = Storage(vars)

I still get an error:

invalid view (default/crud_in_comp.load)

(in index.html)
{{=LOAD('default','crud_in_comp.load',ajax_trap=True)}}

(in default.py)
def crud_in_comp():
    return dict(crud=crud.create(db.auth_user,message=None))

any other file involved in that fix ?
--
Sebastian E. Ovide




Anthony

unread,
Jul 20, 2011, 9:12:29 AM7/20/11
to web...@googlegroups.com
Do you have a /views/default/crud_in_comp.load view? If not, for now you'll need one, as generic views aren't working in non-ajax components at the moment (this should be fixed soon).
 
Anthony

On Wednesday, July 20, 2011 5:38:18 AM UTC-4, sebastian wrote:
Hi Anthony,

I have not tested the trunk yet, but I have change those two lines

            other_request.vars = Storage(vars)
            other_request.get_vars = Storage(vars)

I still get an error:

invalid view (default/crud_in_comp.load)

(in index.html)
{{=LOAD('default','crud_in_comp.load',ajax_trap=True)}}

(in default.py)
def crud_in_comp():
    return dict(crud=crud.create(db.auth_user,message=None))

any other file involved in that fix ?

On Tue, Jul 19, 2011 at 9:39 PM, Anthony <abas...@gmail.com> wrote:
Nightly build is not the same as trunk -- I'm not sure when it was last updated. You can pull trunk from the Google Code repository via Mercurial (you need to have Mercurial installed): http://code.google.com/p/web2py/source/checkout. Or you can just change the two relevant lines in your own copy of compileapp.py: http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#126 (change lines 124-125 in 1.97.1 to what's in lines 126-127 in trunk) -- it just uses Storage(vars) in place of vars.
 
Anthony

On Tuesday, July 19, 2011 4:28:45 PM UTC-4, apple wrote:
I downloaded the nightly build source and copied it on top of my
web2py directory. Still get the request.vars as dict. Is that
expected?




--
Sebastian E. Ovide




Sebastian E. Ovide

unread,
Jul 20, 2011, 9:43:28 AM7/20/11
to web...@googlegroups.com
adding a default default/crud_in_comp.load made the trick.
--
Sebastian E. Ovide


Reply all
Reply to author
Forward
0 new messages