]> git.ipfire.org Git - ipfire.org.git/blob - www/webapp/datastore/menu.py
Create a global webapp database connection and create a config class.
[ipfire.org.git] / www / webapp / datastore / menu.py
1 #!/usr/bin/python
2
3 import simplejson
4
5 from tornado.database import Row
6
7 class Menu(object):
8 def __init__(self, application, filename=None):
9 self.application = application
10 self.items = {}
11
12 if filename:
13 self.load(filename)
14
15 def load(self, filename):
16 with open(filename) as f:
17 for url, items in simplejson.load(f).items():
18 self.items[url] = []
19 for item in items:
20 self.items[url].append(Row(item))
21
22 def get(self, url):
23 return self.items.get(url, [])