[web2py] Re: Pass a query from form to another function

2018-04-20 Thread Yoel Benitez Fonseca
Umm... sorry took long to answer, i have put on issue on PyDAL repo and a 
pull request with a posible fix:

https://github.com/web2py/pydal/pull/531

El martes, 10 de abril de 2018, 22:20:04 (UTC-4), Anthony escribió:
>
> On Tuesday, April 10, 2018 at 6:14:06 PM UTC-4, Yoel Benitez Fonseca wrote:
>>
>> Is this not working any more ?
>>
>> >>> q = (db.photo.id == 1)
>> >>> db(q.as_dict(flat=True)).select()
>>   File "", line unknown
>> SyntaxError: Operator not supported: eq
>>
>> That is in a web2py shell,i mean is the same thing passing around the 
>> query in the session as a dict, is not ?
>>
>
> Looks like it could be broken now. Feel free to file an issue with the 
> PyDAL repository.
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2018-04-10 Thread Anthony
On Tuesday, April 10, 2018 at 6:14:06 PM UTC-4, Yoel Benitez Fonseca wrote:
>
> Is this not working any more ?
>
> >>> q = (db.photo.id == 1)
> >>> db(q.as_dict(flat=True)).select()
>   File "", line unknown
> SyntaxError: Operator not supported: eq
>
> That is in a web2py shell,i mean is the same thing passing around the 
> query in the session as a dict, is not ?
>

Looks like it could be broken now. Feel free to file an issue with the 
PyDAL repository.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2018-04-10 Thread Anthony

>
> On Tuesday, April 10, 2018 at 3:14:06 PM UTC-7, Yoel Benitez Fonseca wrote:
>>
>> Is this not working any more ?
>>
>> >>> q = (db.photo.id == 1)
>> >>> db(q.as_dict(flat=True)).select()
>>   File "", line unknown
>> SyntaxError: Operator not supported: eq
>>
>> That is in a web2py shell,i mean is the same thing passing around the 
>> query in the session as a dict, is not ?
>>
>
>  
> The following works:
>
> >>> q = (db.photo.id == 1)
> >>> db(q).select().as_dict()
>
> as_dict() and as_list() are defined as operating on a Rows object.  q is 
> a query object.
>  http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#as_dict-and-as_list
> >
>
> flat=True gives an unexpected keyword argument error.
>

The Query class also has an as_dict method, though I don't think it is 
documented:

https://github.com/web2py/pydal/blob/master/pydal/objects.py#L2004

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2018-04-10 Thread Dave S


On Tuesday, April 10, 2018 at 3:14:06 PM UTC-7, Yoel Benitez Fonseca wrote:
>
> Is this not working any more ?
>
> >>> q = (db.photo.id == 1)
> >>> db(q.as_dict(flat=True)).select()
>   File "", line unknown
> SyntaxError: Operator not supported: eq
>
> That is in a web2py shell,i mean is the same thing passing around the 
> query in the session as a dict, is not ?
>

 
The following works:

>>> q = (db.photo.id == 1)
>>> db(q).select().as_dict()

as_dict() and as_list() are defined as operating on a Rows object.  q is a 
query object.
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#as_dict-and-as_list>

flat=True gives an unexpected keyword argument error.

.../pydal/base.py line 631 defines as_dict() for tables with flat and 
sanitize args, so you can do db(q).as_dict(flat=True) and get a query 
object dict (as it looks to me) but trying to put that back into db() fails.

(I tried with 2.15.4)
 
/dps


El miércoles, 7 de diciembre de 2016, 14:56:20 (UTC-5), Anthony escribió:
>
> On Wednesday, December 7, 2016 at 9:33:16 AM UTC-5, Marlysson Silva wrote:
>>
>> You can use sessions..
>>
>> session.content = query_search
>>
>
> A Query object can't be pickled to store it in the session, but you can 
> first convert to a dictionary:
>
> session.search_query = search_query.as_dict(flat=True)
>
> Then in the second function:
>
> db(session.search_query).select()
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2018-04-10 Thread Yoel Benitez Fonseca
Is this not working any more ?

