diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-10-29 14:54:38 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-10-29 14:54:38 +0100 |
commit | 7163dfa3d0252067de90e8c088ea90d0b0f7d059 (patch) | |
tree | 11fa27982ff2c328435a128df3a8ab44b25593f7 /cherry_lesana/app.py | |
parent | a5fbd781ccc9b64483cc499c375fa6e0e99ade1d (diff) |
Load a collection from command line and show a list of items
Diffstat (limited to 'cherry_lesana/app.py')
-rw-r--r-- | cherry_lesana/app.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cherry_lesana/app.py b/cherry_lesana/app.py index 4ab7672..6670dcb 100644 --- a/cherry_lesana/app.py +++ b/cherry_lesana/app.py @@ -1,13 +1,38 @@ import cherrypy +import jinja2 class App: """ """ + def __init__(self, collection=None): + self.collection = collection + self.j_env = jinja2.Environment( + loader=jinja2.PackageLoader('cherry_lesana', 'data/templates'), + autoescape=jinja2.select_autoescape(['html', 'xml'], default=True), + ) @cherrypy.expose def index(self): cherrypy.log('asd') return "Hello World" + @cherrypy.expose + def list(self): + """Show a list of items in the current collection""" + if not self.collection: + return "No collection loaded" + template = self.j_env.get_template('list.html') + # TODO: paginate + items = self.collection.get_all_documents() + return template.render( + collection=self.collection, + items=items, + ) + + +class Item: + """ + Work on the contents of an item + """ |