If you want to run a Python script in a web2py environment, you must use 
web2py.py with command line arguments:

python web2py.py -S yourapp -M -R /path/to/your/script.py

If you don't create the web2py execution environment as above, the current 
object will not include the typical web2py API objects, such as T.

Anthony

On Saturday, July 9, 2016 at 2:02:53 AM UTC-4, 黄祥 wrote:
>
> i have web2py modules that insert new data for new web2py app:
> *modules/test_install.py*
> #!/usr/bin/env python
> # coding: utf8
>
> import sys; 
> sys.path.append('site/web2py/')
>
> from gluon import current
> #from gluon import *
> from gluon.contrib.webclient import WebClient
>
> install = WebClient('http://127.0.0.1:8000/test/install/',
> postbacks = True)
>
> install.get('index')
>
> *if current.T('Installation Done') in install.text:*
> print "Installation Done"
> else:
> print "Installation Failed"
>
> Web2py had already running with :
> python ~/site/web2py/web2py.py
>
> But when i tried to execute web2py module in another terminal on the same 
> machine it return an error
>
> Test:~ Test$ python ~/site/web2py/applications/test/modules/test_install.py
> Traceback (most recent call last):
>   File 
> "/Users/MacBookPro/site/web2py/applications/test/modules/test_install.py", 
> line 18, in <module>
>     if current.T('Installation Done') in install.text:
> AttributeError: 'thread._local' object has no attribute 'T'
>
> is there any way to fix it?
>
> thanks and best regards,
> stifan
>
>

-- 
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