Author: justi9
Date: 2007-11-29 17:57:09 -0500 (Thu, 29 Nov 2007)
New Revision: 1403
Modified:
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
Log:
Make broker registration work, and use reg entries to actually connect
to running brokers.
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2007-11-29 22:16:50 UTC (rev 1402)
+++ mgmt/cumin/bin/cumin-test 2007-11-29 22:57:09 UTC (rev 1403)
@@ -8,11 +8,9 @@
Options:
--port PORT
--data DATABASE-URL
- --broker BROKER
--bench [HITS]
--profile
--no-debug
- --no-demo-data
""",
sys.exit(1)
@@ -66,13 +64,10 @@
from cumin.demo import *
from cumin.model import *
-def do_main(port, broker, bench_hits, debug=True):
+def do_main(port, bench_hits, debug=True):
model = DummyModel()
app = Cumin(model)
- if broker:
- app.add_managed_broker(broker)
-
if debug or bench_hits:
app.enable_debug()
@@ -84,7 +79,6 @@
server.run()
def main():
- in_broker = args.get("broker")
in_port = int(args.get("port", 9090))
in_profile = "profile" in args
in_debug = "no-debug" not in args
@@ -121,7 +115,7 @@
stats.strip_dirs()
else:
try:
- do_main(in_port, in_broker, in_bench, in_debug)
+ do_main(in_port, in_bench, in_debug)
except KeyboardInterrupt:
pass
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-29 22:16:50 UTC (rev 1402)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-29 22:57:09 UTC (rev 1403)
@@ -40,6 +40,9 @@
self.model.sys = sys
+ for reg in BrokerRegistration.select():
+ self.mint.addManagedBroker(reg.host, reg.port)
+
self.cumin_page = CuminPage(self, "cumin.html")
self.set_default_page(self.cumin_page)
@@ -54,10 +57,6 @@
self.add_page(ClientXmlPage(self, "client.xml"))
self.add_page(ClientChartPage(self, "client.png"))
- def add_managed_broker(self, broker):
- host, port = broker.split(":")
- self.mint.addManagedBroker(host, int(port))
-
class CuminServer(WebServer):
def __init__(self, port=9090):
model = DummyModel()
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-29 22:16:50 UTC (rev 1402)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-29 22:57:09 UTC (rev 1403)
@@ -1,4 +1,4 @@
-import mint
+from mint import *
from wooly import *
from wooly.widgets import *
from random import random
@@ -83,7 +83,7 @@
def get_items(self, session, model):
start, end = self.paginator.get_bounds(session)
- return list(mint.Broker.select())[start:end]
+ return list(Broker.select())[start:end]
def do_process(self, session, model):
if self.submit.get(session):
@@ -109,7 +109,7 @@
class BrokerPaginator(Paginator):
def get_object(self, session, model):
- return list(mint.Broker.select()) #XXX ugh
+ return list(Broker.select()) #XXX ugh
class BrokerFrame(CuminFrame):
def __init__(self, app, name):
@@ -570,14 +570,25 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
+ addrs = self.addrs.get(session)
names = self.names.get(session)
- addrs = self.addrs.get(session)
groups = self.groups.get(session)
- for name, addr, group in zip(names, addrs, groups):
- pass
- #broker = mint.Broker()
+ for i in range(0, len(addrs)):
+ addr = addrs[i]
+ if addr:
+ reg = BrokerRegistration()
+
+ elems = addr.split(":")
+
+ if len(elems) > 1:
+ reg.host, reg.port = elems[0], int(elems[1])
+ else:
+ reg.host = elems[0]
+
+ reg.name = names[i]
+
self.process_cancel(session, model)
class BrokerRemove(CuminConfirmForm):
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2007-11-29 22:16:50 UTC (rev 1402)
+++ mgmt/cumin/python/cumin/broker.strings 2007-11-29 22:57:09 UTC (rev 1403)
@@ -19,7 +19,6 @@
</tr>
[BrokerSetForm.html]
-{page}
<form id="{id}" method="post" action="?">
<!-- <select
onchange="document.getElementById('{id}.submit').submit()"> -->