On Sunday, April 22, 2018 at 3:48:14 PM UTC-4, Maurice Waka wrote:
>
> *module:#define code*
>
> from gluon import current
> from pydal import DAL, Field
> db = current.db
>

As noted here 
<http://web2py.com/books/default/chapter/29/04/the-core#Warning--Do-not-use-the-current-object-in-global-scope-in-a-module>,
 
you should not assign values from current at the top level of a module. 
Instead, move the db = current.db line into the definition() function. 
Actually, it is simpler and more explicit to just make db an argument of 
the definition() function, so you can pass it in directly rather than 
bothering attaching it to current.
 

> def definition():
>     rows = db(db.definition).select()
>     for row in rows:
>         return row.definition
>

What is the point of selecting all the records and running the for loop -- 
the function will simply end up returning the first record only?

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.

Reply via email to