Commits

Yann Malet committed 3f23976

Add a setting to control the default timeout of the cache for the feeds

Comments (0)

Files changed (2)

cmsplugin_feed/cms_plugins.py

 
 from cmsplugin_feed.models import Feed
 from cmsplugin_feed.forms import FeedForm
+from cmsplugin_feed.settings import CMSPLUGIN_FEED_CACHE_TIMEOUT
 
 def get_cached_feed(instance):
     """
     """
     if not cache.has_key("feed_%s" %instance.id):
         feed = feedparser.parse(instance.feed_url)
-        cache.set("feed_%s" %instance.id, feed, 100)
+        cache.set("feed_%s" %instance.id, feed, CMSPLUGIN_FEED_CACHE_TIMEOUT)
     return cache.get("feed_%s" %instance.id)
 
 class FeedPlugin(CMSPluginBase):

cmsplugin_feed/settings.py

+"""
+This module enforces default settings when the main settings module does not
+contain the appropriate settings.
+"""
+from django.conf import settings
+
+# Define the cache timeout in second for the feed
+# default is 3600s (1 hour)
+CMSPLUGIN_FEED_CACHE_TIMEOUT = getattr(settings,
+                                       'CMSPLUGIN_FEED_CACHE_TIMEOUT', 3600)
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.