Anonymous avatar Anonymous committed a3a76e7

cache newsfeeds

Comments (0)

Files changed (3)

newsmeme/__init__.py

 from newsmeme.extensions import db, mail, oid, cache
 
 DEBUG = True
-SECRET_KEY = "38061032-5b21-4c20-b67b-28d891c6a1dc"
+
+# change this in your production settings !!!
+
+SECRET_KEY = "secret"
 
 # keys for localhost. Change as appropriate.
 

newsmeme/views/api.py

 
 
 @api.route("/search/")
-@cached()
 def search():
 
     keywords = request.args.get("keywords", "")

newsmeme/views/feeds.py

 from werkzeug.contrib.atom import AtomFeed
 
 from newsmeme.models import User, Post, Tag
+from newsmeme.helpers import cached
 
 feeds = Module(__name__)
 
 
 
 @feeds.route("/")
+@cached()
 def index():
     feed = PostFeed("newsmeme - hot",
                     feed_url=request.url,
 
 
 @feeds.route("/latest/")
+@cached()
 def latest():
     feed = PostFeed("newsmeme - new",
                     feed_url=request.url,
 
 
 @feeds.route("/deadpool/")
+@cached()
 def deadpool():
     feed = PostFeed("newsmeme - deadpool",
                     feed_url=request.url,
 
 
 @feeds.route("/tag/<slug>/")
+@cached()
 def tag(slug):
 
     tag = Tag.query.filter_by(slug=slug).first_or_404()
 
 
 @feeds.route("/user/<username>/")
+@cached()
 def user(username):
     user = User.query.filter_by(username=username).first_or_404()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.