diff service/environment/environment.py @ 1029:4d36cae32a4c

refactor /graph and /graph/events handlers to lib/ Ignore-this: fdd8f3d753f76b32929a6a318314d2b5 darcs-hash:16939d60e5c2c4f6913b700b79c16a409bedd965
author drewp <drewp@bigasterisk.com>
date Sun, 24 Jan 2016 22:53:29 -0800
parents 70d52fa8373a
children 6304b0370491
line wrap: on
line diff
--- a/service/environment/environment.py	Sun Jan 24 07:12:25 2016 -0800
+++ b/service/environment/environment.py	Sun Jan 24 22:53:29 2016 -0800
@@ -10,8 +10,7 @@
 from dateutil.relativedelta import relativedelta, FR
 from rdflib import Namespace, Literal
 sys.path.append("/my/proj/homeauto/lib")
-from patchablegraph import PatchableGraph, writeGraphResponse, GraphEventsHandler
-from cycloneerr import PrettyErrorHandler
+from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler
 from twilight import isWithinTwilight
 
 from rdfdoc import Doc
@@ -19,12 +18,6 @@
 ROOM = Namespace("http://projects.bigasterisk.com/room/")
 DEV = Namespace("http://projects.bigasterisk.com/device/")
 
-
-class GraphHandler(PrettyErrorHandler, cyclone.web.RequestHandler):
-    def get(self):
-        writeGraphResponse(self, self.settings.masterGraph,
-                           self.request.headers.get('accept'))
-
 def update(masterGraph):
     stmt = lambda s, p, o: masterGraph.patchObject(ROOM.environment, s, p, o)
     
@@ -61,10 +54,13 @@
     class Application(cyclone.web.Application):
         def __init__(self):
             handlers = [
-                (r"/()", cyclone.web.StaticFileHandler,
+                (r"/()",
+                 cyclone.web.StaticFileHandler,
                  {"path": ".", "default_filename": "index.html"}),
-                (r'/graph', GraphHandler),
-                (r'/graph/events', GraphEventsHandler),
+                (r'/graph',
+                 CycloneGraphHandler, {'masterGraph': masterGraph}),
+                (r'/graph/events',
+                 CycloneGraphEventsHandler, {'masterGraph': masterGraph}),
                 (r'/doc', Doc), # to be shared
             ]
             cyclone.web.Application.__init__(self, handlers,