]> git.ipfire.org Git - ipfire.org.git/blobdiff - www/webapp/datastore/news.py
Some very big changes I cannot break down to distinct commits.
[ipfire.org.git] / www / webapp / datastore / news.py
similarity index 65%
rename from www/webapp/news.py
rename to www/webapp/datastore/news.py
index 652578088ae9b93a9fabcdf909e850354f73c92b..2ebb25649bcf6bb7a4f943dfbfd0c2dc24d651bf 100644 (file)
@@ -1,9 +1,12 @@
 #!/usr/bin/python
 
-from helpers import Item, _stringify, json_loads
+import simplejson
+
+from tornado.database import Row
 
 class News(object):
-       def __init__(self, filename=None):
+       def __init__(self, application, filename=None):
+               self.application = application
                self.items = []
 
                if filename:
@@ -16,10 +19,10 @@ class News(object):
 
                data = data.replace("\n", "").replace("\t", " ")
 
-               json = json_loads(data)
+               json = simplejson.loads(data)
                for key in sorted(json.keys()):
                        json[key]["id"] = key
-                       self.items.append(NewsItem(**_stringify(json[key])))
+                       self.items.append(Row(json[key]))
 
        def get(self, limit=None):
                ret = self.items[:]
@@ -27,8 +30,3 @@ class News(object):
                if limit:
                        ret = ret[:limit]
                return ret
-
-
-NewsItem = Item
-
-news = News("news.json")