Commits

Thomas Pelletier committed 23198dd

add version retrieve

Comments (0)

Files changed (2)

 
 app = Buro(get_root(__file__))
 
-app.publish(url="/", template="index.html")
+# This function get the latest version number and the corresponding download
+# link. See the Pypi XML-RPC api: http://wiki.python.org/moin/PyPiXmlRpc
+def data():
+    info = {}
+    import xmlrpclib, pprint
+    client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
+    version = client.package_releases('Buro')[0]
+    url = client.release_urls('Buro', version)[0]['url']
+    info['version'] = version
+    info['download_url'] = url
+    return info
+
+app.publish_html(url='/', template='index.html', context=data())
 
 if __name__ == "__main__":
     app.run()

templates/index.html

 {% endblock exerpt %}
 
 {% block content %}
+
+<em>Latest version <a href="{{download_url}}">{{version}}</a>.</em>
     
 <h2>A very simple Buro application</h2>