docs/main
by Luke Macken
docs/main/Features.rst | 2 +-
docs/main/IntegratingWithTG2.rst | 6 +++---
docs/main/Messaging.rst | 2 +-
docs/main/Producers.rst | 8 ++++----
docs/main/QuickstartTemplates.rst | 4 ++--
docs/main/Technology.rst | 2 +-
docs/main/Topics.rst | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
New commits:
commit 25c21ba4c6098b77bba2ec038731e6ea42bde307
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:54:16 2009 -0500
More s/datastream/producer/g doc changes
diff --git a/docs/main/Features.rst b/docs/main/Features.rst
index 2009781..38d77f6 100644
--- a/docs/main/Features.rst
+++ b/docs/main/Features.rst
@@ -88,7 +88,7 @@ process incoming data. One could then easily build state-machines, inference
engines, or even forward/backward-chaning rule-driven expert systems.
Moksha also provides a simple yet powerful API for creating
-:doc:`DataStreamers` that can do basically anything at anytime. It allows for
+:doc:`Producers` that can do basically anything at anytime. It allows for
the easy scripting of periodic tasks such as fetching data, polling resources,
warming caches, sending notifications, analyzing databases, etc. For example,
Moksha provides a :doc:`FeedStream`, that automatically handles fetching,
diff --git a/docs/main/IntegratingWithTG2.rst b/docs/main/IntegratingWithTG2.rst
index 8d394f1..b7c0d30 100644
--- a/docs/main/IntegratingWithTG2.rst
+++ b/docs/main/IntegratingWithTG2.rst
@@ -111,12 +111,12 @@ that your global resources are always injected.
</body>
</html>
-Create the Moksha Data Stream
------------------------------
+Create the Moksha Data Producer
+-------------------------------
In the original example, the JQPlotWidget would query a controller every 2
seconds, which returns JSON data. Since Moksha is event driven, we will create
-a Moksha :doc:`DataStreams` that will wake up every 2 seconds and send new data
+a Moksha :doc:`Producers` that will wake up every 2 seconds and send new data
to the message bus for a couple of given :doc:`Topics`. This makes it so our widgets
can simply subscribe to their corresponding topics, and patiently wait for new
data to arrive.
diff --git a/docs/main/Messaging.rst b/docs/main/Messaging.rst
index 2eefda8..2128ed7 100644
--- a/docs/main/Messaging.rst
+++ b/docs/main/Messaging.rst
@@ -6,7 +6,7 @@ Messaging
Topics
Consumers
- DataStreams
+ Producers
LiveWidget
MokshaHub
MessageBrokers
diff --git a/docs/main/Producers.rst b/docs/main/Producers.rst
index e02bbdc..a12b7df 100644
--- a/docs/main/Producers.rst
+++ b/docs/main/Producers.rst
@@ -10,8 +10,8 @@ The Producers contain a connection to the MokshaHub via the `self.hub` object.
It also provides a `send_message(topic, message)` method that will send your
message to the hub.
-Polling Data Streams
---------------------
+Polling Producers
+------------------
The :class:`PollingProducer` will automatically wake up at a given `frequency`
(which can be a `datetime.timedelta` object, or the number of a seconds), and
@@ -34,10 +34,10 @@ seconds, and sends a 'Hello World!' message to the 'hello' `topic`.
Installing
----------
-To install your `Producer`, simply add it to the `[moksha.stream]` entry-point
+To install your `Producer`, simply add it to the `[moksha.producer]` entry-point
in your `setup.py`, like so:
.. code-block:: python
[moksha.producer]
- hello = myproject.streams.hello:HelloWorldProducer
+ hello = myproject.producers:HelloWorldProducer
diff --git a/docs/main/QuickstartTemplates.rst b/docs/main/QuickstartTemplates.rst
index 752a82b..9d9ac11 100644
--- a/docs/main/QuickstartTemplates.rst
+++ b/docs/main/QuickstartTemplates.rst
@@ -17,7 +17,7 @@ Moksha provides templates for easily creating basic components.
-c, --connector Create an example Moksha Connector
-u, --consumer Create an example Moksha Consumer
-C, --controller Create an example Moksha Controller
- -s, --stream Create an example Moksha DataStream
+ -P, --producer Create an example Moksha Producer
-p PACKAGE, --package=PACKAGE
package name for the code
-t TOPIC, --topic=TOPIC
@@ -34,7 +34,7 @@ Creating a new moksha app with all components
.. code-block:: bash
- $ paster moksha --livewidget --stream --consumer --controller
+ $ paster moksha --livewidget --producer --consumer --controller
Creating and installing an RPM for your new package
diff --git a/docs/main/Technology.rst b/docs/main/Technology.rst
index 0af4eaa..3755966 100644
--- a/docs/main/Technology.rst
+++ b/docs/main/Technology.rst
@@ -76,4 +76,4 @@ receives, stores, and routes messages using the AMQP protocol.
`Twisted <http://twistedmatrix.com>`_
-------------------------------------
-Twisted is an event-driven networking engine written in Python. It is the core engine for the :doc:`MokshaHub`, which reacts to incoming messages, as well as runs our :doc:`DataStreams`.
+Twisted is an event-driven networking engine written in Python. It is the core engine for the :doc:`MokshaHub`, which reacts to incoming messages, as well as runs our :doc:`Producers`.
diff --git a/docs/main/Topics.rst b/docs/main/Topics.rst
index b93e507..4d8f4bf 100644
--- a/docs/main/Topics.rst
+++ b/docs/main/Topics.rst
@@ -11,4 +11,4 @@ potentially be represented by a STOMP destination, or even an AMQP message
queue. These messaging backends can be swapped out and configured without
having to alter the applications that care about those `topics`.
-For details on how to interact with topics, see the documentation on :doc:`Consumers`, :doc:`DataStreams`, and :doc:`MokshaHub`.
+For details on how to interact with topics, see the documentation on :doc:`Consumers`, :doc:`Producers`, and :doc:`MokshaHub`.
14 years, 6 months
docs/main docs/_static
by Luke Macken
docs/_static/live_widget_interaction.png |binary
docs/_static/live_widgets.png |binary
docs/_static/widget.png |binary
docs/main/LiveWidget.rst | 8 ++++++++
docs/main/Widgets.rst | 16 +++++++++++++---
5 files changed, 21 insertions(+), 3 deletions(-)
New commits:
commit f431f9d76303b67c752f3c242017c0a2e01daab9
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:39:59 2009 -0500
Add widget diagrams and reorganize our widget docs
diff --git a/docs/_static/live_widget_interaction.png b/docs/_static/live_widget_interaction.png
new file mode 100644
index 0000000..9a15a3b
Binary files /dev/null and b/docs/_static/live_widget_interaction.png differ
diff --git a/docs/_static/live_widgets.png b/docs/_static/live_widgets.png
new file mode 100644
index 0000000..f3d0132
Binary files /dev/null and b/docs/_static/live_widgets.png differ
diff --git a/docs/_static/widget.png b/docs/_static/widget.png
new file mode 100644
index 0000000..520b898
Binary files /dev/null and b/docs/_static/widget.png differ
diff --git a/docs/main/LiveWidget.rst b/docs/main/LiveWidget.rst
index f1d9709..6caae06 100644
--- a/docs/main/LiveWidget.rst
+++ b/docs/main/LiveWidget.rst
@@ -7,6 +7,8 @@ your widget to a given message `topic`, or list of topics. When the widget
receives a new message, the `onmessage` JavaScript callback will be run by the
client with JSON data in the `json` variable.
+.. image:: ../_static/live_widgets.png
+
A basic LiveWidget
------------------
@@ -68,3 +70,9 @@ uses a little bit of jQuery to add and remove feed entries from a list.
});
"""
feed = Feed()
+
+Live Widget Interaction
+-----------------------
+
+.. image:: ../_static/live_widget_interaction.png
+
diff --git a/docs/main/Widgets.rst b/docs/main/Widgets.rst
index ece86be..75ec236 100644
--- a/docs/main/Widgets.rst
+++ b/docs/main/Widgets.rst
@@ -7,9 +7,10 @@ integrated into TurboGears2, and thus Moksha, out of the box. Along with their
official documentation, you can also find great ToscaWidgets tutorials in the
`TurboGears2 <http://www.turbogears.org/2.0/docs/toc.html>`_ docs.
- * `ToscaWidgets <http://toscawidgets.org>`_
- * `Writing Widget Demos <http://toscawidgets.org/documentation/WidgetBrowser>`_
- * `TurboGears2 Documentation <http://www.turbogears.org/2.0/docs/toc.html>`_
+.. image:: ../_static/widget.png
+
+Moksha Widget Docs
+------------------
.. toctree::
@@ -19,6 +20,15 @@ official documentation, you can also find great ToscaWidgets tutorials in the
LiveWidget
MokshaContainerWidgets
+
.. seealso::
:doc:`MokshaLabs`
+
+External Documentation
+----------------------
+* `ToscaWidgets <http://toscawidgets.org>`_
+* `Writing Widget Demos <http://toscawidgets.org/documentation/WidgetBrowser>`_
+* `TurboGears2 Documentation <http://www.turbogears.org/2.0/docs/toc.html>`_
+
+
14 years, 6 months
3 commits - docs/main docs/_static
by Luke Macken
docs/_static/moksha-hub.png |binary
docs/main/DataStreams.rst | 39 ---------------------------------------
docs/main/MokshaHub.rst | 9 +++++----
docs/main/Producers.rst | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 43 deletions(-)
New commits:
commit f8fd9d896f19bcfd3532aaacf6cf295314ae6d5f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:29:56 2009 -0500
More improvements to the hub docs
diff --git a/docs/main/MokshaHub.rst b/docs/main/MokshaHub.rst
index 8f14056..1886cb3 100644
--- a/docs/main/MokshaHub.rst
+++ b/docs/main/MokshaHub.rst
@@ -27,11 +27,11 @@ CentralMokshaHub
The :class:`CentralMokshaHub` is the primary consumer of all message `topics`.
It runs outside of the Moksha WSGI application stack, and is automatically
-started by the `start-moksha` script.
+started by the `start-moksha` script (and can be started manually by running `moksha-hub`.
The :class:`CentralMokshaHub` currently handles the following tasks:
-* Feeds `Consumers` new messages for specific topics
+* Feeds :doc:`Consumers` new messages for specific topics
* Runs all of the :doc:`Producers`
.. image:: ../_static/moksha-hub.png
commit c90c2198874a9b91e7efebd1b540e27df0e7ed49
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:24:16 2009 -0500
Rename our DataStream docs to Producer docs
diff --git a/docs/main/Producers.rst b/docs/main/Producers.rst
index f0a24fa..e02bbdc 100644
--- a/docs/main/Producers.rst
+++ b/docs/main/Producers.rst
@@ -1,27 +1,31 @@
-============
-Data Streams
-============
+=========
+Producers
+=========
-Moksha offers a :class:`DataStream` API that allows you to easily provide
-data to your message brokers. DataStreams are loaded and run by the :class:`MokshaHub`, isolated from the WSGI application.
+Moksha offers a :class:`Producer` API that allows you to easily provide data to
+your message brokers. Producers are loaded and run by the :class:`MokshaHub`,
+isolated from the WSGI application.
-The DataStreams contain a connection to the MokshaHub via the `self.hub`
-object. It also provides a `send_message(topic, message)` method that will
-send your message to the hub.
+The Producers contain a connection to the MokshaHub via the `self.hub` object.
+It also provides a `send_message(topic, message)` method that will send your
+message to the hub.
Polling Data Streams
--------------------
-The :class:`PollingDataStream` will automatically wake up at a given `frequency` (which can be a `datetime.timedelta` object, or the number of a seconds), and call the :meth:`poll` method.
+The :class:`PollingProducer` will automatically wake up at a given `frequency`
+(which can be a `datetime.timedelta` object, or the number of a seconds), and
+call the :meth:`poll` method.
-Below is an example of a :class:`PollingDataStream` that wakes up every 10 seconds, and sends a 'Hello World!' message to the 'hello' `topic`.
+Below is an example of a :class:`PollingProducer` that wakes up every 10
+seconds, and sends a 'Hello World!' message to the 'hello' `topic`.
.. code-block:: python
from datetime import timedelta
- from moksha.api.streams import PollingDataStream
+ from moksha.api.hub.producer import PollingProducer
- class HelloWorldDataStream(PollingDataStream):
+ class HelloWorldProducer(PollingProducer):
frequency = timedelta(seconds=10)
def poll(self):
@@ -30,10 +34,10 @@ Below is an example of a :class:`PollingDataStream` that wakes up every 10 secon
Installing
----------
-To install your `DataStream`, simply add it to the `[moksha.stream]` entry-point
+To install your `Producer`, simply add it to the `[moksha.stream]` entry-point
in your `setup.py`, like so:
.. code-block:: python
- [moksha.stream]
- hello = myproject.streams.hello:HelloWorldDataStream
+ [moksha.producer]
+ hello = myproject.streams.hello:HelloWorldProducer
commit d06e1fb3a27617f752fad8cc7445ad4dfa0ab034
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:23:40 2009 -0500
Update our MokshaHub docs, and add a diagram
diff --git a/docs/_static/moksha-hub.png b/docs/_static/moksha-hub.png
new file mode 100644
index 0000000..a98299f
Binary files /dev/null and b/docs/_static/moksha-hub.png differ
diff --git a/docs/main/DataStreams.rst b/docs/main/DataStreams.rst
deleted file mode 100644
index f0a24fa..0000000
--- a/docs/main/DataStreams.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-============
-Data Streams
-============
-
-Moksha offers a :class:`DataStream` API that allows you to easily provide
-data to your message brokers. DataStreams are loaded and run by the :class:`MokshaHub`, isolated from the WSGI application.
-
-The DataStreams contain a connection to the MokshaHub via the `self.hub`
-object. It also provides a `send_message(topic, message)` method that will
-send your message to the hub.
-
-Polling Data Streams
---------------------
-
-The :class:`PollingDataStream` will automatically wake up at a given `frequency` (which can be a `datetime.timedelta` object, or the number of a seconds), and call the :meth:`poll` method.
-
-Below is an example of a :class:`PollingDataStream` that wakes up every 10 seconds, and sends a 'Hello World!' message to the 'hello' `topic`.
-
-.. code-block:: python
-
- from datetime import timedelta
- from moksha.api.streams import PollingDataStream
-
- class HelloWorldDataStream(PollingDataStream):
- frequency = timedelta(seconds=10)
-
- def poll(self):
- self.send_message('hello', 'Hello World!')
-
-Installing
-----------
-
-To install your `DataStream`, simply add it to the `[moksha.stream]` entry-point
-in your `setup.py`, like so:
-
-.. code-block:: python
-
- [moksha.stream]
- hello = myproject.streams.hello:HelloWorldDataStream
diff --git a/docs/main/MokshaHub.rst b/docs/main/MokshaHub.rst
index e9f2a0c..8f14056 100644
--- a/docs/main/MokshaHub.rst
+++ b/docs/main/MokshaHub.rst
@@ -31,6 +31,7 @@ started by the `start-moksha` script.
The :class:`CentralMokshaHub` currently handles the following tasks:
-* Consumes all messages from STOMP and AMQP brokers
* Feeds `Consumers` new messages for specific topics
-* Runs all of the `DataStreams`
+* Runs all of the :doc:`Producers`
+
+.. image:: ../_static/moksha-hub.png
diff --git a/docs/main/Producers.rst b/docs/main/Producers.rst
new file mode 100644
index 0000000..f0a24fa
--- /dev/null
+++ b/docs/main/Producers.rst
@@ -0,0 +1,39 @@
+============
+Data Streams
+============
+
+Moksha offers a :class:`DataStream` API that allows you to easily provide
+data to your message brokers. DataStreams are loaded and run by the :class:`MokshaHub`, isolated from the WSGI application.
+
+The DataStreams contain a connection to the MokshaHub via the `self.hub`
+object. It also provides a `send_message(topic, message)` method that will
+send your message to the hub.
+
+Polling Data Streams
+--------------------
+
+The :class:`PollingDataStream` will automatically wake up at a given `frequency` (which can be a `datetime.timedelta` object, or the number of a seconds), and call the :meth:`poll` method.
+
+Below is an example of a :class:`PollingDataStream` that wakes up every 10 seconds, and sends a 'Hello World!' message to the 'hello' `topic`.
+
+.. code-block:: python
+
+ from datetime import timedelta
+ from moksha.api.streams import PollingDataStream
+
+ class HelloWorldDataStream(PollingDataStream):
+ frequency = timedelta(seconds=10)
+
+ def poll(self):
+ self.send_message('hello', 'Hello World!')
+
+Installing
+----------
+
+To install your `DataStream`, simply add it to the `[moksha.stream]` entry-point
+in your `setup.py`, like so:
+
+.. code-block:: python
+
+ [moksha.stream]
+ hello = myproject.streams.hello:HelloWorldDataStream
14 years, 6 months
6 commits - docs/main docs/_static moksha/apps moksha/tests pavement.py
by Luke Macken
docs/_static/moksha-messaging-amqp.png |binary
docs/_static/moksha-messaging-stomp-amqp.png |binary
docs/_static/moksha-messaging-stomp.png |binary
docs/_static/moksha-middleware.png |binary
docs/main/Messaging.rst | 1
docs/main/MessagingScenarios.rst | 29 +
docs/main/Middleware.rst | 25 -
moksha/apps/knowledge/moksha/apps/knowledge/controllers/root.py | 99 ++++
moksha/apps/knowledge/moksha/apps/knowledge/model/model.py | 87 +++-
moksha/apps/knowledge/pavement.py | 32 +
moksha/apps/knowledge/pavement.py.hide | 34 -
moksha/tests/models/test_entity.py | 205 +++++-----
pavement.py | 2
13 files changed, 338 insertions(+), 176 deletions(-)
New commits:
commit 4374a4ec573f543efca6f2106b7111e5cdebb840
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:16:37 2009 -0500
Update our middleware documentation
diff --git a/docs/main/Middleware.rst b/docs/main/Middleware.rst
index be9c7da..65cce68 100644
--- a/docs/main/Middleware.rst
+++ b/docs/main/Middleware.rst
@@ -12,10 +12,10 @@ It currently provides the following functionality
* Handles dispatching moksha applications, which can be any WSGI app or Controller.
* Handles dispatching to individual widgets, which are simply `ToscaWidgets <http://toscawidgets.org>`_
* Sets up `SQLAlchemy` database engines for each application
- * Initializes applications data models
* Loads all application configuration
+ * Initializes the :doc:`LiveWidget` callback registry
+ * Initializes applications data models
* Sets up the moksha resource connectors
- * Sets up the stomp callback registry
Using the MokshaMiddleware
--------------------------
@@ -53,23 +53,4 @@ Not only can Moksha be inserted into any existing `WSGI <http://wsgi.org>`_-comp
but on it's own offers a comprehensive top-to-bottom middleware stack that
provides a vast plethora of additional functionality.
-=============================== ===============
-Middleware Function Module
-=============================== ===============
-Profiling repoze.profile
-Resource compression repoze.squeeze
- **TG2 Middleware**
----------------------------------------------------
-Application routing/dispatching Routes
-Session management Beaker
-Caching layer Beaker
-Widget resource injection ToscaWidgets
-Authentication repoze.who
-Authorization repoze.what
-Transaction management repoze.tm2
-Error handling & Debugging WebError
-Registry manager Paste
- **Moksha Middleware**
----------------------------------------------------
-Your application
-=============================== ===============
+.. image:: ../_static/moksha-middleware.png
commit 4a0e49c4b7c3da8ee1caea41e2c3c5ec3740fe2c
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Dec 16 21:15:43 2009 -0500
Add documentation on different messaging scenarios
diff --git a/docs/_static/moksha-messaging-amqp.png b/docs/_static/moksha-messaging-amqp.png
new file mode 100644
index 0000000..e54275f
Binary files /dev/null and b/docs/_static/moksha-messaging-amqp.png differ
diff --git a/docs/_static/moksha-messaging-stomp-amqp.png b/docs/_static/moksha-messaging-stomp-amqp.png
new file mode 100644
index 0000000..3070d63
Binary files /dev/null and b/docs/_static/moksha-messaging-stomp-amqp.png differ
diff --git a/docs/_static/moksha-messaging-stomp.png b/docs/_static/moksha-messaging-stomp.png
new file mode 100644
index 0000000..bba1d70
Binary files /dev/null and b/docs/_static/moksha-messaging-stomp.png differ
diff --git a/docs/_static/moksha-middleware.png b/docs/_static/moksha-middleware.png
new file mode 100644
index 0000000..704add4
Binary files /dev/null and b/docs/_static/moksha-middleware.png differ
diff --git a/docs/main/Messaging.rst b/docs/main/Messaging.rst
index f2b29a1..2eefda8 100644
--- a/docs/main/Messaging.rst
+++ b/docs/main/Messaging.rst
@@ -10,3 +10,4 @@ Messaging
LiveWidget
MokshaHub
MessageBrokers
+ MessagingScenarios
diff --git a/docs/main/MessagingScenarios.rst b/docs/main/MessagingScenarios.rst
new file mode 100644
index 0000000..6719906
--- /dev/null
+++ b/docs/main/MessagingScenarios.rst
@@ -0,0 +1,29 @@
+Messaging Scenarios
+===================
+
+.. image:: ../_static/moksha-messaging-stomp.png
+
+Pros:
+ - No configuration needed
+ - Works out-of-the-box
+Cons:
+ - Not designed for scalability
+ - No wildcard topic names
+
+.. image:: ../_static/moksha-messaging-stomp-amqp.png
+
+
+Pros
+ - STOMP/AMQP broker briding
+Cons
+ - Not very well tested
+ - May or may not work as expected
+
+.. image:: ../_static/moksha-messaging-amqp.png
+
+Pros:
+ - Trivial to configure
+ - 100% AMQP, from the browser to the broker
+ - Flexibility and power of AMQP queues, exchanges, routing keys, etc.
+Cons:
+ - Relatively new and not 100% complete JavaScript bindings
commit 08b7bc55d709f35d1642437d72824ec2a70a8bb0
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Dec 15 21:03:17 2009 -0500
Add a couple more unit tests for our knowledge app
diff --git a/moksha/tests/models/test_entity.py b/moksha/tests/models/test_entity.py
index b37eb21..ed1a898 100644
--- a/moksha/tests/models/test_entity.py
+++ b/moksha/tests/models/test_entity.py
@@ -37,6 +37,7 @@ class TestEntity(ModelTest):
self.obj[u'age'] = 24
self.obj[u'dob'] = datetime(1984, 11, 02)
self.obj[u'l33t'] = True
+ self.obj[u'json'] = {'foo':'bar'}
def test_entity_creation_name(self):
eq_(self.obj.name, u'lmacken')
@@ -84,6 +85,19 @@ class TestEntity(ModelTest):
assert (DBSession.query(Fact).
filter(with_characteristic(u'l33t', True))).one()
+ def test_child_entities(self):
+ child = Entity(u'child1')
+ DBSession.add(child)
+ self.obj.append(child)
+ DBSession.flush()
+ me = Entity.by_name(u'lmacken')
+ assert_true('child1' in me.children)
+ eq_(self.obj.children['child1'].parent, me)
+
+ def test_entity_json_fact(self):
+ me = Entity.by_name(u'lmacken')
+ eq_(me[u'json'], {'foo': 'bar'})
+
"""
TODO: add hooks that send AMQP messages?
Or, do this i
commit ea59a3ad9b50bea9d2d0a305c9a7b269de76d18c
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Dec 15 21:02:06 2009 -0500
Entity/fact model tweaks, and allow us to create Entities w/o any args for sprox
diff --git a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
index 1a7d0ee..d2ed245 100644
--- a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
+++ b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
@@ -84,14 +84,14 @@ class Entity(VerticalPropertyDictMixin, DeclarativeBase):
_property_type = Fact
_property_mapping = 'facts'
- #id = Column(Integer, autoincrement=True, primary_key=True)
- name = Column(UnicodeText)
+ id = Column(Integer, autoincrement=True, primary_key=True)
+ name = Column(UnicodeText, nullable=False)
facts = relation(Fact, backref='entity',
collection_class=attribute_mapped_collection('key'))
# Adjacency tree properties
- id = Column(Integer, Sequence('moksha_tree_id_seq', optional=True), primary_key=True)
+ #id = Column(Integer, Sequence('moksha_tree_id_seq', optional=True), primary_key=True)
parent_id = Column(Integer, ForeignKey('moksha_entities.id'), nullable=True)
children = relation('Entity', cascade="all",
@@ -99,7 +99,7 @@ class Entity(VerticalPropertyDictMixin, DeclarativeBase):
collection_class=attribute_mapped_collection('name'),
lazy=False, join_depth=3)
- def __init__(self, name):
+ def __init__(self, name=None):
self.name = name
@classmethod
diff --git a/moksha/apps/knowledge/pavement.py b/moksha/apps/knowledge/pavement.py
index e4b20dc..8bb2d45 100644
--- a/moksha/apps/knowledge/pavement.py
+++ b/moksha/apps/knowledge/pavement.py
@@ -22,13 +22,11 @@ options(
namespace_packages=[
'moksha',
'moksha.apps',
-
],
install_requires=["Moksha"],
- entry_points={
- 'moksha.application': (
- 'moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController'
- ),
- }
+ entry_points="""
+ [moksha.application]
+ moksha.apps.knowledge = moksha.apps.knowledge.controllers.root:RootController
+ """,
),
)
commit e08ed309917f6facefc0c5443c6ed6c053f59117
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Dec 15 21:01:13 2009 -0500
Initial attempt at using the CrudRestController & sprox for our entity/fact model
diff --git a/moksha/apps/knowledge/moksha/apps/knowledge/controllers/root.py b/moksha/apps/knowledge/moksha/apps/knowledge/controllers/root.py
index 1fd2644..22924ad 100644
--- a/moksha/apps/knowledge/moksha/apps/knowledge/controllers/root.py
+++ b/moksha/apps/knowledge/moksha/apps/knowledge/controllers/root.py
@@ -4,14 +4,109 @@
from tg import expose, flash, require, url, request, redirect
from pylons.i18n import ugettext as _, lazy_ugettext as l_
from sqlalchemy import or_
+from tgext.crud import CrudRestController
+from sprox.tablebase import TableBase
+from sprox.fillerbase import TableFiller, EditFormFiller
+from sprox.formbase import AddRecordForm, EditableForm
+from tw.core import WidgetsList
+from tw.forms import TableForm, TextField, CalendarDatePicker, SingleSelectField, TextArea
+from formencode.validators import Int, NotEmpty, DateConverter, DateValidator
+from repoze.what.predicates import has_permission
+from moksha import model
+#from moksha.model import DBSession, metadata
from moksha.lib.base import Controller
from moksha.lib.helpers import defaultdict
-
-#from moksha.model import DBSession
from moksha.apps.knowledge.model import Fact, Entity, with_characteristic, DBSession
+#class EntityForm(TableForm):
+# class fields(WidgetsList):
+# name = TextField(validator=NotEmpty)
+ #description = TextArea(attrs=dict(rows=3, cols=25))
+ #release_date = CalendarDatePicker(validator=DateConverter())
+ #genrechoices = ((1,"action"),
+ # (2,"animation"),
+ # (3,"comedy"),
+ # (4,"documentary"),
+ # (5,"drama"),
+ # (6,"sci-fi"))
+ #genre = SingleSelectField(options=genrechoices)
+
+#then, we create an instance of this form
+#movie_add_form = MovieForm("create_movie_form")
+#
+#
+
+class EntityTable(TableBase):
+ __model__ = Entity
+entity_table = EntityTable(DBSession)
+
+class EntityTableFiller(TableFiller):
+ __model__ = Entity
+entity_table_filler = EntityTableFiller(DBSession)
+
+class EntityAddForm(AddRecordForm):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id', 'facts', 'children']
+entity_add_form = EntityAddForm(DBSession)
+
+class EntityController(CrudRestController):
+ requires = has_permission('manager')
+
+ model = Entity
+ #table = entity_table
+ #table_filler = entity_table_filler
+ #new_form = entity_add_form
+
+ @expose('mako:moksha.apps.knowledge.templates.get_all')
+ def get_all(self, *args, **kw):
+ return super(EntityController, self).get_all(*args, **kw)
+
+ @expose('mako:moksha.apps.knowledge.templates.new')
+ def new(self, *args, **kw):
+ return super(EntityController, self).new(*args, **kw)
+
+ @expose('mako:moksha.apps.knowledge.templates.edit')
+ def edit(self, *args, **kw):
+ return super(EntityController, self).edit(*args, **kw)
+
+ #@expose()
+ #def post(self, **kw):
+ # print "EntityController.post(%s)" % locals()
+ # return super(EntityController, self).post(**kw)
+
+ class new_form_type(AddRecordForm):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id']
+
+ class edit_form_type(EditableForm):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id']
+
+ class edit_filler_type(EditFormFiller):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id']
+
+ class table_type(TableBase):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id']
+
+ class table_filler_type(TableFiller):
+ __model__ = Entity
+ __omit_fields__ = ['id', 'parent_id']
+ __xml_fields__ = ['children', 'facts']
+
+ def children(self, entity):
+ return ', '.join([child.name for child in entity.children])
+
+ def facts(self, entity, *args, **kw):
+ #print "facts(%s)"% locals()
+ for fact in entity.facts:
+ print fact
+ return entity.name
+
class RootController(Controller):
+ entities = EntityController(DBSession)
@expose('json')
def index(self):
commit 19bcb72156ea8b3d4d9ffd717f149b0f3bc93525
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Dec 15 00:56:12 2009 -0500
Make our polymoprhic vertical model also an adjacency tree.
Also, re-enable the Fact/Entity test cases
diff --git a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
index bf84685..1a7d0ee 100644
--- a/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
+++ b/moksha/apps/knowledge/moksha/apps/knowledge/model/model.py
@@ -1,37 +1,45 @@
+# -*- coding: utf-8 -*-
# This file is part of Moksha.
-# Copyright (C) 2008-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.
+# Moksha is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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,
+# Moksha 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.
+# GNU 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/>.
+# You should have received a copy of the GNU General Public License
+# along with Moksha. If not, see <http://www.gnu.org/licenses/>.
#
-# Authors: Luke Macken <lmacken(a)redhat.com>
+# Copyright 2008-2009, Red Hat, Inc.
+"""
+:mod:`moksha.apps.knowledge.model` -- The Moksha Polymorphic Vertical Adjacency Tree Model
+==========================================================================================
+
+.. moduleauthor:: Luke Macken <lmacken(a)redhat.com>
+"""
+
+from sqlalchemy import *
+from sqlalchemy.orm import *
+from sqlalchemy.orm.collections import attribute_mapped_collection
from datetime import datetime
from sqlalchemy import *
from sqlalchemy.orm import relation, comparable_property
from sqlalchemy.orm.collections import attribute_mapped_collection
-from moksha.model.hook import MokshaHookMapperExtension
-from moksha.model import metadata, DBSession, DeclarativeBase
from vertical import PolymorphicVerticalProperty, VerticalPropertyDictMixin
-moksha_mapper_extension = MokshaHookMapperExtension()
+from moksha.model import metadata, DeclarativeBase, DBSession
+
class Fact(PolymorphicVerticalProperty, DeclarativeBase):
""" A polymorphic-valued vertical table property """
- __tablename__ = 'facts'
- #__mapper_args__ = {'extension': moksha_mapper_extension}
+ __tablename__ = 'moksha_facts'
- id = Column(Integer, ForeignKey('entities.id'), primary_key=True)
+ id = Column(Integer, ForeignKey('moksha_entities.id'), primary_key=True)
key = Column(Unicode(64), primary_key=True)
type_ = Column(Unicode(16), default=None)
int_value = Column(Integer, default=None)
@@ -59,7 +67,7 @@ with_characteristic = lambda key, value: and_(Fact.key==key, Fact.value==value)
class Entity(VerticalPropertyDictMixin, DeclarativeBase):
- """ An entity.
+ """ An polymorphic entity.
Entity facts are available via the 'facts' property or by using
dict-like accessors on an Entity instance::
@@ -68,24 +76,32 @@ class Entity(VerticalPropertyDictMixin, DeclarativeBase):
apple['color'] = 'red'
# or, equivalently:
apple.facts['color'] = Fact('color', 'red')
+
+ This Entity is also an adjacency tree. Meaning, every entity
+ can have a `parent` and zero or more `children`.
"""
- __tablename__ = 'entities'
- #__mapper_args__ = {'extension': moksha_mapper_extension}
+ __tablename__ = 'moksha_entities'
_property_type = Fact
_property_mapping = 'facts'
- id = Column(Integer, autoincrement=True, primary_key=True)
- name = Column(Unicode(100))
+ #id = Column(Integer, autoincrement=True, primary_key=True)
+ name = Column(UnicodeText)
facts = relation(Fact, backref='entity',
collection_class=attribute_mapped_collection('key'))
+ # Adjacency tree properties
+ id = Column(Integer, Sequence('moksha_tree_id_seq', optional=True), primary_key=True)
+ parent_id = Column(Integer, ForeignKey('moksha_entities.id'), nullable=True)
+
+ children = relation('Entity', cascade="all",
+ backref=backref("parent", remote_side="Entity.id"),
+ collection_class=attribute_mapped_collection('name'),
+ lazy=False, join_depth=3)
+
def __init__(self, name):
self.name = name
- def __repr__(self):
- return '<%s %r>' % (self.__class__.__name__, self.name)
-
@classmethod
def by_name(cls, name):
"""A class method that permits to search entities
@@ -93,3 +109,26 @@ class Entity(VerticalPropertyDictMixin, DeclarativeBase):
"""
return DBSession.query(cls).filter(cls.name==name).first()
+ # Adjacency-tree methods
+ def append(self, node):
+ if isinstance(node, basestring):
+ node = Entity(node)
+ node.parent = self
+ self.children[node.name] = node
+
+ def __repr__(self):
+ return self._getstring(0, False)
+
+ def __str__(self):
+ return self._getstring(0, False)
+
+ def _getstring(self, level, expand = False):
+ s = (' ' * level) + "%s (%s,%s, %d)" % (
+ self.name, self.id,self.parent_id,id(self)) + '\n'
+ if expand:
+ s += ''.join([n._getstring(level+1, True)
+ for n in self.children.values()])
+ return s
+
+ def print_nodes(self):
+ return self._getstring(0, True)
diff --git a/moksha/apps/knowledge/pavement.py b/moksha/apps/knowledge/pavement.py
new file mode 100644
index 0000000..e4b20dc
--- /dev/null
+++ b/moksha/apps/knowledge/pavement.py
@@ -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'
+ ),
+ }
+ ),
+)
diff --git a/moksha/apps/knowledge/pavement.py.hide b/moksha/apps/knowledge/pavement.py.hide
deleted file mode 100644
index e4b20dc..0000000
--- a/moksha/apps/knowledge/pavement.py.hide
+++ /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/tests/models/test_entity.py b/moksha/tests/models/test_entity.py
index 751be65..b37eb21 100644
--- a/moksha/tests/models/test_entity.py
+++ b/moksha/tests/models/test_entity.py
@@ -1,107 +1,110 @@
+# -*- coding: utf-8 -*-
# This file is part of Moksha.
# Copyright (C) 2008-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/>.
-# -*- coding: utf-8 -*-
-#"""Test Moksha's Entity/Fact model"""
-#
-#from datetime import datetime
-#from nose.tools import eq_, assert_true
-#from sqlalchemy import *
-#from moksha.model import DBSession, Entity, Fact, with_characteristic
-#from moksha.tests.models import ModelTest
-
-#class TestEntity(ModelTest):
-# """Test case for the Entity model."""
-#
-# klass = Entity
-# attrs = dict(name=u'lmacken')
-#
-# def setup(self):
-# super(TestEntity, self).setup()
-# self.obj[u'firstname'] = u'Luke'
-# self.obj[u'lastname'] = u'Macken'
-# self.obj[u'age'] = 24
-# self.obj[u'dob'] = datetime(1984, 11, 02)
-# self.obj[u'l33t'] = True
-#
-# def test_entity_creation_name(self):
-# eq_(self.obj.name, u'lmacken')
-#
-# def test_fact_types(self):
-# DBSession.add(self.obj)
-# DBSession.flush()
-# me = DBSession.query(Entity).filter_by(name=u'lmacken').one()
-# eq_(me[u'lastname'], u'Macken')
-# eq_(me[u'age'], 24)
-# eq_(me[u'dob'], datetime(1984, 11, 2))
-# eq_(me[u'l33t'], True)
-#
-# def test_getting_by_name(self):
-# """ Entities should be fetchable by their name """
-# DBSession.add(self.obj)
-# lmacken = Entity.by_name(u'lmacken')
-# eq_(lmacken, self.obj)
-#
-# def test_filter_by_name(self):
-# DBSession.add(self.obj)
-# me = DBSession.query(Entity).filter_by(name=u'lmacken').one()
-# eq_(me.name, u'lmacken')
-# eq_(me[u'firstname'], u'Luke')
-#
-# def test_query_by_fact(self):
-# """ Query entities by facts """
-# DBSession.add(self.obj)
-# assert DBSession.query(Entity).filter(
-# Entity.facts.any(
-# and_(Fact.key == u'l33t',
-# Fact.value == True))).first()
-#
-# def test_query_with_characteristic(self):
-# """ Query entities based on facts using with_characteristic """
-# DBSession.add(self.obj)
-# assert (DBSession.query(Entity).
-# filter(or_(Entity.facts.any(
-# with_characteristic(u'dob', datetime(1984, 11, 02))),
-# not_(Entity.facts.any(Fact.key == u'l33t'))))).first()
-#
-# def test_query_facts_by_characteristic(self):
-# """ Query facts by certain characteristics """
-# DBSession.add(self.obj)
-# assert (DBSession.query(Fact).
-# filter(with_characteristic(u'l33t', True))).one()
-#
-# """
-# def test_hooks(self):
-# from moksha.hook import Hook, MokshaHookMapperExtension
-# from moksha.model import model
-# insert = update = delete = False
-#
-# class MyHook(Hook):
-# def after_insert(self, instance):
-# insert = True
-# def after_update(self, instance):
-# update = True
-# def after_delete(self, instance):
-# delete = True
-#
-# model.moksha_mapper_extension.hooks['after_insert'].append(MyHook())
-#
-# # create a new entity
-# something = Entity(u'something')
-# DBSession.add(something)
-# DBSession.flush()
-# assert insert
-# """
+"""Test Moksha's Entity/Fact model"""
+
+from datetime import datetime
+from nose.tools import eq_, assert_true
+from sqlalchemy import *
+from moksha.tests.models import ModelTest
+
+from moksha.apps.knowledge.model import DBSession, Entity, Fact, with_characteristic
+
+class TestEntity(ModelTest):
+ """Test case for the Entity model."""
+
+ klass = Entity
+ attrs = dict(name=u'lmacken')
+
+ def setup(self):
+ super(TestEntity, self).setup()
+ self.obj[u'firstname'] = u'Luke'
+ self.obj[u'lastname'] = u'Macken'
+ self.obj[u'age'] = 24
+ self.obj[u'dob'] = datetime(1984, 11, 02)
+ self.obj[u'l33t'] = True
+
+ def test_entity_creation_name(self):
+ eq_(self.obj.name, u'lmacken')
+
+ def test_fact_types(self):
+ DBSession.add(self.obj)
+ DBSession.flush()
+ me = DBSession.query(Entity).filter_by(name=u'lmacken').one()
+ eq_(me[u'lastname'], u'Macken')
+ eq_(me[u'age'], 24)
+ eq_(me[u'dob'], datetime(1984, 11, 2))
+ eq_(me[u'l33t'], True)
+
+ def test_getting_by_name(self):
+ """ Entities should be fetchable by their name """
+ DBSession.add(self.obj)
+ lmacken = Entity.by_name(u'lmacken')
+ eq_(lmacken, self.obj)
+
+ def test_filter_by_name(self):
+ DBSession.add(self.obj)
+ me = DBSession.query(Entity).filter_by(name=u'lmacken').one()
+ eq_(me.name, u'lmacken')
+ eq_(me[u'firstname'], u'Luke')
+
+ def test_query_by_fact(self):
+ """ Query entities by facts """
+ DBSession.add(self.obj)
+ assert DBSession.query(Entity).filter(
+ Entity.facts.any(
+ and_(Fact.key == u'l33t',
+ Fact.value == True))).first()
+
+ def test_query_with_characteristic(self):
+ """ Query entities based on facts using with_characteristic """
+ DBSession.add(self.obj)
+ assert (DBSession.query(Entity).
+ filter(or_(Entity.facts.any(
+ with_characteristic(u'dob', datetime(1984, 11, 02))),
+ not_(Entity.facts.any(Fact.key == u'l33t'))))).first()
+
+ def test_query_facts_by_characteristic(self):
+ """ Query facts by certain characteristics """
+ DBSession.add(self.obj)
+ assert (DBSession.query(Fact).
+ filter(with_characteristic(u'l33t', True))).one()
+
+ """
+ TODO: add hooks that send AMQP messages?
+ Or, do this i
+ def test_hooks(self):
+ from moksha.hook import Hook, MokshaHookMapperExtension
+ from moksha.model import model
+ insert = update = delete = False
+
+ class MyHook(Hook):
+ def after_insert(self, instance):
+ insert = True
+ def after_update(self, instance):
+ update = True
+ def after_delete(self, instance):
+ delete = True
+
+ model.moksha_mapper_extension.hooks['after_insert'].append(MyHook())
+
+ # create a new entity
+ something = Entity(u'something')
+ DBSession.add(something)
+ DBSession.flush()
+ assert insert
+ """
diff --git a/pavement.py b/pavement.py
index 1b64fc6..eb1e3ea 100644
--- a/pavement.py
+++ b/pavement.py
@@ -175,8 +175,10 @@ def license():
@task
def test():
+ print "Running Moksha test suite..."
sh("nosetests")
cwd = os.getcwd()
+ print "Running MokshaJQPlotDemo test suite..."
os.chdir(path('moksha') / 'apps' / 'demo' / 'MokshaJQPlotDemo')
sh('nosetests')
14 years, 6 months
moksha/middleware
by Luke Macken
moksha/middleware/connector.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
New commits:
commit ba3612bfbd57adc8a2c221090ab59c8c177bd72f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 20:07:28 2009 -0500
More improvements to the get_connector method
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 1e5e236..a5bfa98 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -166,17 +166,23 @@ class MokshaConnectorMiddleware(object):
def _get_connector(name, request=None):
# TODO: having a connection pool might be nice
+ cls = None
if name in MokshaConnectorMiddleware._connectors:
- c = MokshaConnectorMiddleware._connectors[name]
+ cls = MokshaConnectorMiddleware._connectors[name]['connector_class']
else:
# Look for it on the entry-point
for conn_entry in pkg_resources.iter_entry_points('moksha.connector'):
if conn_entry.name == name:
conn_class = conn_entry.load()
conn_class.register()
- c = {'connector_class': conn_class}
+ cls = conn_class
- if not request:
+ if request is None:
from pylons import request
- return c['connector_class'](request.environ, request)
+ if cls:
+ try:
+ return cls(request.environ, request)
+ except TypeError:
+ # Called outside of the WSGI stack
+ return cls(None, None)
14 years, 6 months
moksha/middleware
by Luke Macken
moksha/middleware/connector.py | 5 -----
1 file changed, 5 deletions(-)
New commits:
commit 02fd68a40239de31bc968d71e8846a92b5640b13
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 19:38:12 2009 -0500
Minor cleanups to the connector middleware
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 48ef971..1e5e236 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -22,10 +22,6 @@ import simplejson as json
import urllib
from webob import Request, Response
-from pylons import config
-from pylons.i18n import ugettext
-
-from moksha.exc import ApplicationNotFound, MokshaException
from pprint import pformat
@@ -178,7 +174,6 @@ def _get_connector(name, request=None):
if conn_entry.name == name:
conn_class = conn_entry.load()
conn_class.register()
- conn_path = conn_entry.dist.location
c = {'connector_class': conn_class}
if not request:
14 years, 6 months
moksha/middleware
by Luke Macken
moksha/middleware/connector.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
New commits:
commit a80e70c2f174edcc73e53392a3a053ccb238e8d1
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 19:36:08 2009 -0500
Make the moksha.api.connectors.get_connector method work outside of WSGI
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 9632b98..48ef971 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -170,7 +170,16 @@ class MokshaConnectorMiddleware(object):
def _get_connector(name, request=None):
# TODO: having a connection pool might be nice
- c = MokshaConnectorMiddleware._connectors[name]
+ if name in MokshaConnectorMiddleware._connectors:
+ c = MokshaConnectorMiddleware._connectors[name]
+ else:
+ # Look for it on the entry-point
+ for conn_entry in pkg_resources.iter_entry_points('moksha.connector'):
+ if conn_entry.name == name:
+ conn_class = conn_entry.load()
+ conn_class.register()
+ conn_path = conn_entry.dist.location
+ c = {'connector_class': conn_class}
if not request:
from pylons import request
14 years, 6 months
setup.py start-moksha
by Luke Macken
setup.py | 2 ++
start-moksha | 1 +
2 files changed, 3 insertions(+)
New commits:
commit eff2d6419510a0a416c6e7ac662b0c1a3a926e85
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 16:10:48 2009 -0500
Tweak some setuptools deps to get our virtualenv setup working out of the box
diff --git a/setup.py b/setup.py
index 3b16dcc..d115e70 100644
--- a/setup.py
+++ b/setup.py
@@ -41,6 +41,8 @@ setup(
"Paver",
"tw.forms",
"pytz",
+ "Catwalk",
+ "Babel"
#"WidgetBrowser", # not in PyPi yet
],
packages=find_packages(exclude=['ez_setup']),
diff --git a/start-moksha b/start-moksha
index e40c79d..1d22a75 100755
--- a/start-moksha
+++ b/start-moksha
@@ -18,6 +18,7 @@ if [ ! $VIRTUAL_ENV ]; then
easy_install Twisted
easy_install pysqlite
easy_install -U ToscaWidgets
+ easy_install -U SQLAlchemy
# `install` instead of `develop` to avoid weird directory vs. egg
# namespace issues
14 years, 6 months
Branch 'dashboard' - start-moksha
by Luke Macken
start-moksha | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e9f34c4641b38978b0f40052a07b4048e0243eaf
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 16:00:45 2009 -0500
Force update on Bable... *sigh*
diff --git a/start-moksha b/start-moksha
index 585e96a..c953c16 100755
--- a/start-moksha
+++ b/start-moksha
@@ -17,8 +17,8 @@ if [ ! $VIRTUAL_ENV ]; then
easy_install Paver
easy_install Twisted
easy_install pysqlite
- easy_install Babel
easy_install Catwalk
+ easy_install -U Babel
easy_install -U ToscaWidgets
easy_install -U tw.jquery==dev
14 years, 6 months
Branch 'dashboard' - start-moksha
by Luke Macken
start-moksha | 3 +++
1 file changed, 3 insertions(+)
New commits:
commit 24c44d295ee4bd9dbf54b0f84faf474c2e1fdfcb
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 15:56:39 2009 -0500
Install a few deps by hand in the start-moksha, to hack around virtualenv issues
diff --git a/start-moksha b/start-moksha
index e40c79d..585e96a 100755
--- a/start-moksha
+++ b/start-moksha
@@ -17,7 +17,10 @@ if [ ! $VIRTUAL_ENV ]; then
easy_install Paver
easy_install Twisted
easy_install pysqlite
+ easy_install Babel
+ easy_install Catwalk
easy_install -U ToscaWidgets
+ easy_install -U tw.jquery==dev
# `install` instead of `develop` to avoid weird directory vs. egg
# namespace issues
14 years, 6 months