[web2py] Re: twitter error using recipe from admin page

2013-04-25 Thread Leonel Câmara
Well the local variable 'r' referenced before assignment seems obvious, if 
you have no data, like it is happening now (the response has results:[]), 
then r never gets defined. You could fix this setting r = [] before the 
for. 

Quarta-feira, 24 de Abril de 2013 10:01:05 UTC+1, 黄祥 escreveu:

 hi folks,

 i'm trying to add twitter recent tweets that i learned from admin page. 
 but when i'm implemented it returns an error :

 Unable to download because:
 local variable 'r' referenced before assignment

 did anyone ever face the same situation? any hints, or solutions to solve 
 this problems?

 thanks a lot before


-- 

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




[web2py] Re: twitter error using recipe from admin page

2013-04-25 Thread 黄祥
it's work now, thank you so much for your hint leonel. for the recipe in 
admin page it seems have limitation, because when i use it, no tweets 
showed up, when i use the twitter widget it can show up.

-- 

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




[web2py] Re: twitter error using recipe from admin page

2013-04-24 Thread Loïc
Can you show some code...?

Le mercredi 24 avril 2013 11:01:05 UTC+2, 黄祥 a écrit :

 hi folks,

 i'm trying to add twitter recent tweets that i learned from admin page. 
 but when i'm implemented it returns an error :

 Unable to download because:
 local variable 'r' referenced before assignment

 did anyone ever face the same situation? any hints, or solutions to solve 
 this problems?

 thanks a lot before


-- 

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




[web2py] Re: twitter error using recipe from admin page

2013-04-24 Thread 黄祥
basically it's same like on the admin page, the different part is only the 
twitter user name.

*models/db.py*
TWITTER_HASH = stifixid

*controllers/default.py*
def twitter():
session.forget()
session._unlock(response)
import urllib
import gluon.tools
import gluon.contrib.simplejson as sj
try:
if TWITTER_HASH:
page = 
urllib.urlopen(http://search.twitter.com/search.json?q=%s; % 
TWITTER_HASH).read()
data = sj.loads(page, encoding=utf-8)['results']
d = dict()
for e in data:
d[e[id]] = e
r = reversed(sorted(d))
return dict(tweets=[d[k] for k in r])
else:
return 'disabled'
except Exception, e:
return DIV(T('Unable to download because:'), BR(), str(e))

def index():
return dict()

*views/default/index.html*
{{extend 'layout_default.html'}}

!-- TWITTER --
div class=box
h4{{=T(Recent Tweets)}}/h4
div id=tweets{{=T('loading...')}}/div
scriptjQuery(document).ready(function(){jQuery('#tweets').load('{{=URL('twitter.load')}}');});/script
/div
!-- /TWITTER --

any idea why it's produce the errors? is it related to my twitter account? 
i'm trying to access my twitter account via twitter web is fine.
thanks and best regards

-- 

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




[web2py] Re: twitter error using recipe from admin page

2013-04-24 Thread 黄祥
it seems the twitter code from admin page is limited for certain days or 
weeks. the other things is it didn't support link for example 
http://whateverurl.com
did anyone know how to fix it?
thank you so much

-- 

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