First thing to try in such cases is to import the module (or just run the program snippet in your case) on the same server / computer you run web2py on. You need to try this things out in the same python environment... Then troubleshoot from there.
Regards, Ales On Friday, July 19, 2013 3:09:40 PM UTC+2, Auden RovelleQuartz wrote: > > on regular python - for example on a www.compilr.com account, I am able > to create and successfully execute this trivial program (in the {} brackets: > > { > > #!/usr/bin/python > > import ast > l = ast.literal_eval('["a","31","c"]') > l = [i.strip() for i in l] > print l[1] > > } > > > but when I try to use the ast module within the web2py framework as in > this controller function: > > { > > def index(): > import ast > rec = db(db.audentest.id > 0).select() > item = rec[0] > l = ast.literal_eval(item) > l = [i.strip() for i in l] > quantity1 = l > link = A("Test View", _href=URL(r=request,f="testview")) > return dict(link = link, quantity1 = quantity1) > } > > I get the following error trace: > > { > > Traceback > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > 11. > 12. > > Traceback (most recent call last): > File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted > exec ccode in environment > File "/home/www-data/web2py/applications/omniavx/controllers/developer.py" > <https://omniavx.com/admin/edit/omniavx/controllers/developer.py>, line 26, > in <module> > File "/home/www-data/web2py/gluon/globals.py", line 194, in <lambda> > self._caller = lambda f: f() > File "/home/www-data/web2py/applications/omniavx/controllers/developer.py" > <https://omniavx.com/admin/edit/omniavx/controllers/developer.py>, line 2, in > index > import ast > File "/home/www-data/web2py/gluon/custom_import.py", line 81, in > custom_importer > raise ImportError, 'Cannot import module %s' % str(e) > > > } > > > Does anyone know how to import the ast module so that it works in the > web2py framework? > > Thanks > -- --- 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/groups/opt_out.