[web2py] SQL query to web2py code

2016-06-09 Thread 'Annet' via web2py-users
I have the following SQL query (in Postgresql): SELECT ntw_edge.outid, ntw_edge.inid, ntw_edge.label, alias_edge.inid, alias_edge.outid, alias_edge.label FROM ntw_edge LEFT OUTER JOIN ntw_edge AS alias_edge ON ntw_edge.inid=alias_edge.outid WHERE ntw_edge.outid=1147; In web2py I have: def ret

Re: [web2py] SQL query to web2py code

2016-06-09 Thread Massimiliano
Try to print the sql generated from web2py: print db(db.ntw_edge.outID==1147)._select(left=db.ntw_edge.on(db. ntw_edge.inID==alias_edge.outID)) On Thu, Jun 9, 2016 at 10:10 AM, 'Annet' via web2py-users < web2py@googlegroups.com> wrote: > I have the following SQL query (in Postgresql): > > > SELE

[web2py] Querying data using admin

2016-06-09 Thread António Ramos
hello how can i, via admin query a table using in the input box more than 1 field to query? i tried db.amostras.n==203027 & db.amostras.estante1=="_E_000" - >error db.amostras.n==203027 and db.amostras.estante1=="_E_000" -> no error but seems to search only the second field (db.amostras.estante1=

[web2py] Re: migrate uwsgi + nginx --> twisted

2016-06-09 Thread Niphlod
are you talking about web2py ? web2py isn't really leveraging twisted features. Not sure if it'll sports better performances than uwsgi+nginx. that being said, nginx should still sit on top, proxying to the twisted process. Twisted has extensive docs on how to start it as a service, such as ht

[web2py] Re: SELECT without duplicates for a specific field

2016-06-09 Thread tim . nyborg
Looks like you want a subquery. You'll need to decide which of the items to choose when you have a given category_code. Say you want the first item with a given category code: sub_query = db()._select(db.products.id.min(), groupby=db.products.category_code) results = db(db.products.id.belongs(s

[web2py] Re: Querying data using admin

2016-06-09 Thread Anthony
Same rules as usual apply -- you need parentheses: (db.amostras.n==203027) & (db.amostras.estante1=="_E_000") Anthony On Thursday, June 9, 2016 at 5:29:39 AM UTC-4, Ramos wrote: > > hello > how can i, via admin query a table using in the input box more than 1 > field to query? > > i tried > db

Re: [web2py] Re: Querying data using admin

2016-06-09 Thread António Ramos
Oops Thank you Anthony António 2016-06-09 14:39 GMT+01:00 Anthony : > (db.amostras.n==203027) & (db.amostras.estante1=="_E_000") -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/l

[web2py] Re: Querying data using admin

2016-06-09 Thread isi_jca
Hello!!! Try using Parenthesis, for example: (db.tventa.id >= 3) & (db.tventa.id <= 7) Result Set tventa.id tventa.fecha tventa.vendedor

Re: [web2py] Re: Querying data using admin

2016-06-09 Thread António Ramos
Yes it works now. Too bad that i cannot only return some of the columns. It would be perfect because i have many columns and i have to scroll to the right a lot. 2016-06-09 14:55 GMT+01:00 isi_jca : > Hello!!! > > Try using Parenthesis, for example: > > (db.tventa.id >= 3) & (db.tventa.id <= 7

Re: [web2py] Re: Querying data using admin

2016-06-09 Thread isi_jca
Ramos: Other posibility is create a form using grid and then choose columns you want to show, for example: def query_venta(): query = (db.tventa.id >= 3) & (db.tventa.id <= 7) columns = [db.tventa.fecha, db.tventa.monto]] grid=SQLFORM.grid(query,field_id = db.tventa.id,fields=

[web2py] Problems using @cache.action(valid_statuses=[200])

2016-06-09 Thread Lisandro
I'm having trouble to avoid caching pages that returned anything else than HTTP 200. Consider the following simple example: @cache.action(time_expire=300, cache_model=cache.redis, session=False, vars= False, public=True, valid_statuses=[200]) def index(): raise HTTP(503) When I hit the URL

[web2py] Re: how to format JSON data?

2016-06-09 Thread Alex Glaros
how to add json_list to the return line at bottom of function? I need locals too, for use in the view return locals(json.dumps(json_list))) ?? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p

[web2py] resilient background process

2016-06-09 Thread Pierre
Hi I have no experience with task queues and am thinking to adapt my code from both the web2py example of homemade task queues at: http://web2py.com/books/default/chapter/29/08/emails-and-sms?search=Sending+messages+using+a+background+task#Sending-messages-using-a-background-task and pythonanyw

[web2py] Re: Problems using @cache.action(valid_statuses=[200])

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 9:13:51 AM UTC-7, Lisandro wrote: > > I'm having trouble to avoid caching pages that returned anything else than > HTTP 200. > > Consider the following simple example: > > @cache.action(time_expire=300, cache_model=cache.redis, session=False, > vars=False, public=Tr

[web2py] How to handle dynamic forms?

2016-06-09 Thread desta
Hello everyone, My current task is to create a form where fields can be added/removed. Is it possible to handle such forms with web2py? Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p

[web2py] Re: how to format JSON data?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 9:35:07 AM UTC-7, Alex Glaros wrote: > > how to add json_list to the return line at bottom of function? I need > locals too, for use in the view > > return locals(json.dumps(json_list))) ?? > json_list isn't automatically in locals? You haven't declared it global

