blob: 6670dcb24ec754e1cb901a98711b92b3f37ae474 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
"""
|