1. Benoit Boissinot
  2. jorf2rss

Commits

Benoit Boissinot  committed 4757403

initial commit

  • Participants
  • Branches default

Comments (0)

Files changed (4)

File app.yaml

View file
  • Ignore whitespace
+application: helloworld
+version: 1
+runtime: python
+api_version: 1
+
+handlers:
+- url: /.*
+  script: helloworld.py

File helloworld.py

View file
  • Ignore whitespace
+from google.appengine.ext import webapp, db
+from google.appengine.ext.webapp import template
+from google.appengine.ext.webapp.util import run_wsgi_app
+import logging, os
+
+# How many entries to show?  -1 means show all since Jan 1, 2008
+defaultfeed = 10
+
+class FeedArticle(db.Model):
+    title = db.StringProperty(required=True)
+    id = db.StringProperty(required=True)
+    html = db.TextProperty(required=True)
+    timestamp = db.DateTimeProperty(required=True)
+    #feed = db.ReferenceProperty(Feed, collection_name='feed_articles')
+
+class Feed(object):
+    def __init__(self):
+        self.title = "JORF"
+        self.id = "http://www.example.com"
+        self.articles = FeedArticle.all().order('-timestamp')
+        self.timestamp = None
+
+class AtomHandler(webapp.RequestHandler):
+    '''
+    Displays the Atom feed as application/atom+xml
+    '''
+    def get(self):
+        logging.debug("Sending Atom feed")
+        self.response.headers['Content-Type'] = 'application/atom+xml'
+        template_values=Feed()
+        path = os.path.join(os.path.dirname(__file__), 'views/atom.xml')
+        self.response.out.write(template.render(path, {'feed': template_values}))
+
+class MainPage(webapp.RequestHandler):
+    def get(self):
+        self.response.headers['Content-Type'] = 'text/plain'
+        self.response.out.write('Hello, webapp World!')
+
+application = webapp.WSGIApplication(
+                                     [('/', AtomHandler)],
+                                     debug=True)
+
+def main():
+    run_wsgi_app(application)
+
+if __name__ == "__main__":
+    main()

File index.yaml

View file
  • Ignore whitespace
+indexes:
+
+# AUTOGENERATED
+
+# This index.yaml is automatically updated whenever the dev_appserver
+# detects that a new type of query is run.  If you want to manage the
+# index.yaml file manually, remove the above marker line (the line
+# saying "# AUTOGENERATED").  If you want to manage some indexes
+# manually, move them above the marker line.  The index.yaml file is
+# automatically uploaded to the admin console when you next deploy
+# your application using appcfg.py.

File views/atom.xml

View file
  • Ignore whitespace
+<?xml version="1.0" encoding="utf-8"?>
+ 
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <title type="text">{{ feed.title }}</title>
+    <updated>{{ feed.timestamp }}</updated>
+    <id>{{ feed.id }}</id>
+    <link rel="self" type="application/atom+xml" href="{{ feed.feed_url }}" />
+ 
+    {% for article in feed.articles %}
+    <entry>
+        <title>{{ article.title }}</title>
+        <id>{{ article.id }}</id>
+        <updated>{{ article.timestamp }}</updated>
+        <content type="html">
+		{{ feed.html }}
+        </content>
+    </entry>
+    {% endfor %}
+ 
+</feed>