changeset 15:2a22b994aca4

Add classifier feeds
author Cédric Krier <ced@b2ck.com>
date Tue, 24 Feb 2015 00:20:11 +0100
parents b51310293ee3
children b12fc631a637
files farmhouse.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/farmhouse.py	Mon Feb 23 17:24:04 2015 +0100
+++ b/farmhouse.py	Tue Feb 24 00:20:11 2015 +0100
@@ -94,6 +94,17 @@
     return render_atom(packages, title=user)
 
 
+@app.route('/classifier')
+@app.route('/classifier/<classifier>')
+@cache.cached(timeout=2 * 60 * 60, key_prefix=lambda: request.url)
+def classifier(classifier=None):
+    classifiers = request.args.getlist('classifiers')
+    if classifier:
+        classifiers.append(classifier)
+    packages = get_classifiers_packages(classifiers)
+    return render_atom(packages, title=', '.join(classifiers))
+
+
 def render_atom(packages, title=None):
     packages = sorted(packages)
     releases = []
@@ -157,6 +168,11 @@
     return [p for _, p in client.user_packages(user)]
 
 
+@cache.memoize(timeout=2 * 60 * 60)
+def get_classifiers_packages(classifiers):
+    return sorted({p for p, _ in client.browse(classifiers)})
+
+
 class Release:
     def __init__(self, name, version, url):
         self.name = name