Author: justi9
Date: 2008-06-25 15:29:33 -0400 (Wed, 25 Jun 2008)
New Revision: 2163
Modified:
mgmt/basil/python/basil/__init__.py
Log:
Use the context arg to callbacks to pass the originating connection
Modified: mgmt/basil/python/basil/__init__.py
===================================================================
--- mgmt/basil/python/basil/__init__.py 2008-06-25 18:26:12 UTC (rev 2162)
+++ mgmt/basil/python/basil/__init__.py 2008-06-25 19:29:33 UTC (rev 2163)
@@ -20,33 +20,32 @@
self.lock = Lock()
- def on_schema(self, broker_id, class_info,
- configs, metrics, methods, events):
+ def on_schema(self, conn, class_info, configs, metrics, methods, events):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_schema(broker_id, class_info,
+ package.on_schema(conn, class_info,
configs, metrics, methods, events)
finally:
self.lock.release()
- def on_props(self, broker_id, class_info, values, timestamps):
+ def on_props(self, conn, class_info, values, timestamps):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_props(broker_id, class_info, values, timestamps)
+ package.on_props(conn, class_info, values, timestamps)
finally:
self.lock.release()
- def on_stats(self, broker_id, class_info, values, timestamps):
+ def on_stats(self, conn, class_info, values, timestamps):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_stats(broker_id, class_info, values, timestamps)
+ package.on_stats(conn, class_info, values, timestamps)
finally:
self.lock.release()
- def on_callback(self, broker_id, seq, status_code, status_text, args):
+ def on_callback(self, conn, seq, status_code, status_text, args):
self.lock.acquire()
try:
object, name, callback, kwargs = self.method_calls.pop(seq)
@@ -77,19 +76,17 @@
self.classes = list()
- def on_schema(self, broker_id, class_info,
- configs, metrics, methods, events):
+ def on_schema(self, conn, class_info, configs, metrics, methods, events):
cls = self.get_class(class_info)
- cls.on_schema(broker_id, class_info,
- configs, metrics, methods, events)
+ cls.on_schema(conn, class_info, configs, metrics, methods, events)
- def on_props(self, broker_id, class_info, values, timestamps):
+ def on_props(self, conn, class_info, values, timestamps):
cls = self.get_class(class_info)
- cls.on_props(broker_id, class_info, values, timestamps)
+ cls.on_props(conn, class_info, values, timestamps)
- def on_stats(self, broker_id, class_info, values, timestamps):
+ def on_stats(self, conn, class_info, values, timestamps):
cls = self.get_class(class_info)
- cls.on_stats(broker_id, class_info, values, timestamps)
+ cls.on_stats(conn, class_info, values, timestamps)
def get_class(self, class_info):
name = class_info[1]
@@ -120,8 +117,7 @@
attrs["basil_class"] = self
self.python_class = type(str(name), (BasilObject,), attrs)
- def on_schema(self, broker_id, class_info,
- configs, metrics, methods, events):
+ def on_schema(self, conn, class_info, configs, metrics, methods, events):
for spec in configs:
setattr(self.python_class, spec[0], None)
@@ -136,19 +132,19 @@
for spec in events:
pass
- def on_props(self, broker_id, class_info, values, timestamps):
- object = self.get_object(class_info, broker_id, values)
+ def on_props(self, conn, class_info, values, timestamps):
+ object = self.get_object(class_info, conn, values)
for name, value in values:
setattr(object, name, value)
- def on_stats(self, broker_id, class_info, values, timestamps):
- object = self.get_object(class_info, broker_id, values)
+ def on_stats(self, conn, class_info, values, timestamps):
+ object = self.get_object(class_info, conn, values)
for name, value in values:
setattr(object, name, value)
- def get_object(self, class_info, broker_id, values):
+ def get_object(self, class_info, conn, values):
for name, value in values:
if name == "id":
id = value
@@ -157,11 +153,11 @@
assert id is not None
try:
- object = self.objects_by_composite_id[(broker_id, id)]
+ object = self.objects_by_composite_id[(conn.broker_id, id)]
except KeyError:
- object = self.python_class(class_info, broker_id, id)
+ object = self.python_class(class_info, conn.broker_id, id)
self.objects.append(object)
- self.objects_by_composite_id[(broker_id, id)] = object
+ self.objects_by_composite_id[(conn.broker_id, id)] = object
return object
@@ -217,7 +213,7 @@
def open(self):
self.conn.start()
self.chan = self.mclient.addChannel \
- (self.conn.session(str(uuid4())), self.broker_id)
+ (self.conn.session(str(uuid4())), self)
def close(self):
self.mclient.removeChannel(self.chan)