Author: eallen
Date: 2010-09-17 14:03:57 -0400 (Fri, 17 Sep 2010)
New Revision: 4305
Modified:
mgmt/newdata/cumin/python/cumin/messaging/binding.py
Log:
Fix BZ 634874: Remove binding invocation code was outdated.
Also fixed a problem when displaying remove binding form (single binding, not selection).
A binding has no name attribute so the form contents was blank.
Modified: mgmt/newdata/cumin/python/cumin/messaging/binding.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/binding.py 2010-09-17 15:00:22 UTC (rev
4304)
+++ mgmt/newdata/cumin/python/cumin/messaging/binding.py 2010-09-17 18:03:57 UTC (rev
4305)
@@ -20,14 +20,32 @@
return "Remove"
def do_invoke(self, invoc, binding):
- assert isinstance(binding, Binding)
+ assert isinstance(binding, RosemaryObject)
- session = self.app.model.get_session_by_object(binding)
- session.exchange_unbind(queue=binding.queue.name,
- exchange=binding.exchange.name,
- binding_key=binding.bindingKey)
- session.sync()
+ conn = self.app.database.get_connection()
+ cursor = conn.cursor()
+ queue = None
+ exchange = None
+ try:
+ cls = self.app.model.org_apache_qpid_broker.Queue
+ queue = cls.get_object_by_id(cursor, binding._queueRef_id)
+ cls = self.app.model.org_apache_qpid_broker.Exchange
+ exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
+ except Exception, e:
+ invoc.status = "failed"
+ invoc.exception = e
+ log.exception(e)
+ finally:
+ conn.close()
+
+ if queue and exchange:
+ session = self.app.model.get_session_by_object(binding)
+ session.exchange_unbind(queue=queue.name,
+ exchange=exchange.name,
+ binding_key=binding.bindingKey)
+ session.sync()
+
invoc.end()
class BindingFrame(ObjectFrame):
@@ -55,19 +73,51 @@
invoc.end()
+class BindingRemoveForm(ObjectFrameTaskForm):
+ def render_content(self, session):
+ # binding doesn't have a name, use the binding key
+ obj = self.object.get(session)
+ return obj.bindingKey
+
class BindingRemove(ObjectFrameTask):
+ def __init__(self, app, frame):
+ super(BindingRemove, self).__init__(app, frame)
+
+ self.form = BindingRemoveForm(app, self.name, self)
+
def get_title(self, session):
return "Remove"
+ def do_exit(self, session):
+ self.app.main_page.main.messaging.broker.view.show(session)
+
def do_invoke(self, invoc, binding):
- assert isinstance(binding, Binding)
+ assert isinstance(binding, RosemaryObject)
- session = self.app.model.get_session_by_object(binding)
- session.exchange_unbind(queue=binding.queue.name,
- exchange=binding.exchange.name,
- binding_key=binding.bindingKey)
- session.sync()
+ conn = self.app.database.get_connection()
+ cursor = conn.cursor()
+ queue = None
+ exchange = None
+ try:
+ cls = self.app.model.org_apache_qpid_broker.Queue
+ queue = cls.get_object_by_id(cursor, binding._queueRef_id)
+ cls = self.app.model.org_apache_qpid_broker.Exchange
+ exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
+ except Exception, e:
+ invoc.status = "failed"
+ invoc.exception = e
+ log.exception(e)
+ finally:
+ conn.close()
+
+ if queue and exchange:
+ session = self.app.model.get_session_by_object(binding)
+ session.exchange_unbind(queue=queue.name,
+ exchange=exchange.name,
+ binding_key=binding.bindingKey)
+ session.sync()
+
invoc.end()
class BindingData(ObjectSqlAdapter):
Show replies by date