start-moksha
by Luke Macken
start-moksha | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit db72b31798f189d118921baa437751629259e3a7
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Dec 12 14:32:33 2009 -0500
'install', don't 'develop' moksha, since the egg-lnk seems to cause issues with routes
diff --git a/start-moksha b/start-moksha
index ae90c03..dc999f0 100755
--- a/start-moksha
+++ b/start-moksha
@@ -23,7 +23,7 @@ if [ ! $VIRTUAL_ENV ]; then
#echo "Installing Moksha"
echo "Installing Moksha"
#rm -fr dist
- python setup.py develop
+ python setup.py install
#python setup.py bdist_egg
#easy_install -Z dist/*.egg
@@ -56,7 +56,7 @@ if [ ! $VIRTUAL_ENV ]; then
#rm -fr dist
#python setup.py bdist_egg
#easy_install -Z dist/*.egg
- python setup.py develop
+ python setup.py install
fi
fi
14 years, 6 months
moksha/lib
by Luke Macken
moksha/lib/helpers.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 6df8075d69fbb26def97123a9f0cfa9cf6cc3a89
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Dec 7 17:03:50 2009 -0500
Tweak our get_moksha_config_path again
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 496c576..00026e9 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -779,8 +779,8 @@ def get_moksha_config_path():
if in_full_moksha_stack():
return get_main_app_config_path()
else:
- for config_file in ('production.ini', 'development.ini'):
- for config_path in ('.', '/etc/moksha/', __file__ + '/../../../'):
+ for config_path in ('.', '/etc/moksha/', __file__ + '/../../../'):
+ for config_file in ('production.ini', 'development.ini'):
cfg = os.path.join(os.path.abspath(config_path), config_file)
if os.path.isfile(cfg):
return cfg
14 years, 6 months
moksha/lib
by Luke Macken
moksha/lib/helpers.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 277fa3e23d8a3944cfc4dcc9133f4e78aa4b0d18
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Dec 7 16:42:12 2009 -0500
Look in the current directory for a config file
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 8ba747f..496c576 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -763,7 +763,7 @@ def in_full_moksha_stack():
def get_main_app_config_path():
"""
- :returns: The path to the main applications configuratoin file
+ :returns: The path to the main applications configuration file
"""
try:
return pylons.config['__file__']
@@ -780,7 +780,7 @@ def get_moksha_config_path():
return get_main_app_config_path()
else:
for config_file in ('production.ini', 'development.ini'):
- for config_path in ('/etc/moksha/', __file__ + '/../../../'):
+ for config_path in ('.', '/etc/moksha/', __file__ + '/../../../'):
cfg = os.path.join(os.path.abspath(config_path), config_file)
if os.path.isfile(cfg):
return cfg
14 years, 6 months
moksha/tests
by Luke Macken
moksha/tests/quickstarts/test_livewidget.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 97922f0039dcdda123a12a873413fe472ed0eac3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 16:17:43 2009 -0500
Update our livewidget test case for some recent changes
diff --git a/moksha/tests/quickstarts/test_livewidget.py b/moksha/tests/quickstarts/test_livewidget.py
index 72a505b..750247a 100644
--- a/moksha/tests/quickstarts/test_livewidget.py
+++ b/moksha/tests/quickstarts/test_livewidget.py
@@ -64,7 +64,7 @@ class TestLiveWidgetQuickstart(QuickstartTester):
def test_livewidget(self):
""" Ensure our LiveWidget is available """
resp = self.app.get('/widgets/mokshatest')
- assert 'Hello world.' in resp, resp
+ assert 'Welcome' in resp, resp
def test_livewidget_entry_point(self):
""" Ensure our widget is available on the `moksha.widget` entry-point """
14 years, 6 months
24 commits - docs/main moksha/api moksha/apps moksha/commands moksha/hub moksha/public moksha/templates
by Luke Macken
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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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'
+ ),
+ }
+ ),
+)
14 years, 6 months
15 commits - development.ini moksha/api moksha/apps moksha/commands moksha/hub moksha/lib moksha/pastetemplate.py moksha/public moksha.spec moksha/templates pavement.py setup.py
by Luke Macken
development.ini | 5 -
moksha.spec | 2
moksha/api/hub/consumer.py | 30 +++++++-
moksha/api/hub/producer.py | 23 ++++++
moksha/api/widgets/amqp/amqp.py | 15 ++--
moksha/api/widgets/orbited/orbited.py | 2
moksha/api/widgets/stomp/stomp.py | 4 -
moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py | 17 +---
moksha/apps/topics/pavement.py | 36 ----------
moksha/apps/topics/pavement.py.hide | 36 ++++++++++
moksha/commands/quickstart.py | 10 +-
moksha/hub/stomp/stomp.py | 1
moksha/lib/helpers.py | 6 -
moksha/pastetemplate.py | 8 +-
moksha/public/javascript/moksha.js | 1
moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl | 5 -
moksha/templates/moksha/stream/moksha/apps/+package+/streams.py_tmpl | 9 --
pavement.py | 2
setup.py | 2
19 files changed, 129 insertions(+), 85 deletions(-)
New commits:
commit dfb38bf7853707cf4a7780c46a7f6cefcf6ff9e4
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 08:12:31 2009 -0500
A much improved Metrics Consumer using the new API
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 58acdef..e249316 100644
--- a/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py
+++ b/moksha/apps/metrics/moksha/apps/metrics/consumers/metrics_consumer.py
@@ -13,24 +13,21 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Moksha Metrics Consumer
+=======================
-import logging
+.. moduleauthor:: Luke Macken <lmacken(a)redhat.com>
+"""
-from orbited import json
from moksha.api.hub import Consumer
-log = logging.getLogger('moksha.hub')
-
class MokshaMessageMetricsConsumer(Consumer):
"""
This consumer listens to all messages on the `moksha_message_metrics`
- topic, and relays the messgae to the message['headers']['topic']
+ topic, and relays the message to the message.body['topic'] topic.
"""
topic = 'moksha_message_metrics'
def consume(self, message):
- topic = message['headers'].get('topic')
- if topic:
- self.send_message(topic, json.encode(message['body']))
- else:
- log.error('No `topic` specified in moksha_message_metrics message')
+ self.send_message(message['topic'], message['data'])
commit 74f6689c4be9d544e528ba28673f642611036667
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 08:12:03 2009 -0500
Remove an unnecessary debugging statment in our AMQP socket
diff --git a/moksha/api/widgets/amqp/amqp.py b/moksha/api/widgets/amqp/amqp.py
index 22acd29..935422f 100644
--- a/moksha/api/widgets/amqp/amqp.py
+++ b/moksha/api/widgets/amqp/amqp.py
@@ -85,7 +85,6 @@ class AMQPSocket(Widget):
moksha_amqp_remote_queue = null;
moksha_amqp_queue = null;
moksha_amqp_on_message = function(msg) {
- moksha.debug('moksha_amqp_on_message(' + msg.body + ')');
var dest = msg.header.delivery_properties.routing_key;
var json = $.secureEvalJSON(msg.body);
if (moksha_callbacks[dest]) {
commit 909c1b9f8b12c98c78c0d232fa925bedad8cd92f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 08:10:43 2009 -0500
Improve our Consumer API
- Add a 'jsonify' argument that will automatically decode JSON messages
before consuming. It will also encode JSON messages before sending.
- Abstract the Message object, to make it a simple dictionary of the body
diff --git a/moksha/api/hub/consumer.py b/moksha/api/hub/consumer.py
index 08245d9..f3f32d5 100644
--- a/moksha/api/hub/consumer.py
+++ b/moksha/api/hub/consumer.py
@@ -28,14 +28,18 @@ loaded, and receives each message for the specified topic through the
import logging
log = logging.getLogger('moksha.hub')
+
from moksha.hub.hub import MokshaHub
-from moksha.lib.helpers import listify, create_app_engine
+from moksha.lib.helpers import listify, create_app_engine, json
from sqlalchemy.orm import sessionmaker
class Consumer(object):
""" A message consumer """
topic = None
+ # Automatically decode JSON data
+ jsonify = True
+
def __init__(self):
self.hub = MokshaHub()
self.log = log
@@ -50,7 +54,10 @@ class Consumer(object):
self.hub.message_subscribe(queue=server_queue_name,
destination=local_queue_name)
self.hub.local_queue.start()
- self.hub.local_queue.listen(self.consume)
+ if self.jsonify:
+ self.hub.local_queue.listen(self._consume_json)
+ else:
+ self.hub.local_queue.listen(self._consume)
# If the consumer specifies an 'app', then setup `self.engine` to
# be a SQLAlchemy engine, along with a configured DBSession
@@ -61,10 +68,29 @@ 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.
+
+ This method exists because our STOMP & AMQP message brokers consume
+ messages in different formats. This causes our messaging abstraction
+ to leak into the consumers themselves.
+
+ :Note: We do not pass the message headers to the consumer (in this AMQP consumer)
+ 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))
+
+ def _consume(self, message):
+ self.consume(message.body)
+
def consume(self, message):
raise NotImplementedError
def send_message(self, topic, message):
+ if self.jsonify:
+ message = json.encode(message)
try:
self.hub.send_message(topic, message)
except Exception, e:
commit a74264dfb9b0e7d589e38c7140143f5b1612c0a5
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:58:13 2009 -0500
Create a json.{encode,decode} abstraction in moksha.lib.helpers
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index e640817..8ba747f 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -20,11 +20,11 @@ import time
import pylons
import urllib
import uuid
-import simplejson as json
import re
import os
import logging
import warnings
+from orbited import json
from tw.api import js_callback
from pytz import timezone, utc
@@ -59,7 +59,7 @@ def _update_params(params, d):
# by the passed params
if isinstance(value, dict):
value = _update_params(value, d)
- value = json.dumps(value)
+ value = json.encode(value)
elif isinstance(value, list):
value = value
@@ -327,7 +327,7 @@ class App(ConfigWrapper):
qs = self._create_query_string(p)
results.update({'label': self.label, 'url': self.url,
'params': p,
- 'json_params': json.dumps(p),
+ 'json_params': json.encode(p),
'query_string': qs,
'content_id': self.content_id + '-' + results['id'],
'css_class': css_class})
commit 4dcbcf596879ea733d8c7844788fb06ac542a953
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:55:53 2009 -0500
Hide our moksha.topics pavement.py so we don't install it by default
diff --git a/moksha/apps/topics/pavement.py b/moksha/apps/topics/pavement.py
deleted file mode 100644
index 4c8b36f..0000000
--- a/moksha/apps/topics/pavement.py
+++ /dev/null
@@ -1,36 +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.topics",
- 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-topics',
- packages=find_packages(),
- package_data=find_package_data(),
- namespace_packages=[
- 'moksha',
- 'moksha.apps',
- ],
- install_requires=["Moksha"],
- entry_points={
- 'moksha.stream': (
- 'topics = moksha.apps.topics.streams:TopicsStream',
- ),
- 'moksha.consumer': (
- 'topics = moksha.apps.topics.consumers:TopicsConsumer'
- ),
- }
- ),
-)
diff --git a/moksha/apps/topics/pavement.py.hide b/moksha/apps/topics/pavement.py.hide
new file mode 100644
index 0000000..4c8b36f
--- /dev/null
+++ b/moksha/apps/topics/pavement.py.hide
@@ -0,0 +1,36 @@
+# -*- 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.topics",
+ 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-topics',
+ packages=find_packages(),
+ package_data=find_package_data(),
+ namespace_packages=[
+ 'moksha',
+ 'moksha.apps',
+ ],
+ install_requires=["Moksha"],
+ entry_points={
+ 'moksha.stream': (
+ 'topics = moksha.apps.topics.streams:TopicsStream',
+ ),
+ 'moksha.consumer': (
+ 'topics = moksha.apps.topics.consumers:TopicsConsumer'
+ ),
+ }
+ ),
+)
commit 30b98a87a1ead3e6fa3075dfd85f56571ef08ccc
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:31:38 2009 -0500
Empty out the queued stomp frames after we flush them
diff --git a/moksha/hub/stomp/stomp.py b/moksha/hub/stomp/stomp.py
index cca8b08..741c55b 100644
--- a/moksha/hub/stomp/stomp.py
+++ b/moksha/hub/stomp/stomp.py
@@ -53,6 +53,7 @@ class StompHub(MessagingHub, ReconnectingClientFactory):
for frame in self._frames:
log.debug('Flushing queued frame')
self.proto.transport.write(frame.pack())
+ self._frames = []
def clientConnectionLost(self, connector, reason):
log.info('Lost connection. Reason: %s' % reason)
commit 1d2b9a26db669da7e4ef3bc99086eb4bd6a6bf53
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:30:11 2009 -0500
Version bump
diff --git a/moksha.spec b/moksha.spec
index b78f877..d4c594d 100644
--- a/moksha.spec
+++ b/moksha.spec
@@ -2,7 +2,7 @@
%{!?pyver: %define pyver %(%{__python} -c "import sys ; print sys.version[:3]")}
Name: moksha
-Version: 0.4.3
+Version: 0.4.4
Release: 1%{?dist}
Summary: A flexable platform for creating live collaborative web applications
Group: Applications/Internet
diff --git a/pavement.py b/pavement.py
index 412a47a..9fe3c9e 100644
--- a/pavement.py
+++ b/pavement.py
@@ -25,7 +25,7 @@ from paver.setuputils import find_packages, find_package_data
import paver.misctasks
import paver.virtual
-VERSION = '0.4.2'
+VERSION = '0.4.4'
HEADER = """This file is part of Moksha.
Copyright (C) 2008-2009 Red Hat, Inc.
diff --git a/setup.py b/setup.py
index 2bfb452..3b16dcc 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ from paver.setuputils import find_package_data
setup(
name='moksha',
- version='0.4.3',
+ version='0.4.4',
description='',
author='',
author_email='',
commit e5c8fe54e3e10ca6c6aa0537aac041cbd1b51af3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:29:09 2009 -0500
Have our stream quickstart use the producer api
diff --git a/moksha/templates/moksha/stream/moksha/apps/+package+/streams.py_tmpl b/moksha/templates/moksha/stream/moksha/apps/+package+/streams.py_tmpl
index 38fa4b3..845738c 100644
--- a/moksha/templates/moksha/stream/moksha/apps/+package+/streams.py_tmpl
+++ b/moksha/templates/moksha/stream/moksha/apps/+package+/streams.py_tmpl
@@ -1,11 +1,8 @@
-#import logging
-#log = logging.getLogger('moksha.hub')
-
from datetime import timedelta, datetime
-from moksha.api.streams import PollingDataStream
+from moksha.api.hub.producer import PollingProducer
-class {{stream_name}}(PollingDataStream):
- frequency = timedelta(seconds=3)
+class {{stream_name}}(PollingProducer):
+ frequency = timedelta(seconds=5)
topic = '{{topic}}'
i = 0
commit 84634d968c6b394cf64819a796914c56ac97dbcf
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:28:40 2009 -0500
Add a new moksha.api.hub.producer API, to complement the Consumer API
diff --git a/moksha/api/hub/producer.py b/moksha/api/hub/producer.py
new file mode 100644
index 0000000..5986134
--- /dev/null
+++ b/moksha/api/hub/producer.py
@@ -0,0 +1,23 @@
+# This file is part of Moksha.
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+:mod:`moksha.api.hub.producer - The Moksha Producer API
+=======================================================
+"""
+from moksha.api.streams import *
+
+Producer = DataStream
+PollingProducer = PollingDataStream
commit 52e4f365ce4e56567b78a1d663aae63556fcf29a
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:28:13 2009 -0500
Slim down our consumer quickstart
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 6d6a467..0890787 100644
--- a/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl
+++ b/moksha/templates/moksha/consumer/moksha/apps/+package+/consumers.py_tmpl
@@ -1,10 +1,7 @@
-import logging
-log = logging.getLogger('moksha.hub')
-
from moksha.api.hub import Consumer
class {{consumer_name}}(Consumer):
topic = '{{topic}}'
def consume(self, message):
- log.info("%r.consume(%r)" % (self, message))
+ self.log.info("%r.consume(%r)" % (self, message))
commit e161400dfe8be49724e31f734026ff73701f29d4
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:27:43 2009 -0500
Tweak the quickstart default topics
diff --git a/moksha/pastetemplate.py b/moksha/pastetemplate.py
index b099635..53730b7 100644
--- a/moksha/pastetemplate.py
+++ b/moksha/pastetemplate.py
@@ -43,7 +43,7 @@ class MokshaLiveWidgetTemplate(Template):
egg_plugins = ['Moksha']
vars = [
var('topic', 'The moksha topic to utilize',
- default='moksha.topics.test'),
+ default='moksha.test'),
var('livewidget', 'Include an example live widget', default=False),
var('widget_name', 'The name of the widget', default=None),
]
@@ -51,7 +51,7 @@ class MokshaLiveWidgetTemplate(Template):
def pre(self, command, output_dir, vars):
"""Called before template is applied."""
if 'widget_name' not in vars:
- vars['widget_name'] = vars['project'].title() + 'Widget'
+ vars['widget_name'] = vars['package'].title() + 'Widget'
class MokshaStreamTemplate(Template):
summary = 'Moksha Stream Quickstart Template'
@@ -59,7 +59,7 @@ class MokshaStreamTemplate(Template):
template_renderer = staticmethod(paste_script_template_renderer)
vars = [
var('topic', 'The moksha topic to utilize',
- default='moksha.topics.test'),
+ default='moksha.test'),
]
def pre(self, command, output_dir, vars):
@@ -78,7 +78,7 @@ class MokshaConsumerTemplate(Template):
template_renderer = staticmethod(paste_script_template_renderer)
vars = [
var('topic', 'The moksha topic to utilize',
- default='moksha.topics.test'),
+ default='moksha.test'),
]
def pre(self, command, output_dir, vars):
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js
index 7285481..cb2f716 100644
--- a/moksha/public/javascript/moksha.js
+++ b/moksha/public/javascript/moksha.js
@@ -789,7 +789,6 @@ moksha = {
},
send_message: function(topic, body) {
- moksha.debug('moksha.send_message(' + topic + ', ' + body + ')');
if (typeof(moksha_amqp_session) != 'undefined') {
moksha_amqp_session.Message('transfer', {
accept_mode: 1,
commit 90dd2d1060885e265cfe3755aa038f5dedc01019
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:27:08 2009 -0500
Minor tweak to the way we name our quickstart classes
diff --git a/moksha/commands/quickstart.py b/moksha/commands/quickstart.py
index 65d6ac3..f751c4e 100644
--- a/moksha/commands/quickstart.py
+++ b/moksha/commands/quickstart.py
@@ -140,11 +140,11 @@ Example usage::
cmd_args.append("controller=%s" % self.controller)
cmd_args.append("stream=%s" % self.stream)
cmd_args.append("package=%s" % self.package)
- cmd_args.append("widget_name=%s" % self.name.title() + 'Widget')
- cmd_args.append("stream_name=%s" % self.name.title() + 'Stream')
- cmd_args.append("consumer_name=%s" % self.name.title() + 'Consumer')
- cmd_args.append("connector_name=%s" % self.name.title() + 'Connector')
- cmd_args.append("controller_name=%s" % self.name.title() + 'Controller')
+ cmd_args.append("widget_name=%s" % self.package.title() + 'Widget')
+ cmd_args.append("stream_name=%s" % self.package.title() + 'Stream')
+ cmd_args.append("consumer_name=%s" % self.package.title() + 'Consumer')
+ cmd_args.append("connector_name=%s" % self.package.title() + 'Connector')
+ cmd_args.append("controller_name=%s" % self.package.title() + 'Controller')
command.run(cmd_args)
#if not self.dry_run:
commit 4f88806c455dd316ca65b25fc59d915fe38148a6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:26:41 2009 -0500
Make the orbited url scheme configurable, to allow https proxies
diff --git a/moksha/api/widgets/amqp/amqp.py b/moksha/api/widgets/amqp/amqp.py
index 78d2887..22acd29 100644
--- a/moksha/api/widgets/amqp/amqp.py
+++ b/moksha/api/widgets/amqp/amqp.py
@@ -161,7 +161,9 @@ class AMQPSocket(Widget):
self.notify = asbool(config.get('moksha.socket.notify', False))
self.orbited_host = config.get('orbited_host', 'localhost')
self.orbited_port = config.get('orbited_port', 9000)
- self.orbited_url = 'http://%s:%s' % (self.orbited_host, self.orbited_port)
+ self.orbited_scheme = config.get('orbited_scheme', 'http')
+ self.orbited_url = '%s://%s:%s' % (self.orbited_scheme,
+ self.orbited_host, self.orbited_port)
self.orbited_js = JSLink(link=self.orbited_url + '/static/Orbited.js')
self.amqp_broker_host = config.get('amqp_broker_host', 'localhost')
self.amqp_broker_port = config.get('amqp_broker_port', 5672)
diff --git a/moksha/api/widgets/orbited/orbited.py b/moksha/api/widgets/orbited/orbited.py
index 3af78db..2a1516b 100644
--- a/moksha/api/widgets/orbited/orbited.py
+++ b/moksha/api/widgets/orbited/orbited.py
@@ -21,7 +21,7 @@ from tw.api import Widget, JSLink, js_callback
orbited_host = config.get('orbited_host', 'localhost')
orbited_port = config.get('orbited_port', 9000)
-orbited_url = 'http://%s:%s' % (orbited_host, orbited_port)
+orbited_url = '%s://%s:%s' % (config.get('orbited_scheme', 'http'), orbited_host, orbited_port)
orbited_js = JSLink(link=orbited_url + '/static/Orbited.js')
class OrbitedWidget(Widget):
diff --git a/moksha/api/widgets/stomp/stomp.py b/moksha/api/widgets/stomp/stomp.py
index a532b2e..848f10d 100644
--- a/moksha/api/widgets/stomp/stomp.py
+++ b/moksha/api/widgets/stomp/stomp.py
@@ -153,7 +153,9 @@ class StompWidget(Widget):
self.notify = asbool(config.get('moksha.socket.notify', False))
self.orbited_host = config.get('orbited_host', 'localhost')
self.orbited_port = config.get('orbited_port', 9000)
- self.orbited_url = 'http://%s:%s' % (self.orbited_host, self.orbited_port)
+ self.orbited_scheme = config.get('orbited_scheme', 'http')
+ self.orbited_url = '%s://%s:%s' % (self.orbited_scheme,
+ self.orbited_host, self.orbited_port)
self.orbited_js = JSLink(link=self.orbited_url + '/static/Orbited.js')
self.stomp_host = config.get('stomp_host', 'localhost')
self.stomp_port = config.get('stomp_port', 61613)
commit 5d3522a00d84f768e3dcbc249c37865aafdf4b73
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:26:02 2009 -0500
Add our send/recive hooks above everything to avoid ending our dict with a comma
diff --git a/moksha/api/widgets/amqp/amqp.py b/moksha/api/widgets/amqp/amqp.py
index bb6aea1..78d2887 100644
--- a/moksha/api/widgets/amqp/amqp.py
+++ b/moksha/api/widgets/amqp/amqp.py
@@ -115,16 +115,16 @@ class AMQPSocket(Widget):
Orbited.settings.hostname = '${orbited_host}';
Orbited.settings.streaming = true;
moksha_amqp_conn = new amqp.Connection({
- host: '${amqp_broker_host}',
- port: ${amqp_broker_port},
- username: '${amqp_broker_user}',
- password: '${amqp_broker_pass}',
% if send_hook:
send_hook: function(data, frame) { ${send_hook} },
% endif
% if recieve_hook:
- recive_hook: function(data, frame) { ${recieve_hook} }
+ recive_hook: function(data, frame) { ${recieve_hook} },
% endif
+ host: '${amqp_broker_host}',
+ port: ${amqp_broker_port},
+ username: '${amqp_broker_user}',
+ password: '${amqp_broker_pass}',
});
moksha_amqp_conn.start();
commit e28e27b9b4ee2a7d07d7899d2318032d497475b7
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Dec 3 07:25:28 2009 -0500
Add an orbited_scheme to the config
diff --git a/development.ini b/development.ini
index 3d692eb..449263f 100644
--- a/development.ini
+++ b/development.ini
@@ -16,7 +16,7 @@ error_email_from = paste@localhost
[server:main]
use = egg:Paste#http
-host = localhost
+host = 0.0.0.0
port = 8080
[app:main]
@@ -86,6 +86,7 @@ moksha.livesocket.backend = stomp
# The location of our Orbited server
orbited_host = localhost
orbited_port = 9000
+orbited_scheme = http
# Stomp broker configuration.
# By default we use the MorbidQ broker, run by Orbited, for development.
@@ -94,7 +95,7 @@ stomp_port = 61613
stomp_user = guest
stomp_pass = guest
-# Optional AMQP Broker.
+# Optional AMQP Broker
#amqp_broker = guest/guest@localhost
#amqp_broker_host = localhost
#amqp_broker_port = 5672
14 years, 6 months
docs/architecture_diagrams.txt
by Luke Macken
docs/architecture_diagrams.txt | 134 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 134 insertions(+)
New commits:
commit 788b2ab5c612476a51b86119784b8c8164baa649
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 2 17:26:28 2009 -0500
Add some architecture diagrams
diff --git a/docs/architecture_diagrams.txt b/docs/architecture_diagrams.txt
new file mode 100644
index 0000000..aa5fab0
--- /dev/null
+++ b/docs/architecture_diagrams.txt
@@ -0,0 +1,134 @@
+# To build these, you need DiTAA
+# java -jar ditaa0_8.jar architecture_diagrams.txt
+
+Moksha middleware stack
+
+/----------------------------------------------\
+| Optional middleware |
+| +------------------------------------------+ |
+| | repoze.profile | |
+| | Profiling | |
+| +------------------------------------------| |
+| | repoze.squeeze | |
+| | Resource compression | |
+| +------------------------------------------+ |
++----------------------------------------------+
+| TurboGears2 Middleware |
+| +------------------------------------------+ |
+| | Routes | |
+| | Application routing/dispatching | |
+| +------------------------------------------+ |
+| | Beaker | |
+| | Session management | |
+| | Caching layer | |
+| +------------------------------------------+ |
+| | ToscaWidgets | |
+| | Widget resource injection | |
+| +------------------------------------------+ |
+| | repoze.who | |
+| | Authentication | |
+| +------------------------------------------+ |
+| | repoze.what | |
+| | Authorization | |
+| +------------------------------------------+ |
+| | repoze.tm2 | |
+| | Transaction management | |
+| +------------------------------------------+ |
+| | Paste | |
+| | Registry manager | |
+| +------------------------------------------+ |
+| | WebError | |
+| | Error handling & Debugging | |
+| +------------------------------------------+ |
++----------------------------------------------|
+| Moksha Middleware |
+| +--------------+ +---------+ |
+| | Applications | | Widgets | |
+| +--------------+ +---------+ |
++----------------------------------------------|
+| Your Application |
+\----------------------------------------------/
+
+Moksha Hub
+
+/---------------------------\
+| Plugin loader |
++---------------------------+
+| Event loop reactor |
++---------------------------+
+| Plugins |
+| +-----------+-----------+ |
+| | Consumers | Producers | |
+| +-----------+-----------+ |
++---------------------------+
+| Protocol Translator |
+| +-----------+-----------+ |
+| | AMQP | STOMP | |
+| +-----------+-----------+ |
+\---------------------------/
+ ^
+ |
+ v
+ /----------------\
+ | Message Broker |
+ \----------------/
+
+
+Rapid development deployment
+
+/-----------------\ /------------------------------\
+| Orbited | | Moksha Hub |
+| | | |
+| +---------+ +------------+ | |
+| | MorbidQ | <--- | STOMP {io} | ---> | +-----------+ +-----------+ |
+| +---------+ +------------+ | | Producers | | Consumers | |
+\-----------------/ | +-----------+ +-----------+ |
+ \------------------------------/
+
+Bringing an AMQP broker into the mix
+
+/-----------------\ /------------------------------\
+| Orbited | | Moksha Hub |
+| | | |
+| +---------+ +------------+ | | +-----------+ /----------------\
+| | MorbidQ | <--- | STOMP {io} | ---> | +-----------+ +-----------+ | <--- | AMQP {io} | -------> | Qpid |
+| +---------+ +------------+ | | Producers | | Consumers | | +-----------+ | {s} |
+\-----------------/ | +-----------+ +-----------+ | \----------------/
+ \------------------------------/
+
+
+100% AMQP
+
+ /------------------------------\
+ | Moksha Hub |
+/---------\ | | +-----------+ /----------------\
+| Orbited | | +-----------+ +-----------+ | <--- | AMQP {io} | -------> | Qpid |
+\---------/ | | Producers | | Consumers | | +-----------+ | {s} |
+ | +-----------+ +-----------+ | \----------------/
+ | |
+ \------------------------------/
+
+
+Moksha Live Widgets
+
+/-----------------------------------\
+| Browser |
+| |
+| /-------------\ +-------------+ +---------------+ +---------+ +----------------+
+| | Live Widget |<--->| Live Socket |<---|{io}AMQP/STOMP |--->| Orbited |<--->| Message broker |
+| \-------------/ +-------------+ +---------------+ +---------+ +----------------+
+| |
+\-----------------------------------/
+
+
+/-----------------------------------------------------------------------\
+| +--------------------+ +----------------------+ |
+| Live Widget | Topic(s) | | On message callback | |
+| +--------------------+ +----------------------+ |
+| |
+| +-------------------+ +--------------------+ +----------------------+ |
+| | Server side logic | | JS & CSS resources | | Widget template | |
+| +-------------------+ +--------------------+ +----------------------+ |
+\-----------------------------------------------------------------------/
+
+
14 years, 7 months