Skip to content

Instantly share code, notes, and snippets.

@fannheyward
Created November 30, 2011 07:42
Show Gist options
  • Save fannheyward/1408359 to your computer and use it in GitHub Desktop.
Save fannheyward/1408359 to your computer and use it in GitHub Desktop.
Picky RSSOutHandler
class RSSOutHandler(webapp.RequestHandler):
def get(self):
site_domain = Datum.get('site_domain')
site_name = Datum.get('site_name')
site_author = Datum.get('site_author')
site_slogan = Datum.get('site_slogan')
site_analytics = Datum.get('site_analytics')
site_updated = Datum.get('site_updated')
if site_updated is None:
site_updated = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
feed_url = Datum.get('feed_url')
if feed_url is None:
feed_url = '/index.xml'
else:
if len(feed_url) == 0:
feed_url = '/index.xml'
template_values = {
'site_domain' : site_domain,
'site_name' : site_name,
'site_author' : site_author,
'site_slogan' : site_slogan,
'feed_url' : feed_url
}
articles = db.GqlQuery("SELECT * FROM Article WHERE is_page = FALSE ORDER BY created DESC")
template_values['articles'] = articles
template_values['articles_total'] = articles.count()
template_values['site_updated'] = site_updated
path = os.path.join(os.path.dirname(__file__), 'tpl', 'shared', 'out.xml')
output = template.render(path, template_values)
self.response.headers['Content-type'] = 'text/xml; charset=UTF-8'
self.response.out.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment