changeset 1117:f554ddf74097

more control over the callback hostname for rdfdb clients Ignore-this: b165bcaa898f97eac2108ea0abe90a15
author Drew Perttula <drewp@bigasterisk.com>
date Fri, 13 Jun 2014 05:50:08 +0000
parents 2a89050c140b
children 92555101ea56
files light9/networking.py light9/rdfdb/patchreceiver.py light9/rdfdb/syncedgraph.py show/dance2014/networking.n3
diffstat 4 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/light9/networking.py	Fri Jun 13 05:33:05 2014 +0000
+++ b/light9/networking.py	Fri Jun 13 05:50:08 2014 +0000
@@ -30,7 +30,8 @@
     @property
     def url(self):
         return self._url()
-
+    value = url
+    
     def path(self, more):
         return self.url + str(more)
 
@@ -43,3 +44,5 @@
 effectEval = ServiceAddress(L9['effectEval'])
 picamserve = ServiceAddress(L9['picamserve'])
 rdfdb = ServiceAddress(L9['rdfdb'])
+
+patchReceiverUpdateHost = ServiceAddress(L9['patchReceiverUpdateHost'])
--- a/light9/rdfdb/patchreceiver.py	Fri Jun 13 05:33:05 2014 +0000
+++ b/light9/rdfdb/patchreceiver.py	Fri Jun 13 05:50:08 2014 +0000
@@ -1,6 +1,6 @@
 import logging, cyclone.httpclient, traceback, urllib
 from twisted.internet import reactor
-from light9.rdfdb.rdflibpatch import patchQuads
+from light9 import networking
 from light9.rdfdb.patch import Patch
 log = logging.getLogger('syncedgraph')
 
@@ -10,24 +10,27 @@
     master. See onPatch for what happens when the rdfdb master sends
     us a patch
     """
-    def __init__(self, label, onPatch):
+    def __init__(self, rdfdbRoot, label, onPatch):
         """
         label is what we'll call ourselves to the rdfdb server
 
         onPatch is what we call back when the server sends a patch
         """
+        self.rdfdbRoot = rdfdbRoot
         listen = reactor.listenTCP(0, cyclone.web.Application(handlers=[
             (r'/update', makePatchEndpoint(onPatch)),
         ]))
         port = listen._realPortNumber  # what's the right call for this?
-        self.updateResource = 'http://localhost:%s/update' % port
+        
+        self.updateResource = 'http://%s:%s/update' % (
+            networking.patchReceiverUpdateHost.value, port)
         log.info("listening on %s" % port)
         self._register(label)
 
     def _register(self, label):
 
         cyclone.httpclient.fetch(
-            url='http://localhost:8051/graphClients',
+            url=self.rdfdbRoot + 'graphClients',
             method='POST',
             headers={'Content-Type': ['application/x-www-form-urlencoded']},
             postdata=urllib.urlencode([('clientUpdate', self.updateResource),
--- a/light9/rdfdb/syncedgraph.py	Fri Jun 13 05:33:05 2014 +0000
+++ b/light9/rdfdb/syncedgraph.py	Fri Jun 13 05:50:08 2014 +0000
@@ -60,7 +60,7 @@
         self.initiallySynced = defer.Deferred()
         self._graph = ConjunctiveGraph()
 
-        self._receiver = PatchReceiver(label, self._onPatch)
+        self._receiver = PatchReceiver(self.rdfdbRoot, label, self._onPatch)
         
         self._sender = PatchSender(self.rdfdbRoot + 'patches',
                                    self._receiver.updateResource)
--- a/show/dance2014/networking.n3	Fri Jun 13 05:33:05 2014 +0000
+++ b/show/dance2014/networking.n3	Fri Jun 13 05:50:08 2014 +0000
@@ -4,6 +4,7 @@
 
 show:dance2014 :networking sh:netHome .
 sh:netHome
+  :patchReceiverUpdateHost "localhost";
   :rdfdb            <http://localhost:8051/>;
   :effectEval       <http://dash:8070/>;
   :musicPlayer      <http://dash:8040/>;