put the code in models, /models/temp.py
>>> def get_temp():
... temp = None
... from xml.dom import minidom
... source = urllib2.urlopen('
http://free.worldweatheronline.com/feed/weather.ashx?q=udupi&format=xml&num_of_days=2&key=b019cd7d6a135850110711
')
... source_text = source.read()
... parseddata = minidom.parseString(source_
text)
... temp_c = parseddata.getElementsByTagName('temp_C')
... if temp_c:
... temp = temp_c[0].firstChild.toxml()
... return temp
So in any view you can do:
{{=get_temp()}}
also you can access it in any controller
def index():
temp = get_temp()
return dict(temp=temp)
Bruno Rocha
[http://rochacbruno.com.br]