docs/main/Consumers.rst | 16 ++ docs/main/Design.rst | 26 ++++ docs/main/MokshaHub.rst | 3 moksha/api/hub/__init__.py | 3 moksha/api/hub/consumer.py | 24 +++- moksha/apps/knowledge/pavement.py | 34 ------ moksha/apps/knowledge/pavement.py.hide | 34 ++++++ moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py | 2 moksha/apps/metrics/moksha/apps/metrics/widgets/metrics.py | 5 moksha/commands/quickstart.py | 8 - moksha/hub/amqp/qpid010.py | 8 + moksha/hub/hub.py | 56 ++++++---- moksha/public/javascript/moksha.js | 7 + moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl | 5 moksha/templates/moksha/livewidget/moksha/widgets/+package+/templates/widget.mak_tmpl | 20 +++ moksha/templates/moksha/livewidget/moksha/widgets/+package+/widgets.py_tmpl | 7 - 16 files changed, 187 insertions(+), 71 deletions(-)
New commits: commit 4f07c9ba83d35c4a8f26eb1a0d59d889373e6826 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 20:11:58 2009 -0500
Turn our LiveWidget quickstart into a chat application
diff --git a/moksha/templates/moksha/livewidget/moksha/widgets/+package+/templates/widget.mak_tmpl b/moksha/templates/moksha/livewidget/moksha/widgets/+package+/templates/widget.mak_tmpl index 7b98a14..e165b86 100644 --- a/moksha/templates/moksha/livewidget/moksha/widgets/+package+/templates/widget.mak_tmpl +++ b/moksha/templates/moksha/livewidget/moksha/widgets/+package+/templates/widget.mak_tmpl @@ -1,3 +1,21 @@ <div id="${id}"> - Hello world. + + <input id="chat_${id}_name" type="text" value="Anonymous" size="10"/> + <input id="chat_${id}_input" type="text" size="34" name="input" + onkeypress="moksha.on_enter(event, send_chat_message)"> + <br/> + <textarea id="chat_${id}" cols="55" rows="25" readonly="true">Welcome to ${topic}</textarea> + + <script type="text/javascript"> + function send_chat_message(){ + var input = $('#chat_${id}_input'); + moksha.send_message('${topic}', { + message: input.val() + '\n', + name: $('#chat_${id}_name').val() + }); + input.val(""); + } + $('#chat_${id}_input').focus(); + </script> + </div> diff --git a/moksha/templates/moksha/livewidget/moksha/widgets/+package+/widgets.py_tmpl b/moksha/templates/moksha/livewidget/moksha/widgets/+package+/widgets.py_tmpl index 1a6cc1e..09f887e 100644 --- a/moksha/templates/moksha/livewidget/moksha/widgets/+package+/widgets.py_tmpl +++ b/moksha/templates/moksha/livewidget/moksha/widgets/+package+/widgets.py_tmpl @@ -2,8 +2,11 @@ from moksha.api.widgets.live import LiveWidget
class {{widget_name}}(LiveWidget): topic = '{{topic}}' - params = ['id'] - onmessage = "$('<div/>').text(json.message).appendTo('#${id}');" + params = ['id', 'topic'] + onmessage = """ + $('#chat_${id}').val(json.name + ': ' + json.message + + $('#chat_${id}').val()) + """ template = 'mako:moksha.widgets.{{package}}.templates.widget'
def update_params(self, d):
commit 69309477ac7df6a18be5b6e42ff39098f4e6d58b Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 20:11:41 2009 -0500
Add a pretty useful moksha.on_enter javascript function
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js index cb2f716..01e1aff 100644 --- a/moksha/public/javascript/moksha.js +++ b/moksha/public/javascript/moksha.js @@ -804,6 +804,13 @@ moksha = { } else { stomp.send($.toJSON(body), topic) } + }, + + on_enter: function(e, callback) { + var key = e.keyCode || e.which; + if (key == 13) { + callback(e); + } }
}
commit 46d2dd7efdbc81f97351e8f6fcdfd4d0ffd4f6cf Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:34:55 2009 -0500
Update our consumer quickstart to expose more options
diff --git a/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl b/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl index 0890787..a86761b 100644 --- a/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl +++ b/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl @@ -1,7 +1,12 @@ from moksha.api.hub import Consumer
class {{consumer_name}}(Consumer): + + # The message topic to listen to. topic = '{{topic}}'
+ # Automatically decode message as JSON, and encode when using self.send_message + jsonify = True + def consume(self, message): self.log.info("%r.consume(%r)" % (self, message))
commit 6ac26d24320058ff10c0d152869df2b2cca184eb Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:34:37 2009 -0500
Make our hub more robust and handle when we can't find a config
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 47ad48b..e34058d 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -236,7 +236,14 @@ def setup_logger(verbose): def main(): """ The main MokshaHub method """ setup_logger('-v' in sys.argv or '--verbose' in sys.argv) - cfg = appconfig('config:' + get_moksha_config_path()) + config_path = get_moksha_config_path() + if not config_path: + print """ + Cannot find Moksha configuration! Place a development.ini or production.ini + in /etc/moksha or in the current directory. + """ + return + cfg = appconfig('config:' + config_path) config.update(cfg)
hub = CentralMokshaHub()
commit 6d9407af2d185b8028d10913a35b009cf6de5215 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:34:10 2009 -0500
AMQP onmessage handler; don't proxy topic-less messages to STOMP
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 83874ae..47ad48b 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -113,13 +113,12 @@ class MokshaHub(StompHub, AMQPHub):
def consume_amqp_message(self, message): self.message_accept(message) - topic = message.headers[0]['routing_key'] try: - body = json.decode(message.body) - except Exception, e: - log.warning('Cannot decode message from JSON: %s' % e) - log.debug('Message: %r' % message.body) - body = message.body + topic = message.get('delivery_properties').routing_key + except AttributeError: + # If we receive an AMQP message without a toipc, don't proxy it to STOMP + return + if self.stomp_broker: StompHub.send_message(self, topic.encode('utf8'), message.body.encode('utf8'))
commit 01fad05b3fd2e826fe54c834a7b410bd298f4ce7 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:32:20 2009 -0500
Always jsonify if it's enabled
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 25597ae..83874ae 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -86,7 +86,7 @@ class MokshaHub(StompHub, AMQPHub): else: topics = topic for topic in topics: - if jsonify and not isinstance(message, basestring): + if jsonify: message = json.encode(message) if self.amqp_broker: AMQPHub.send_message(self, topic, message, routing_key=topic)
commit 861d7719d259aa1f12ddd5d919ce392bdb7b6a92 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:32:02 2009 -0500
Tweak some log messages
diff --git a/moksha/hub/amqp/qpid010.py b/moksha/hub/amqp/qpid010.py index 1bf15bb..1da6131 100644 --- a/moksha/hub/amqp/qpid010.py +++ b/moksha/hub/amqp/qpid010.py @@ -45,6 +45,7 @@ class QpidAMQPHub(BaseAMQPHub): username=self.user, password=self.password) self.connection.start() + log.info("Connected to AMQP Broker %s" % self.host) self.session = self.connection.session(str(uuid4()))
def set_broker(self, broker): diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 7ee067e..25597ae 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -48,6 +48,10 @@ class MokshaHub(StompHub, AMQPHub): self.amqp_broker = config.get('amqp_broker', None) self.stomp_broker = config.get('stomp_broker', None)
+ if self.amqp_broker and self.stomp_broker: + log.warning("Running with both a STOMP and AMQP broker. " + "This mode is experimental and may or may not work") + if not self.topics: self.topics = defaultdict(list)
@@ -59,7 +63,6 @@ class MokshaHub(StompHub, AMQPHub): self.topics[topic].append(callback)
if self.amqp_broker: - log.info('Initializing AMQP support') AMQPHub.__init__(self, self.amqp_broker)
if self.stomp_broker:
commit 0b362bf4a6d97fcdea703cca81a2948127cc11ae Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:31:51 2009 -0500
Tweak our quickstart rpm_name
diff --git a/moksha/commands/quickstart.py b/moksha/commands/quickstart.py index ff79075..45afa90 100644 --- a/moksha/commands/quickstart.py +++ b/moksha/commands/quickstart.py @@ -97,7 +97,7 @@ Example usage:: "Enter package name [%s]: " % package).strip() or package
self.name = pkg_resources.safe_name(self.name).replace('-', '_') - self.rpm_name = self.name.replace('.', '_') + self.rpm_name = self.package.replace('.', '-')
env = pkg_resources.Environment() if self.name.lower() in env:
commit b71ad5970da310b91937ebb37410be4ae3c70344 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:31:28 2009 -0500
Properly handle when we accept a message on a closed AMQP session
diff --git a/moksha/hub/amqp/qpid010.py b/moksha/hub/amqp/qpid010.py index 2af134d..1bf15bb 100644 --- a/moksha/hub/amqp/qpid010.py +++ b/moksha/hub/amqp/qpid010.py @@ -21,6 +21,7 @@ import logging from qpid.util import connect, URL, ssl from qpid.datatypes import Message, uuid4, RangedSet from qpid.connection import Connection +from qpid.session import SessionClosed
from moksha.hub.amqp.base import BaseAMQPHub
@@ -87,7 +88,11 @@ class QpidAMQPHub(BaseAMQPHub): destination=destination)
def message_accept(self, message): - self.session.message_accept(RangedSet(message.id)) + try: + self.session.message_accept(RangedSet(message.id)) + except SessionClosed: + log.debug("Accepted message on closed session: %s" % message.id) + pass
def close(self): self.session.close(timeout=2)
commit 5d9b5e6508e6899f0526201765b2b5e3cef92635 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:30:55 2009 -0500
s/--stream/--producer/
diff --git a/moksha/commands/quickstart.py b/moksha/commands/quickstart.py index fe61f60..ff79075 100644 --- a/moksha/commands/quickstart.py +++ b/moksha/commands/quickstart.py @@ -58,8 +58,8 @@ Example usage:: parser.add_option("-C", "--controller", help='Create an example Moksha Controller', action="store_true", dest="controller") - parser.add_option("-s", "--stream", - help='Create an example Moksha DataStream', + parser.add_option("-P", "--producer", + help='Create an example Moksha Producer', action="store_true", dest="stream") parser.add_option("-p", "--package", help="package name for the code",
commit ab3edabec77762cf755a959c65e885cfd5c6f643 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:30:41 2009 -0500
Default our quickstart topic to moksha.test
diff --git a/moksha/commands/quickstart.py b/moksha/commands/quickstart.py index f751c4e..fe61f60 100644 --- a/moksha/commands/quickstart.py +++ b/moksha/commands/quickstart.py @@ -40,7 +40,7 @@ Example usage:: consumer = False stream = False
- topic = 'moksha.topics.test' + topic = 'moksha.test'
parser = command.Command.standard_parser(quiet=True) parser = optparse.OptionParser(
commit cd82c3a205ee2e459fb7a8bf04974e22b7bd52d4 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:30:25 2009 -0500
Make a note for the next generation of metrics
diff --git a/moksha/apps/metrics/moksha/apps/metrics/widgets/metrics.py b/moksha/apps/metrics/moksha/apps/metrics/widgets/metrics.py index d62c427..9c22535 100644 --- a/moksha/apps/metrics/moksha/apps/metrics/widgets/metrics.py +++ b/moksha/apps/metrics/moksha/apps/metrics/widgets/metrics.py @@ -91,6 +91,11 @@ class MokshaMessageMetricsWidget(LiveFlotWidget): for (var i = 0; i < NUM_MESSAGES; i++) { var start = new Date(); start_time = start.getTime(); + /* Eventually, once our AMQP bindings don't explode, send + the messages directly to the AMQP queue, instead of going + through a consumer. it would be nice to benchmark both. + moksha.send_message('${topic}', start.getTime() + ''); + */ moksha.send_message('moksha_message_metrics', { data: start.getTime() + '', topic: '${topic}'
commit 1d74ba63dda5193a5287a45c9570a7c2ece6fb42 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:30:09 2009 -0500
Fix the data format of our metrics consumer
diff --git a/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py b/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py index e249316..50dfc03 100644 --- a/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py +++ b/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py @@ -30,4 +30,4 @@ class MokshaMessageMetricsConsumer(Consumer): topic = 'moksha_message_metrics'
def consume(self, message): - self.send_message(message['topic'], message['data']) + self.send_message(message['body']['topic'], message['body']['data'])
commit 86cdfc82a77d6cd79deb6abd80011f5e2f51d849 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:29:45 2009 -0500
Don't double-JSON encode our messages from consumers
diff --git a/moksha/api/hub/consumer.py b/moksha/api/hub/consumer.py index 0f9aea8..078319a 100644 --- a/moksha/api/hub/consumer.py +++ b/moksha/api/hub/consumer.py @@ -103,10 +103,8 @@ class Consumer(object): raise NotImplementedError
def send_message(self, topic, message): - if self.jsonify: - message = json.encode(message) try: - self.hub.send_message(topic, message) + self.hub.send_message(topic, message, jsonify=self.jsonify) except Exception, e: log.error('Cannot send message: %s' % e)
commit da1ab8d45c074ef9f9f164af51843f26fb5f1b05 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 18:29:23 2009 -0500
Make our consumer JSON decoding more robust
diff --git a/moksha/api/hub/consumer.py b/moksha/api/hub/consumer.py index d353fb9..0f9aea8 100644 --- a/moksha/api/hub/consumer.py +++ b/moksha/api/hub/consumer.py @@ -79,7 +79,11 @@ class Consumer(object): because the current AMQP.js bindings do not allow the client to change them. Thus, we need to throw any topic/queue details into the JSON body itself. """ - body = json.decode(message.body) + try: + body = json.decode(message.body) + except: + log.debug("Unable to decode message body to JSON: %r" % message.body) + body = message.body topic = None try: topic = message.headers[0].routing_key
commit 55a8a5d343b0969689a07cf48fb266f287799b72 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 15:02:58 2009 -0500
Pass {'body': JSON.decode(body), 'topic': 'moksha.topic'} to the consumers, with both AMQP and STOMP
diff --git a/moksha/api/hub/consumer.py b/moksha/api/hub/consumer.py index 5574c43..d353fb9 100644 --- a/moksha/api/hub/consumer.py +++ b/moksha/api/hub/consumer.py @@ -80,11 +80,20 @@ class Consumer(object): Thus, we need to throw any topic/queue details into the JSON body itself. """ body = json.decode(message.body) - body['raw'] = message - self.consume(body) + topic = None + try: + topic = message.headers[0].routing_key + except TypeError: + # We didn't get a JSON dictionary + pass + except AttributeError: + # We didn't get headers or a routing key? + pass + + self.consume({'body': body, 'topic': topic})
def _consume(self, message): - self.consume(message.body) + self.consume(message)
def consume(self, message): raise NotImplementedError diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 8978822..7ee067e 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -127,19 +127,16 @@ class MokshaHub(StompHub, AMQPHub): log.debug("Got message without a topic: %r" % message) return
+ # FIXME: only do this if the consumer wants it `jsonified` try: body = json.decode(message['body']) except Exception, e: log.warning('Cannot decode message from JSON: %s' % e) body = {}
- # Feed our consumers with dictionaries of the JSON bodies, but - # also make the native AMQP or STOMP message objects available. - body['raw'] = message - # feed all of our consumers for callback in self.topics.get(topic, []): - reactor.callInThread(callback, body) + reactor.callInThread(callback, {'body': body, 'topic': topic})
class CentralMokshaHub(MokshaHub):
commit d78913be13184ad0f4cd6aa72216a1dcd6dc1201 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 14:31:09 2009 -0500
Update our consumer documentation
diff --git a/docs/main/Consumers.rst b/docs/main/Consumers.rst index 3e4d371..62afc53 100644 --- a/docs/main/Consumers.rst +++ b/docs/main/Consumers.rst @@ -11,10 +11,15 @@ Creating from moksha.api.hub import Consumer
class FeedConsumer(Consumer): - topic = 'feeds' + + # The topic to listen to. + topic = 'moksha.feeds' + + # Automatically decode message as JSON, and encode when using self.send_message + jsonify = True
def consume(self, message): - print message['headers'] + print message['topic'] print message['body']
.. note:: @@ -23,6 +28,13 @@ Creating Thread, so be sure to employ thread-safety precausions when implementing your :class:`Consumer`.
+.. note:: + + If your using AMQP, your `topic` can using wildcards. + http://www.rabbitmq.com/faq.html#wildcards-in-topic-exchanges + + Wildcard topics do not work using STOMP. + Installing ----------
commit 75a19b7055e4677788c79932453898cfd2cb54c7 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 14:06:39 2009 -0500
Change a message log from debug to an info
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index bb6a776..8978822 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -179,8 +179,8 @@ class CentralMokshaHub(MokshaHub): log.info('Loading Moksha Consumers') for consumer in pkg_resources.iter_entry_points('moksha.consumer'): c_class = consumer.load() - log.debug("%s consumer is watching the %r topic" % ( - c_class.__name__, c_class.topic)) + log.info("%s consumer is watching the %r topic" % ( + c_class.__name__, c_class.topic)) self.topics[c_class.topic].append(c_class)
def __run_consumers(self):
commit c63b90fdc4214fd9d009d155b586699496ba95a7 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:55:47 2009 -0500
Add an initial Design doc (not exposed yet)
diff --git a/docs/main/Design.rst b/docs/main/Design.rst new file mode 100644 index 0000000..30fefc6 --- /dev/null +++ b/docs/main/Design.rst @@ -0,0 +1,26 @@ +Design +====== + +Moksha aims to simplify the design process and allow you to quickly being +innovating. To do this Moksha supports a variety of CSS and JavaScript +frameworks, making it easy to utilize and leverage existing plugins. + +CSS Frameworks +-------------- + +.. toctree:: + + Blueprint + + +JavaScript Frameworks +--------------------- + +jQuery +~~~~~~ + +See the `ToscaWidgets Cookbook http://turbogears.org/2.0/docs/main/ToscaWidgets/Cookbook.html`_ for some examples. + +See the :mod:`tw.jquery` module for many useful jQuery plugins. + +:note: More jQuery-docs coming soon!
commit 9387a800143c3f0aee1b612f0487d1457a1425aa Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:54:51 2009 -0500
Feed our consumers a JSON decoded body, with the 'raw' message object available
diff --git a/moksha/api/hub/consumer.py b/moksha/api/hub/consumer.py index f3f32d5..5574c43 100644 --- a/moksha/api/hub/consumer.py +++ b/moksha/api/hub/consumer.py @@ -68,7 +68,6 @@ class Consumer(object): self.engine = create_app_engine(app) self.DBSession = sessionmaker(bind=self.engine)()
- def _consume_json(self, message): """ Convert our AMQP messages into a consistent dictionary format.
@@ -80,7 +79,9 @@ class Consumer(object): because the current AMQP.js bindings do not allow the client to change them. Thus, we need to throw any topic/queue details into the JSON body itself. """ - self.consume(json.decode(message.body)) + body = json.decode(message.body) + body['raw'] = message + self.consume(body)
def _consume(self, message): self.consume(message.body) diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 2dd3f67..bb6a776 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -124,18 +124,22 @@ class MokshaHub(StompHub, AMQPHub): def consume_stomp_message(self, message): topic = message['headers'].get('destination') if not topic: + log.debug("Got message without a topic: %r" % message) return
- # We can enable this if/when we need it... - #try: - # body = json.decode(message['body']) - #except Exception, e: - # log.warning('Cannot decode message from JSON: %s' % e) - # body = message['body'] + try: + body = json.decode(message['body']) + except Exception, e: + log.warning('Cannot decode message from JSON: %s' % e) + body = {} + + # Feed our consumers with dictionaries of the JSON bodies, but + # also make the native AMQP or STOMP message objects available. + body['raw'] = message
# feed all of our consumers for callback in self.topics.get(topic, []): - reactor.callInThread(callback, message) + reactor.callInThread(callback, body)
class CentralMokshaHub(MokshaHub):
commit f4c5b6119281d8d902b323d7d359d41cf4622d19 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:51:39 2009 -0500
Make a note about running the hub reactor when using the MokshaHub API
diff --git a/docs/main/MokshaHub.rst b/docs/main/MokshaHub.rst index 4831ee2..e9f2a0c 100644 --- a/docs/main/MokshaHub.rst +++ b/docs/main/MokshaHub.rst @@ -10,9 +10,10 @@ applications to send messages to a given topic.
.. code-block:: python
- from moksha.hub import MokshaHub + from moksha.api.hub import MokshaHub, reactor hub = MokshaHub() hub.send_message('topic', 'message') + reactor.run() hub.close()
Behind the scenes, the :class:`MokshaHub` will automatically connect up to
commit 29442343b42296fb29cfe62f4f469116553bf157 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:50:47 2009 -0500
Support running the MokshaHub outside of the WSGI or Hub stack
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index c16103d..2dd3f67 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -27,7 +27,7 @@ from tg import config from orbited import json from paste.deploy import appconfig
-from moksha.lib.helpers import trace, defaultdict, get_moksha_config_path +from moksha.lib.helpers import trace, defaultdict, get_moksha_config_path, get_moksha_appconfig from moksha.hub.amqp import AMQPHub from moksha.hub.stomp import StompHub
@@ -38,8 +38,16 @@ class MokshaHub(StompHub, AMQPHub): topics = None # {topic_name: [callback,]}
def __init__(self, topics=None): + global config self.amqp_broker = config.get('amqp_broker', None) self.stomp_broker = config.get('stomp_broker', None) + + # If we're running outside of middleware and hub, load config + if not self.amqp_broker and not self.stomp_broker: + config = get_moksha_appconfig() + self.amqp_broker = config.get('amqp_broker', None) + self.stomp_broker = config.get('stomp_broker', None) + if not self.topics: self.topics = defaultdict(list)
commit fb9ca96431a4f72135245705359eb1f6d340a536 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:50:28 2009 -0500
Make the MokshaHub and reactor available in the moksha.api.hub module
diff --git a/moksha/api/hub/__init__.py b/moksha/api/hub/__init__.py index 91219a4..c99dc45 100644 --- a/moksha/api/hub/__init__.py +++ b/moksha/api/hub/__init__.py @@ -16,3 +16,6 @@
from consumer import * from hub import * + +from moksha.hub.reactor import reactor +from moksha.hub.hub import MokshaHub
commit 1a1a0fae5195a9fddab0ee7d0fb0b2b7793bd5e0 Author: Luke Macken lmacken@redhat.com Date: Thu Dec 3 13:32:06 2009 -0500
Don't install our knowledge app yet
diff --git a/moksha/apps/knowledge/pavement.py b/moksha/apps/knowledge/pavement.py deleted file mode 100644 index e4b20dc..0000000 --- a/moksha/apps/knowledge/pavement.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -from paver.easy import * -from paver.setuputils import (setup, find_package_data, find_packages, - install_distutils_tasks) -install_distutils_tasks() -from moksha.lib.paver_tasks import * - -options( - setup=Bunch( - name="moksha.knowledge", - version="0.1", - release="1", - url="http://moksha.fedorahosted.org", - description="Describe your package here", - license="AGPLv3", - long_description="", - author="", - author_email="", - rpm_name='moksha-apps-knowledge', - packages=find_packages(), - package_data=find_package_data(), - namespace_packages=[ - 'moksha', - 'moksha.apps', - - ], - install_requires=["Moksha"], - entry_points={ - 'moksha.application': ( - 'moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController' - ), - } - ), -) diff --git a/moksha/apps/knowledge/pavement.py.hide b/moksha/apps/knowledge/pavement.py.hide new file mode 100644 index 0000000..e4b20dc --- /dev/null +++ b/moksha/apps/knowledge/pavement.py.hide @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +from paver.easy import * +from paver.setuputils import (setup, find_package_data, find_packages, + install_distutils_tasks) +install_distutils_tasks() +from moksha.lib.paver_tasks import * + +options( + setup=Bunch( + name="moksha.knowledge", + version="0.1", + release="1", + url="http://moksha.fedorahosted.org", + description="Describe your package here", + license="AGPLv3", + long_description="", + author="", + author_email="", + rpm_name='moksha-apps-knowledge', + packages=find_packages(), + package_data=find_package_data(), + namespace_packages=[ + 'moksha', + 'moksha.apps', + + ], + install_requires=["Moksha"], + entry_points={ + 'moksha.application': ( + 'moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController' + ), + } + ), +)