Permalink
Browse files

Only check whether we're running in dev appserver once.

  • Loading branch information...
1 parent 8f1636d commit 5add88cd61d81adad449c079865595e4ecf7d290 @arantius committed Aug 31, 2010
Showing with 6 additions and 5 deletions.
  1. +2 −2 clean.py
  2. +2 −3 main.py
  3. +2 −0 util.py
View
@@ -77,7 +77,7 @@ def CleanFeed(feed_url, keep_contents):
entry.content = clean_content
return feed
-if 'Development' not in os.environ.get('SERVER_SOFTWARE', ''):
+if not util.IS_DEV_APPSERVER:
CleanFeed = util.Memoize('Clean_%s_%d', 1800)(CleanFeed)
@@ -119,7 +119,7 @@ def CleanUrl(url):
content = extract_content.ExtractFromHtml(url, html)
return note + Munge(content)
-if 'Development' not in os.environ.get('SERVER_SOFTWARE', ''):
+if not util.IS_DEV_APPSERVER:
CleanUrl = util.Memoize('Clean_%s', 3600*24)(CleanUrl)
View
@@ -31,8 +31,7 @@
import clean
import util
-IS_DEV_APPSERVER = 'Development' in os.environ.get('SERVER_SOFTWARE', '')
-if IS_DEV_APPSERVER:
+if util.IS_DEV_APPSERVER:
logging.getLogger().setLevel(logging.DEBUG)
else:
logging.getLogger().setLevel(logging.WARNING)
@@ -72,7 +71,7 @@ def get(self):
def main():
application = webapp.WSGIApplication(
[('/', MainPage), ('/clean', Clean)],
- debug=IS_DEV_APPSERVER)
+ debug=util.IS_DEV_APPSERVER)
run_wsgi_app(application)
View
@@ -26,6 +26,8 @@
from google.appengine.api import urlfetch
from google.appengine.ext.webapp import template
+IS_DEV_APPSERVER = 'Development' in os.environ.get('SERVER_SOFTWARE', '')
+
def Memoize(formatted_key, time=3600):
"""Decorator to store a function call result in App Engine memcache."""

0 comments on commit 5add88c

Please sign in to comment.