Hello Massimo,
There is no file called "ast" at that location. Any ideas?
On Friday, July 19, 2013 11:33:45 AM UTC-5, Massimo Di Pierro wrote:
>
> Is it possible you have a file called ast under
> applications/<yourapp>/modules/ ?
>
> On Friday, 19 July 2013 08:09:40 UTC-5, 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.