Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added some google analytics and a try/catch around the last modified …

…header check
  • Loading branch information...
commit 5bed03f91813a1e98feaa29094210415f2266e91 1 parent 624ef15
@russellbeattie russellbeattie authored
Showing with 24 additions and 7 deletions.
  1. +24 −7 plusfeed.py
View
31 plusfeed.py
@@ -63,6 +63,19 @@ def get(self):
self.response.out.write("""
</p>
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-24604146-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
</body>
</html>""")
@@ -73,12 +86,16 @@ def get(self, p):
HTTP_DATE_FMT = "%a, %d %b %Y %H:%M:%S GMT"
if 'If-Modified-Since' in self.request.headers:
- last_seen = datetime.strptime(self.request.headers['If-Modified-Since'], HTTP_DATE_FMT)
- ud = memcache.get('time_' + p)
- if ud and last_seen and ud <= last_seen:
- logging.info('returning 304')
- self.response.set_status(304)
- return
+ try:
+
+ last_seen = datetime.strptime(self.request.headers['If-Modified-Since'], HTTP_DATE_FMT)
+ ud = memcache.get('time_' + p)
+ if ud and last_seen and ud <= last_seen:
+ logging.info('returning 304')
+ self.response.set_status(304)
+ return
+ except:
+ test = 1
#logging.info(self.request.headers)
@@ -174,7 +191,7 @@ def get(self, p):
)
output = feed.writeString('UTF-8')
- memcache.set(p, output, 15 * 60)
+ memcache.set(p, output, 10 * 60)
memcache.set('time_' + p, updated)
list = {}
Please sign in to comment.
Something went wrong with that request. Please try again.