On Sunday, June 29, 2014 6:54:15 AM UTC-7, 黄祥 wrote:
>
> please use current.db on your module
>
> ref:
>
> http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
>
> best regards,
> stifan
>


I updated module *images.py* to read:


from gluon import *

def thumbs():
    images = current.db().select(current.db.images.ALL, 
orderby=current.db.images.title)
    output = []
    for image in images:
        output += LI(A(IMG(_src=URL('download', 
args=image.imgfile),_alt=image.title, _width="50px", _height="50px", 
_title=image.title), _href=URL("show", args=image.id), _target="_images"))
    
    
    output = H2('Images') + UL(output)
    return output


Error:

  File "applications/Kurt/modules/images.py", line 4, in thumbs
    images = current.db().select(current.db.images.ALL, 
orderby=current.db.images.title)

AttributeError: 'thread._local' object has no attribute 'db' 

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to