[web2py] Re: How do I pass a query object to a different controller?
Just to be clear on exception (crash) : On clicking search, pickle error is seen if the url is like : http://127.0.0.1:8000/sampleapp/default/search2/edit/customer/2?_signature=... If it is simple : (first time search which works) : http://127.0.0.1:8000/sampleapp/default/search2 But no edit/view forms are seen on redirection from results view back to search2. -Sarbjit On Thursday, July 18, 2013 9:18:18 AM UTC+5:30, Sarbjit singh wrote: Thanks guys for the help. I followed the approach as suggested by Massimo, so I did the following : @auth.requires_login() def search2(): form,results = dynamic_search(db.customer) if form.process().accepted: session.results = results redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): results = session.results return dict(results=results) Please note that the dynamic_search is returning grid and form, so I am storing grid in the session. But I am still facing problems, not sure what wrong steps I am doing. For the first time, when I click on search, desired results are opened in controller results (in a new page). But when I click on edit/view of grid operation, some how the page gets redirected to search page and on subsequent search it crashes with the same problem (can't pickle ..). My question is when i click on edit operations on a grid, why it is redirecting to search. Isn't it is supposed to open edit form there itself? To me it looks like, since the grid was generated when the control was in the search2, so the links of the grid operations are pointing to search2 view though the results are now seen in different view results. So when I click on any operation, it is redirected to search2 view - BUT strangely contents of edit form are not seen (Not sure of the reason?). Can some one please help me to resolve this issue ? Is there a way I can recompute the grid links in results controller such that they do not redirect to search2 view. Also what could be the check added to avoid crash on subsequent search. Thanks Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
Now all the problems are solved, with problem remaining. Here is what I did to solve the problem : In the view for search2, I added the code as : {{extend 'layout.html'}} h1This is the default/search2.html template/h1 {{if results.update_form:}} {{=results}} {{elif results.view_form:}} {{=results}} {{else:}} {{=form}} {{pass}} Problem that is remaining is, when I click on Back button from the Edit/View operation of grid, it took me back to search form, but I want to see the search results. Can some one please help me on how to handle it? -Sarbjit On Thursday, July 18, 2013 12:36:25 PM UTC+5:30, Sarbjit singh wrote: Just to be clear on exception (crash) : On clicking search, pickle error is seen if the url is like : http://127.0.0.1:8000/sampleapp/default/search2/edit/customer/2?_signature=. .. If it is simple : (first time search which works) : http://127.0.0.1:8000/sampleapp/default/search2 But no edit/view forms are seen on redirection from results view back to search2. -Sarbjit On Thursday, July 18, 2013 9:18:18 AM UTC+5:30, Sarbjit singh wrote: Thanks guys for the help. I followed the approach as suggested by Massimo, so I did the following : @auth.requires_login() def search2(): form,results = dynamic_search(db.customer) if form.process().accepted: session.results = results redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): results = session.results return dict(results=results) Please note that the dynamic_search is returning grid and form, so I am storing grid in the session. But I am still facing problems, not sure what wrong steps I am doing. For the first time, when I click on search, desired results are opened in controller results (in a new page). But when I click on edit/view of grid operation, some how the page gets redirected to search page and on subsequent search it crashes with the same problem (can't pickle ..). My question is when i click on edit operations on a grid, why it is redirecting to search. Isn't it is supposed to open edit form there itself? To me it looks like, since the grid was generated when the control was in the search2, so the links of the grid operations are pointing to search2 view though the results are now seen in different view results. So when I click on any operation, it is redirected to search2 view - BUT strangely contents of edit form are not seen (Not sure of the reason?). Can some one please help me to resolve this issue ? Is there a way I can recompute the grid links in results controller such that they do not redirect to search2 view. Also what could be the check added to avoid crash on subsequent search. Thanks Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
Hi, you can use a dialog widget from jquery ui to pop up the form. Would be a nicer solution. Best regards Dmitri Husti Am Donnerstag, 18. Juli 2013 10:50:27 UTC+2 schrieb Sarbjit singh: Now all the problems are solved, with problem remaining. Here is what I did to solve the problem : In the view for search2, I added the code as : {{extend 'layout.html'}} h1This is the default/search2.html template/h1 {{if results.update_form:}} {{=results}} {{elif results.view_form:}} {{=results}} {{else:}} {{=form}} {{pass}} Problem that is remaining is, when I click on Back button from the Edit/View operation of grid, it took me back to search form, but I want to see the search results. Can some one please help me on how to handle it? -Sarbjit On Thursday, July 18, 2013 12:36:25 PM UTC+5:30, Sarbjit singh wrote: Just to be clear on exception (crash) : On clicking search, pickle error is seen if the url is like : http://127.0.0.1:8000/sampleapp/default/search2/edit/customer/2?_signature=. .. If it is simple : (first time search which works) : http://127.0.0.1:8000/sampleapp/default/search2 But no edit/view forms are seen on redirection from results view back to search2. -Sarbjit On Thursday, July 18, 2013 9:18:18 AM UTC+5:30, Sarbjit singh wrote: Thanks guys for the help. I followed the approach as suggested by Massimo, so I did the following : @auth.requires_login() def search2(): form,results = dynamic_search(db.customer) if form.process().accepted: session.results = results redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): results = session.results return dict(results=results) Please note that the dynamic_search is returning grid and form, so I am storing grid in the session. But I am still facing problems, not sure what wrong steps I am doing. For the first time, when I click on search, desired results are opened in controller results (in a new page). But when I click on edit/view of grid operation, some how the page gets redirected to search page and on subsequent search it crashes with the same problem (can't pickle ..). My question is when i click on edit operations on a grid, why it is redirecting to search. Isn't it is supposed to open edit form there itself? To me it looks like, since the grid was generated when the control was in the search2, so the links of the grid operations are pointing to search2 view though the results are now seen in different view results. So when I click on any operation, it is redirected to search2 view - BUT strangely contents of edit form are not seen (Not sure of the reason?). Can some one please help me to resolve this issue ? Is there a way I can recompute the grid links in results controller such that they do not redirect to search2 view. Also what could be the check added to avoid crash on subsequent search. Thanks Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
A query object cannot be put into a session unless you somehow serialize (but not with automated pickle/marshall/etc). On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
I am not aware of the word serialize, Is there any possibility to achieve it? On Wednesday, July 17, 2013 5:36:33 PM UTC+5:30, Massimo Di Pierro wrote: A query object cannot be put into a session unless you somehow serialize (but not with automated pickle/marshall/etc). On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
What I man you need to be able to build a string (or object) that represents the query and store this object in the query. Then retrieve the object and rebuild the query. On Wednesday, 17 July 2013 07:15:32 UTC-5, Sarbjit singh wrote: I am not aware of the word serialize, Is there any possibility to achieve it? On Wednesday, July 17, 2013 5:36:33 PM UTC+5:30, Massimo Di Pierro wrote: A query object cannot be put into a session unless you somehow serialize (but not with automated pickle/marshall/etc). On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
HI, you can pass results to the next page; redirect(URL(test,vars=dict(results=results)) On the next page you can do return dict(results=request.vars[results]) Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
You can store the results in session then. session.rows = db(...).select() Passing to much data in request.vars can be a problem. For example nginx limits the size of the query string. On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote: HI, you can pass results to the next page; redirect(URL(test,vars=dict(results=results)) On the next page you can do return dict(results=request.vars[results]) Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
Hi, Is it possible to pass the request vars and call the function dynamic_search twice? redirect(URL(test,vars=request.vars)) Am Mittwoch, 17. Juli 2013 18:46:07 UTC+2 schrieb Massimo Di Pierro: You can store the results in session then. session.rows = db(...).select() Passing to much data in request.vars can be a problem. For example nginx limits the size of the query string. On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote: HI, you can pass results to the next page; redirect(URL(test,vars=dict(results=results)) On the next page you can do return dict(results=request.vars[results]) Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How do I pass a query object to a different controller?
Thanks guys for the help. I followed the approach as suggested by Massimo, so I did the following : @auth.requires_login() def search2(): form,results = dynamic_search(db.customer) if form.process().accepted: session.results = results redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): results = session.results return dict(results=results) Please note that the dynamic_search is returning grid and form, so I am storing grid in the form. But I am still facing problems, not sure what wrong steps I am doing. For the first time, when I click on search, desired results are opened in controller results (in a new page). But when I click on edit/view of grid operation, some how the page gets redirected to search page and on subsequent search it crashes with the same problem (can't pickle ..). My question is when i click on edit operations on a grid, why it is redirecting to search. Isn't it is supposed to open edit form there itself? Thanks Sarbjit On Thursday, July 18, 2013 1:00:12 AM UTC+5:30, Dmitri Husti wrote: Hi, Is it possible to pass the request vars and call the function dynamic_search twice? redirect(URL(test,vars=request.vars)) Am Mittwoch, 17. Juli 2013 18:46:07 UTC+2 schrieb Massimo Di Pierro: You can store the results in session then. session.rows = db(...).select() Passing to much data in request.vars can be a problem. For example nginx limits the size of the query string. On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote: HI, you can pass results to the next page; redirect(URL(test,vars=dict(results=results)) On the next page you can do return dict(results=request.vars[results]) Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh: Hi, I am trying to use dynamic search form from http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current implementation shows both the form and results on the same page. I want to display the search results (using GRID) in a new page and wants to use customized forms for edit/view operations associated with GRID. As of now, I tried handling it in the view to not to show form contents once the form is accessed but some how it is not working on subsequent operations. So, I am thinking to pass query to a new controller and can hence handle the custom forms there. But I am not able to do so. So here is what I tried : @auth.requires_login() def search2(): form,query = dynamic_search(db.customer) if form.process().accepted: session.sqlquery = query redirect(URL('results')) return dict(form=form) @auth.requires_login() def results(): query = session.sqlquery print query results = SQLFORM.grid(query,searchable=False,create=False,csv=False) results = None return dict(results=results) With this code, first error that is encountered is in session.sqlquery = query - Can't pickle objects So I modified it as session.sqlquery = str(query) With this error appeared in query = session.sqlquery - str object has no attribute _db Can some one please suggest what is the right way to achieve this? -Sarbjit -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.