One more try. I think I understand the problem now. Here is a possible
solution:

def twitter():
        session.forget()
        session._unlock(response)
        import gluon.tools
        import gluon.contrib.simplejson as sj
        from google.appengine.api.urlfetch import fetch
        #page = gluon.tools.fetch('http://twitter.com/web2py?
format=json')
        page = fetch('http://twitter.com/web2py?format=json').content
        return sj.loads(page)['#timeline']

does it work?

On Nov 23, 12:09 pm, Leandro - ProfessionalIT <lsever...@gmail.com>
wrote:
> Massimo,
>
> > from google.appengine.api.urlfetch import fetch
> > def my test():
> >     page = fetch('http://twitter.com/
> > web2py',payload='format=json').content
> >     return page
>
> > do you get JSON?
>
> > Massimo
>
> This function run OK (http://www.leandro.inf.br/init/default/my_test),
> then I try change my function twitter to execute:
>
> def twitter():
>         session.forget()
>         session._unlock(response)
>         import gluon.tools
>         import gluon.contrib.simplejson as sj
>         from google.appengine.api.urlfetch import fetch
>         #page = gluon.tools.fetch('http://twitter.com/web2py?format=json')
>         page = fetch('http://twitter.com/
> web2py',payload='format=json').content
>         return sj.loads(page)['#timeline']
>
> And receive this error in log:
> In FILE: /base/data/home/apps/leandro-inf/1.337960094083594016/
> applications/init/controllers/default.py
>
> Traceback (most recent call last):
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/gluon/
> restricted.py", line 184, in restricted
>     exec ccode in environment
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/
> applications/init/controllers/default.py:twitter", line 163, in
> <module>
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/gluon/
> globals.py", line 102, in <lambda>
>     self._caller = lambda f: f()
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/
> applications/init/controllers/default.py:twitter", line 77, in twitter
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/gluon/
> contrib/simplejson/__init__.py", line 305, in loads
>     return _default_decoder.decode(s)
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/gluon/
> contrib/simplejson/decoder.py", line 329, in decode
>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>   File "/base/data/home/apps/leandro-inf/1.337960094083594016/gluon/
> contrib/simplejson/decoder.py", line 347, in raw_decode
>     raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to