>>> q = (db.photo.id == 1)
>>> db(q.as_dict(flat=True)).select()
  File "", line unknown
SyntaxError: Operator not supported: eq

That is in a web2py shell,i mean is the same thing passing around the query 
in the session as a dict, is not ?

El miércoles, 7 de diciembre de 2016, 14:56:20 (UTC-5), Anthony escribió:
>
> On Wednesday, December 7, 2016 at 9:33:16 AM UTC-5, Marlysson Silva wrote:
>>
>> You can use sessions..
>>
>> session.content = query_search
>>
>
> A Query object can't be pickled to store it in the session, but you can 
> first convert to a dictionary:
>
> session.search_query = search_query.as_dict(flat=True)
>
> Then in the second function:
>
> db(session.search_query).select()
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2016-12-08 Thread Marlysson Silva
Can't by definition of DAL code? or by security..

Em quarta-feira, 7 de dezembro de 2016 16:56:20 UTC-3, Anthony escreveu:
>
> On Wednesday, December 7, 2016 at 9:33:16 AM UTC-5, Marlysson Silva wrote:
>>
>> You can use sessions..
>>
>> session.content = query_search
>>
>
> A Query object can't be pickled to store it in the session, but you can 
> first convert to a dictionary:
>
> session.search_query = search_query.as_dict(flat=True)
>
> Then in the second function:
>
> db(session.search_query).select()
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Re: Pass a query from form to another function

2016-12-07 Thread Áureo Dias Neto
Thank guys, it's work

2016-12-07 17:56 GMT-02:00 Anthony :

> On Wednesday, December 7, 2016 at 9:33:16 AM UTC-5, Marlysson Silva wrote:
>>
>> You can use sessions..
>>
>> session.content = query_search
>>
>
> A Query object can't be pickled to store it in the session, but you can
> first convert to a dictionary:
>
> session.search_query = search_query.as_dict(flat=True)
>
> Then in the second function:
>
> db(session.search_query).select()
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2016-12-07 Thread Anthony
On Wednesday, December 7, 2016 at 9:33:16 AM UTC-5, Marlysson Silva wrote:
>
> You can use sessions..
>
> session.content = query_search
>

A Query object can't be pickled to store it in the session, but you can 
first convert to a dictionary:

session.search_query = search_query.as_dict(flat=True)

Then in the second function:

db(session.search_query).select()

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Re: Pass a query from form to another function

2016-12-07 Thread Áureo Dias Neto
with 'session.content = query_search' i save the query in session?

and request this on argument of function?

2016-12-07 12:33 GMT-02:00 Marlysson Silva :

> You can use sessions..
>
> session.content = query_search
>
> and in your view responsible by generate pdf use:
>
> generate_pdf(session.content)
>
> Em quarta-feira, 7 de dezembro de 2016 10:08:45 UTC-3, Áureo Dias Neto
> escreveu:
>>
>> I have a search form, which filter the fields, I filter my query .. so
>> far so good ..
>>
>> The search works perfectly, from the results I generate a PDF, but, how
>> to pass this query from the search form to my PDF ..
>>
>> Note that PDF is generated in another function.
>>
>> Thank you!
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Pass a query from form to another function

2016-12-07 Thread Marlysson Silva
You can use sessions..

session.content = query_search 

and in your view responsible by generate pdf use:

generate_pdf(session.content)

Em quarta-feira, 7 de dezembro de 2016 10:08:45 UTC-3, Áureo Dias Neto 
escreveu:
>
> I have a search form, which filter the fields, I filter my query .. so far 
> so good ..
>
> The search works perfectly, from the results I generate a PDF, but, how to 
> pass this query from the search form to my PDF ..
>
> Note that PDF is generated in another function.
>
> Thank you!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.