docs/main/GettingStarted.rst | 6 ++--- moksha/apps/helloworld/demo/consumer.py | 7 +++++- moksha/hub/amqp/pyamqplib.py | 5 +++- moksha/hub/hub.py | 34 +++++++++++++++++--------------- moksha/lib/helpers.py | 3 ++ 5 files changed, 35 insertions(+), 20 deletions(-)
New commits: commit 585e7e9885630474824bd774781694aa5bf1af5c Author: Luke Macken lmacken@redhat.com Date: Tue Jan 18 11:30:06 2011 -0500
Deprecate to_unicode
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index be3bd77..365dd7d 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -812,6 +812,9 @@ def create_app_engine(app):
def to_unicode(obj, encoding='utf-8', errors='replace'): + """ + :deprecated: by to_unicode in http://python-kitchen.fedorahosted.org + """ if isinstance(obj, basestring): if not isinstance(obj, unicode): obj = unicode(obj, encoding, errors)
commit 77bce25a53d5b15b19370f18bd79eca024311739 Author: Luke Macken lmacken@redhat.com Date: Tue Jan 18 11:29:42 2011 -0500
Make sure we can run w/o amqplib
diff --git a/moksha/hub/amqp/pyamqplib.py b/moksha/hub/amqp/pyamqplib.py index 32c1f31..faf306f 100644 --- a/moksha/hub/amqp/pyamqplib.py +++ b/moksha/hub/amqp/pyamqplib.py @@ -17,7 +17,10 @@
import logging
-import amqplib.client_0_8 as amqp +try: + import amqplib.client_0_8 as amqp +except ImportError: + pass
from moksha.lib.helpers import trace from moksha.hub.amqp.base import BaseAMQPHub
commit 93bac52ec4c4fc551135b39599b6a3496bede1db Author: Luke Macken lmacken@redhat.com Date: Tue Jan 18 11:29:22 2011 -0500
doc title changes
diff --git a/docs/main/GettingStarted.rst b/docs/main/GettingStarted.rst index 6c08639..84cdf92 100644 --- a/docs/main/GettingStarted.rst +++ b/docs/main/GettingStarted.rst @@ -5,10 +5,10 @@ Getting Started with Moksha There are currently two ways of installing and running Moksha.
.. toctree:: - :maxdepth: 1 + :maxdepth: 0
- RPMInstallation - VirtualenvInstallation + RPMInstallation (Fedora, RHEL, CentOS) + VirtualenvInstallation (Other linux distros, OSX, etc.)
Once you have Moksha installed, there are many ways to start using it.
commit 1aa7c69fb76d66e4be2db8b0c8218972ecff1548 Author: Luke Macken lmacken@redhat.com Date: Sun Jan 16 22:07:29 2011 -0500
log.info when the hub starts
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index a0c6987..4fc155c 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -161,6 +161,7 @@ class CentralMokshaHub(MokshaHub): producers = None # [<Producer>,]
def __init__(self): + log.info('Loading the Moksha Hub') self.topics = defaultdict(list) self.__init_consumers()
commit de6efd68aea3f98e0cb53fe382465636d49ae418 Author: Luke Macken lmacken@redhat.com Date: Sun Jan 16 22:04:49 2011 -0500
Update our hub to use more up to date terminology with variable/method names
diff --git a/moksha/hub/hub.py b/moksha/hub/hub.py index 5371474..a0c6987 100644 --- a/moksha/hub/hub.py +++ b/moksha/hub/hub.py @@ -158,7 +158,7 @@ class CentralMokshaHub(MokshaHub): The Moksha Hub is responsible for initializing all of the Hooks, AMQP queues, exchanges, etc. """ - data_streams = None # [<DataStream>,] + producers = None # [<Producer>,]
def __init__(self): self.topics = defaultdict(list) @@ -170,9 +170,11 @@ class CentralMokshaHub(MokshaHub): self.__init_amqp()
self.__run_consumers() - self.__init_data_streams() + self.__init_producers()
def __init_amqp(self): + # Ok this looks odd at first. I think this is only used when we are briding stomp/amqp, + # Since each producer and consumer opens up their own AMQP connections anyway if self.stomp_broker: log.debug("Initializing local AMQP queue...") self.server_queue_name = 'moksha_hub_' + self.session.name @@ -187,7 +189,7 @@ class CentralMokshaHub(MokshaHub):
def __init_consumers(self): """ Initialize all Moksha Consumer objects """ - log.info('Loading Moksha Consumers') + log.info('Loading Consumers') for consumer in pkg_resources.iter_entry_points('moksha.consumer'): c_class = consumer.load() log.info("%s consumer is watching the %r topic" % ( @@ -203,15 +205,16 @@ class CentralMokshaHub(MokshaHub): self.consumers.append(c) self.topics[topic][i] = c.consume
- def __init_data_streams(self): - """ Initialize all data streams """ - self.data_streams = [] + def __init_producers(self): + """ Initialize all producers (aka data streams) """ + log.info('Loading Producers') + self.producers = [] for entry in ('moksha.producer', 'moksha.stream'): - for stream in pkg_resources.iter_entry_points(entry): - stream_class = stream.load() - log.info('Loading %s producer' % stream_class.__name__) - stream_obj = stream_class() - self.data_streams.append(stream_obj) + for producer in pkg_resources.iter_entry_points(entry): + producer_class = producer.load() + log.info('Loading %s producer' % producer_class.__name__) + producer_obj = producer_class() + self.producers.append(producer_obj)
@trace def create_topic(self, topic): @@ -225,10 +228,10 @@ class CentralMokshaHub(MokshaHub): def stop(self): log.debug("Stopping the CentralMokshaHub") MokshaHub.close(self) - if self.data_streams: - for stream in self.data_streams: - log.debug("Stopping data stream %s" % stream) - stream.stop() + if self.producers: + for producer in self.producers: + log.debug("Stopping producer %s" % producer) + producer.stop() if self.consumers: for consumer in self.consumers: log.debug("Stopping consumer %s" % consumer)
commit d842655d335dd690e6ba954a8e17e65a9824ce99 Author: Luke Macken lmacken@redhat.com Date: Sun Jan 16 21:56:06 2011 -0500
Get rid of moksha.streams
diff --git a/moksha/streams/__init__.py b/moksha/streams/__init__.py deleted file mode 100644 index e69de29..0000000
commit 0ea2e2c3d207837cc894996fefdc7ba9cf6cdb2e Author: Luke Macken lmacken@redhat.com Date: Sat Jan 15 15:12:25 2011 -0500
Commit our db changes in our HelloWorld Consumer every 100 entries.
diff --git a/moksha/apps/helloworld/demo/consumer.py b/moksha/apps/helloworld/demo/consumer.py index 10f4e3b..dec4cfd 100644 --- a/moksha/apps/helloworld/demo/consumer.py +++ b/moksha/apps/helloworld/demo/consumer.py @@ -4,6 +4,7 @@ from demo.model import HelloWorldModel class HelloWorldConsumer(Consumer): topic = 'helloworld' app = 'helloworld' + i = 0
def consume(self, message): self.log.info('Received message: ' + message['body']['msg']) @@ -11,4 +12,8 @@ class HelloWorldConsumer(Consumer): entry = HelloWorldModel() entry.message = message['body']['msg'] self.DBSession.add(entry) - self.DBSession.commit() + + self.i += 1 + if self.i % 100 == 0: + self.DBSession.commit() +
moksha-commits@lists.fedorahosted.org