Author: justi9
Date: 2008-06-25 15:39:49 -0400 (Wed, 25 Jun 2008)
New Revision: 2164
Modified:
mgmt/basil/python/basil/__init__.py
Log:
Separate the logic for getting object ids; pass the broker id, not the conn, to
get_object
Modified: mgmt/basil/python/basil/__init__.py
===================================================================
--- mgmt/basil/python/basil/__init__.py 2008-06-25 19:29:33 UTC (rev 2163)
+++ mgmt/basil/python/basil/__init__.py 2008-06-25 19:39:49 UTC (rev 2164)
@@ -133,31 +133,33 @@
pass
def on_props(self, conn, class_info, values, timestamps):
- object = self.get_object(class_info, conn, values)
+ id = self.get_object_id(values)
+ object = self.get_object(class_info, conn.broker_id, id)
for name, value in values:
setattr(object, name, value)
def on_stats(self, conn, class_info, values, timestamps):
- object = self.get_object(class_info, conn, values)
+ id = self.get_object_id(values)
+ object = self.get_object(class_info, conn.broker_id, id)
for name, value in values:
setattr(object, name, value)
- def get_object(self, class_info, conn, values):
+ def get_object_id(self, values):
for name, value in values:
- if name == "id":
- id = value
- break
+ if name == "id" and value is not None:
+ return value
- assert id is not None
+ raise Exception("ID not found")
+ def get_object(self, class_info, broker_id, id):
try:
- object = self.objects_by_composite_id[(conn.broker_id, id)]
+ object = self.objects_by_composite_id[(broker_id, id)]
except KeyError:
- object = self.python_class(class_info, conn.broker_id, id)
+ object = self.python_class(class_info, broker_id, id)
self.objects.append(object)
- self.objects_by_composite_id[(conn.broker_id, id)] = object
+ self.objects_by_composite_id[(broker_id, id)] = object
return object