demo/demo/widget.py | 2 development.ini | 4 + moksha/api/widgets/global_resources/widget.py | 6 ++ moksha/lib/helpers.py | 2 moksha/templates/index.mak | 2 moksha/tests/quickstarts/test_tg2.py | 23 ++++++++-- moksha/tests/quickstarts/tg2app/setup.py | 5 +- moksha/tests/quickstarts/tg2app/tg2app.egg-info/entry_points.txt | 5 +- production/sample-production.ini | 2 setup.py | 3 + 10 files changed, 42 insertions(+), 12 deletions(-)
New commits: commit 1d140b2f4727bbc2b90758c00e32bb17a47fda71 Author: Luke Macken lmacken@redhat.com Date: Thu Oct 7 18:46:44 2010 -0400
Disable a unit test that plugs a TG2 app into the moksha.wsgiapp entry-point.
This turns out to cause the plugin to stomp all over Moksha's pylons.config. It is still possible to plug in any WSGI app into this, but TG2/Pylons apps should be avoided.
diff --git a/moksha/tests/quickstarts/test_tg2.py b/moksha/tests/quickstarts/test_tg2.py index 7288b6b..e8939d9 100644 --- a/moksha/tests/quickstarts/test_tg2.py +++ b/moksha/tests/quickstarts/test_tg2.py @@ -1,4 +1,5 @@ import os +import pylons import pkg_resources
from webtest import TestApp @@ -34,10 +35,24 @@ class TestTG2AppInMoksha(object): DBSession.flush() assert DBSession.query(User).count() == 1
- def test_tg2app_wsgi(self): - """ Ensure we can get to TG2 when it is mounted as a WSGI app """ - resp = self.app.get('/apps/tg2wsgi/') - assert 'Now Viewing: index' in resp + #def test_tg2app_wsgi(self): + # """ + # Test plugging a TurboGears2/Pylons app into moksha via the + # moksha.wsgiapp extension-point. + + # :Note: This is a bad idea, as the the TG2 app will stomp on Moksha's + # pylons.config, since Moksha is a TG2 app as well. So, this test + # will verify that they don't play well together. + # """ + # # The tg2app will stomp on the pylons.paths and TG will dispatch + # # to the plugins RootController, instead of Moksha's + # resp = self.app.get('/apps/tg2wsgi/') + # assert '[ Moksha ]' in resp + # # It's getting to the app + # #assert 'Welcome to TurboGears' in resp, resp + + # #import tg2app + # #assert pylons.config['package'] == tg2app, pylons.config['package']
class TestTG2App(object): diff --git a/moksha/tests/quickstarts/tg2app/setup.py b/moksha/tests/quickstarts/tg2app/setup.py index f1a201e..409fba4 100644 --- a/moksha/tests/quickstarts/tg2app/setup.py +++ b/moksha/tests/quickstarts/tg2app/setup.py @@ -49,8 +49,9 @@ setup( [moksha.application] tg2app = tg2app.controllers.root:RootController
- [moksha.wsgiapp] - tg2wsgi = tg2app.wsgi:application + # Bad Idea. + #[moksha.wsgiapp] + #tg2wsgi = tg2app.wsgi:application
""", ) diff --git a/moksha/tests/quickstarts/tg2app/tg2app.egg-info/entry_points.txt b/moksha/tests/quickstarts/tg2app/tg2app.egg-info/entry_points.txt index bd4d865..2655973 100644 --- a/moksha/tests/quickstarts/tg2app/tg2app.egg-info/entry_points.txt +++ b/moksha/tests/quickstarts/tg2app/tg2app.egg-info/entry_points.txt @@ -8,7 +8,8 @@ [moksha.application] tg2app = tg2app.controllers.root:RootController
- [moksha.wsgiapp] - tg2wsgi = tg2app.wsgi:application + # Bad Idea. + #[moksha.wsgiapp] + #tg2wsgi = tg2app.wsgi:application
\ No newline at end of file
commit 0ddd035ee07a9fa243bac2668902610652bdd0c2 Author: Luke Macken lmacken@redhat.com Date: Thu Oct 7 18:45:14 2010 -0400
Have get_moksha_dev_config look in /etc/moksha
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index 0257bd2..bd41ed7 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -793,7 +793,7 @@ def get_moksha_config_path(): # raise MokshaConfigNotFound('Cannot find moksha configuration file!')
def get_moksha_dev_config(): - cfgs = [os.path.join(os.path.abspath(__file__ + '/../../../'), 'development.ini'), os.path.join(os.path.abspath(__file__ + '/../../../../'), 'development.ini'), os.path.join(os.getcwd(), 'development.ini'), '/etc/development.ini'] + cfgs = [os.path.join(os.path.abspath(__file__ + '/../../../'), 'development.ini'), os.path.join(os.path.abspath(__file__ + '/../../../../'), 'development.ini'), os.path.join(os.getcwd(), 'development.ini'), '/etc/moksha/development.ini'] for cfg in cfgs: if os.path.isfile(cfg): return cfg
commit 04de60e98f518af7d30124c09356cb624aa8c216 Author: Luke Macken lmacken@redhat.com Date: Thu Oct 7 18:39:11 2010 -0400
Remove a stray tw.jquery import
diff --git a/moksha/api/widgets/global_resources/widget.py b/moksha/api/widgets/global_resources/widget.py index 3377f3b..c518849 100644 --- a/moksha/api/widgets/global_resources/widget.py +++ b/moksha/api/widgets/global_resources/widget.py @@ -19,7 +19,6 @@ import pkg_resources
from tg import config, url from tw.api import Widget, CSSLink, JSLink -from tw.jquery import jquery_js from paste.deploy.converters import asbool from pylons import request from inspect import isclass
commit 34ef9e14d1376f710a858665574c820c0b0f5b41 Author: Luke Macken lmacken@redhat.com Date: Thu Oct 7 18:36:47 2010 -0400
Put the Live Socket on the global entry-point by default, and make it configurable with the `mokska.livesocket` option.
diff --git a/development.ini b/development.ini index 5e4b959..21e350d 100644 --- a/development.ini +++ b/development.ini @@ -79,6 +79,10 @@ app_db = sqlite:///%s.db ## Moksha Live Socket configuration ##
+# Automatically inject the Moksha live socket with +# the Global Resource Injection Widget +moksha.livesocket = True + # The backing protocol for live widgets. # Available backends: stomp, amqp moksha.livesocket.backend = stomp diff --git a/moksha/api/widgets/global_resources/widget.py b/moksha/api/widgets/global_resources/widget.py index 0fb9417..3377f3b 100644 --- a/moksha/api/widgets/global_resources/widget.py +++ b/moksha/api/widgets/global_resources/widget.py @@ -25,6 +25,7 @@ from pylons import request from inspect import isclass
from moksha.widgets.moksha_js import moksha_js, moksha_extension_points_js +from moksha.api.widgets.live import moksha_socket
log = logging.getLogger(__name__)
@@ -80,6 +81,10 @@ class GlobalResourceInjectionWidget(Widget): log.debug("Skipping duplicate global widget: %s" % widget_entry.name) else: + if loaded is moksha_socket: + if not asbool(config.get('moksha.livesocket', True)): + log.debug('Moksha Live Socket disabled in the config') + continue self.children.append(loaded) else: raise Exception("Unknown global resource: %s. Should be " diff --git a/production/sample-production.ini b/production/sample-production.ini index b9b4b36..7ec92f4 100644 --- a/production/sample-production.ini +++ b/production/sample-production.ini @@ -75,6 +75,8 @@ feed_cache = sqlite:////var/lib/moksha/feeds.db orbited_host = localhost orbited_port = 9000
+moksha.livesocket = True + # The backing protocol for live widgets. # Available backends: stomp, amqp moksha.livesocket.backend = stomp diff --git a/setup.py b/setup.py index 1ce16a3..673d0a4 100644 --- a/setup.py +++ b/setup.py @@ -86,6 +86,9 @@ setup( code_widget = moksha.widgets.source:code_widget moksha_socket = moksha.api.widgets.live:moksha_socket
+ [moksha.global] + moksha_socket = moksha.api.widgets.live:moksha_socket + [paste.global_paster_command] moksha = moksha.commands.quickstart:MokshaQuickstartCommand
commit 76b3467fec05c769e3299b8759a0efe1097d054a Author: Luke Macken lmacken@redhat.com Date: Thu Oct 7 18:34:11 2010 -0400
Cosmetic tweak to our demo widget
diff --git a/demo/demo/widget.py b/demo/demo/widget.py index a954c92..32b9aff 100644 --- a/demo/demo/widget.py +++ b/demo/demo/widget.py @@ -2,8 +2,8 @@ from moksha.api.widgets.live import LiveWidget
class HelloWorldWidget(LiveWidget): topic = "helloworld" - onmessage = "$('#data').append(json.msg).append('<br/>');" template = """ <b>Hello World Widget</b> <div id="data"/> """ + onmessage = "$('#data').append(json.msg).append('<br/>');"
commit 387e8af9690d08298b52f0cb6d625ffd9e004b2c Author: Luke Macken lmacken@redhat.com Date: Mon Oct 4 19:08:24 2010 -0400
Don't run any mako filters on the global resource widget in our default index
diff --git a/moksha/templates/index.mak b/moksha/templates/index.mak index 101f88b..a748c37 100644 --- a/moksha/templates/index.mak +++ b/moksha/templates/index.mak @@ -32,7 +32,7 @@ <div id="moksha_dock" style="display:block; padding-top: 10px; height: 30px; bottom:5px; position: absolute;" />
## Inject our global resources - ${tmpl_context.moksha_global_resources()} + ${tmpl_context.moksha_global_resources() | n}
## Setup our right-click contextual menu ## ${tmpl_context.contextual_menu_widget()}
moksha-commits@lists.fedorahosted.org