[web2py] Re: Problems using @cache.action(valid_statuses=[200])

2016-06-09 Thread Anthony
Looks like a bug in the Redis cache implementation. cache.action first saves the output to the cache, and later if it is determined that the HTTP status is not valid, it then attempts to delete the output from the cache via cache_model(cache_key, None)

[web2py] Re: Problems using @cache.action(valid_statuses=[200])

2016-06-09 Thread Anthony
On Thursday, June 9, 2016 at 2:46:27 PM UTC-4, Dave S wrote: > > > As a WAG (I dunno the cache manipulators), your "valid_statuses" is > setting the status to be returned when the page is served from cache. > No, he's using valid_statuses correctly -- the output is cached only when the status ma

[web2py] Re: how to format JSON data?

2016-06-09 Thread Alex Glaros
yes json_list automatically appears in locals but at one point putting it in return(json.dumps(json_list)) was the only way I could see that the escape slashes were added. okay, so no more javascript errors now but am still curious how to phrase syntax for putting it in return clause along wi

[web2py] Re: resilient background process

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 11:32:51 AM UTC-7, Pierre wrote: > > [...] > and pythonanywhere longRunningTasks script at: > > https://help.pythonanywhere.com/pages/LongRunningTasks/ > > this page tells the programmer to make sure his code is *resilient to > being terminated unexpectedly*: what is

[web2py] Re: Problems using @cache.action(valid_statuses=[200])

2016-06-09 Thread Anthony
Just submitted an issue: https://github.com/web2py/web2py/issues/1355 On Thursday, June 9, 2016 at 2:55:52 PM UTC-4, Anthony wrote: > > Looks like a bug in the Redis cache implementation. cache.action first > saves the output to the cache, and later if it is determined that the HTTP > status is

[web2py] Re: how to format JSON data?

2016-06-09 Thread Anthony
On Thursday, June 9, 2016 at 3:02:16 PM UTC-4, Alex Glaros wrote: > > but am still curious how to phrase syntax for putting it in return clause > along with locals. If my question makes sense, please let me know. > That doesn't make sense because locals() is a dictionary of all of the local vari

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Anthony
There is no built-in functionality for this case, but I don't see why you couldn't do something like that. I suppose the details would depend on whether you are persisting inputs to the database and what the data model looks like. As for the UI, that would probably be handled via Javascript and

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 11:47:43 AM UTC-7, desta wrote: > > Hello everyone, > > My current task is to create a form where fields can be added/removed. Is > it possible to handle such forms with web2py? > > Thanks. > I am not sure I understand what you want to do. Is it a) have a database

[web2py] Re: how to format JSON data?

2016-06-09 Thread Alex Glaros
sorry, I meant what is syntax to return a custom dictionary including only the particular values I need to return with the json.dumps phrase? Is it something like (userID=userID, json.dumps(json_list), userLastName=userLastName) ? -- Resources: - http://web2py.com - http://web2py.com/book (Do

[web2py] Re: how to format JSON data?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 12:31:36 PM UTC-7, Alex Glaros wrote: > > sorry, I meant what is syntax to return a custom dictionary including only > the particular values I need to return with the json.dumps phrase? > > Is it something like (userID=userID, json.dumps(json_list), > userLastName=u

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread desta
Well, I am really not sure how to implement this on database-side either, so any feedback from you, more experienced people, would be very insightful. Here is an example form of what I mean: A form that a user can enter books they like. So there is a title field that accepts the name of the b

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 1:19:35 PM UTC-7, desta wrote: > > Well, I am really not sure how to implement this on database-side either, > so any feedback from you, more experienced people, would be very > insightful. > > Here is an example form of what I mean: > > A form that a user can ente

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread desta
The book part that I mentioned is a part of much larger form, that has more dynamic elements. So I was thinking it was a good idea to store the whole form into a single table to keep things manageable. If I understand correctly you suggest to break up the form on db-side, and create a table for

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 1:42:29 PM UTC-7, desta wrote: > > The book part that I mentioned is a part of much larger form, that has > more dynamic elements. So I was thinking it was a good idea to store the > whole form into a single table to keep things manageable. If I understand > correc

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread desta
Something like this: * ## Personal Details ## * Name:_ * Surname: _ * * Mobile phone: _ * * ## Book part ## * Book title: _ * * * * * Do you l

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Dave S
On Thursday, June 9, 2016 at 2:26:32 PM UTC-7, desta wrote: > > Something like this: > > [details elided] A profile type of page, eh? Perhaps Ron C has some ideas. I would be tempted to use separate forms for each section and use ajax calls to transmit the data to the server. I would pick ce

[web2py] Re: How to handle dynamic forms?

2016-06-09 Thread Anthony
The books and movies could be done easily via list:string fields. However, for the cars and bikes, you would need linked tables with child records because you need to store both the model and an uploaded image for each. Anthony On Thursday, June 9, 2016 at 5:26:32 PM UTC-4, desta wrote: > > Som

Re: [web2py] SQL query to web2py code

2016-06-09 Thread 'Annet' via web2py-users
Hi Massimiliano, Thanks for your helpful reply. print db(db.ntw_edge.outID==1147)._select(left=db.ntw_edge.on(db. > ntw_edge.inID==alias_edge.outID)) > Web2py generates: SELECT alias_edge.outid, alias_edge.inid, alias_edge.label, ntw_edge.outid, ntw_edge.inid, ntw_edge.label FROM ntw_edge AS