import zmq


class Publish:
    def __init__(self, tcpPort):
        self._bindTo = "tcp://127.0.0.1:%d" % tcpPort
        self._context = zmq.Context()
        self._socket = self._context.socket(zmq.PUB)
        self._socket.bind(self._bindTo)

    def allocationChangedState(self, allocationID):
        self._publish(event='allocation__changedState', allocationID=allocationID)

    def allocationProviderMessage(self, allocationID, message):
        self._publish(event='allocation__providerMessage', allocationID=allocationID, message=message)

    def _publish(self, ** kwargs):
        self._socket.send_json(kwargs)

@@ -51,16 +51,31 @@
  tcpPort
+, localhostOnly
 ):%0A     
@@ -103,31 +103,64 @@
 p://
-127.0.0.1:%25d%22 %25
+%25s:%25d%22 %25 (%22127.0.0.1%22 if localhostOnly else %22*%22,
  tcpPort
 %0A   
@@ -155,16 +155,17 @@
  tcpPort
+)
 %0A       

Support non localhost pubsub