moksha/widgets
by Luke Macken
moksha/widgets/all.py | 7 +++++++
1 file changed, 7 insertions(+)
New commits:
commit 28e8d3b848847bf64bd326c845df9d45ad804c16
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Feb 6 00:35:55 2009 -0500
Pull in the widgetbrowser's widgets in the `moksha.widgets.all` module
diff --git a/moksha/widgets/all.py b/moksha/widgets/all.py
index ef3b8e8..c9152fc 100644
--- a/moksha/widgets/all.py
+++ b/moksha/widgets/all.py
@@ -23,6 +23,8 @@ which archives all of the resources used by all ToscaWidgets.
"""
import pkg_resources
+
+from tw.api import Widget
from inspect import isclass
__all__ = []
@@ -39,3 +41,8 @@ for entry_point in ('moksha.widget', 'moksha.menu', 'moksha.global'):
# Other stuff that isn't exposed
from moksha.widgets.container import MokshaContainer
__all__.append(MokshaContainer)
+
+from widgetbrowser import widgets
+for obj in dir(widgets):
+ if isinstance(getattr(widgets, obj), Widget):
+ __all__.append(obj)
15 years, 4 months
2 commits - development.ini moksha/controllers moksha/widgetbrowser
by Luke Macken
development.ini | 4 ++++
moksha/controllers/root.py | 3 ++-
moksha/widgetbrowser/setup.py | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
New commits:
commit ee6628ac4081a3dccd75de80c068ccbdc0e21482
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 23:12:13 2009 -0500
Make our WidgetBrowser documentation directory configurable
diff --git a/development.ini b/development.ini
index ca81db0..f925940 100644
--- a/development.ini
+++ b/development.ini
@@ -38,6 +38,10 @@ stomp_pass = guest
# Optional AMQP Broker.
#amqp_broker = guest/guest@localhost
+# Documentation directory
+docs_dir = docs
+# docs_dir = /srv/moksha/docs
+
# Moksha chat configuration
# Use a built-in IRC server
diff --git a/moksha/controllers/root.py b/moksha/controllers/root.py
index 148e2a4..a626260 100644
--- a/moksha/controllers/root.py
+++ b/moksha/controllers/root.py
@@ -18,6 +18,7 @@
import moksha
+from tg import config
from tg import expose, flash, require, tmpl_context, redirect, validate
from tg.controllers import WSGIAppController
from repoze.what import predicates
@@ -47,7 +48,7 @@ class RootController(BaseController):
WidgetBrowser(
template_dirs=[resource_filename('moksha','templates/widget_browser')],
full_stack=False,
- docs_dir='docs'))
+ docs_dir=config.get('docs_dir', 'docs')))
@expose()
def lookup(self, resource, *remainder):
commit fc386c22a9c5148d20870a95f15de974df608648
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 23:02:31 2009 -0500
Have the WidgetBrowser require docutils
diff --git a/moksha/widgetbrowser/setup.py b/moksha/widgetbrowser/setup.py
index 41c24a0..967a1f9 100644
--- a/moksha/widgetbrowser/setup.py
+++ b/moksha/widgetbrowser/setup.py
@@ -21,6 +21,7 @@ setup(name='WidgetBrowser',
"ToscaWidgets>=0.9.2dev-20080602",
"Genshi",
"WebOb",
+ "docutils",
],
tests_require = ['nose', 'formencode', 'sphinx'],
extras_require = {
15 years, 4 months
moksha/api
by Luke Macken
moksha/api/menus/controllers/menu.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit c44ea12bd8822cf6f607d2f18b70e0c927bb65ac
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 15:27:13 2009 -0500
Make the MokshaMenuController a regular Controller, instead of a Base.
diff --git a/moksha/api/menus/controllers/menu.py b/moksha/api/menus/controllers/menu.py
index 8ef6cff..209941b 100644
--- a/moksha/api/menus/controllers/menu.py
+++ b/moksha/api/menus/controllers/menu.py
@@ -19,9 +19,9 @@
import moksha
from tg import expose
-from moksha.lib.base import BaseController
+from moksha.lib.base import Controller
-class MokshaMenuController(BaseController):
+class MokshaMenuController(Controller):
name = 'Moksha Menus'
@expose()
15 years, 4 months
2 commits - moksha/api moksha/controllers moksha/__init__.py moksha/lib moksha/middleware moksha/wsgiapp.py
by Luke Macken
moksha/__init__.py | 8 +++---
moksha/api/widgets/feed/feed.py | 4 +--
moksha/controllers/root.py | 18 +++++++++++---
moksha/lib/helpers.py | 2 -
moksha/middleware/middleware.py | 51 ++++++++++++++--------------------------
moksha/wsgiapp.py | 27 +++++++--------------
6 files changed, 50 insertions(+), 60 deletions(-)
New commits:
commit 2c7d701b518cc790edb15bf2aa1f166589685e84
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 14:31:42 2009 -0500
Simplify up our Middleware, WSGIApp, and application dispatching.
We now dispatch application requests to Moksha's RootController.lookup method,
instead of doing lots of crazy stuff in the moksha.wsgiapp.
diff --git a/moksha/controllers/root.py b/moksha/controllers/root.py
index 1e50870..148e2a4 100644
--- a/moksha/controllers/root.py
+++ b/moksha/controllers/root.py
@@ -27,15 +27,19 @@ from widgetbrowser import WidgetBrowser
from moksha import _
from moksha.model import DBSession
from moksha.lib.base import BaseController
-from moksha.controllers.secc import AdminController
+#from moksha.controllers.secc import AdminController
+from moksha.exc import ApplicationNotFound
from moksha.controllers.error import ErrorController
from moksha.widgets.container import MokshaContainer
container = MokshaContainer('moksha_container')
+#import os
+#os.putenv('TW_BROWSER_PREFIX', '/docs')
+
class RootController(BaseController):
- admin = AdminController()
+ #admin = AdminController()
error = ErrorController()
# ToscaWidgets WidgetBrowser integration
@@ -45,6 +49,14 @@ class RootController(BaseController):
full_stack=False,
docs_dir='docs'))
+ @expose()
+ def lookup(self, resource, *remainder):
+ if resource == 'appz':
+ app = remainder[0]
+ if app not in moksha.apps:
+ raise AppNotFoundException(app)
+ return moksha.apps[app]['controller'], remainder[1:]
+
@expose('mako:moksha.templates.index')
def index(self):
tmpl_context.menu_widget = moksha.menus['default_menu']
@@ -54,6 +66,7 @@ class RootController(BaseController):
@expose('mako:moksha.templates.widget')
def widgets(self, widget, chrome=None, **kw):
options = {}
+ options.update(kw)
w = moksha._widgets.get(widget)
if not w:
raise WidgetNotFound(widget)
@@ -64,7 +77,6 @@ class RootController(BaseController):
options['id'] = widget + '_container'
else:
tmpl_context.widget = w['widget']
- options.update(kw)
return dict(options=options)
@expose('moksha.templates.login')
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py
index 85d9071..4d06161 100644
--- a/moksha/middleware/middleware.py
+++ b/moksha/middleware/middleware.py
@@ -73,12 +73,7 @@ class MokshaMiddleware(object):
self.register_stomp(environ)
request = Request(environ)
if request.path.startswith('/appz'):
- app = request.path.split('/')[1]
- environ['moksha.apps'] = self.apps
- try:
- response = request.get_response(self.mokshaapp)
- except ApplicationNotFound:
- response = Response(status='404 Not Found')
+ response = request.get_response(self.mokshaapp)
else:
response = request.get_response(self.application)
return response(environ, start_response)
diff --git a/moksha/wsgiapp.py b/moksha/wsgiapp.py
index 8a2a911..6d74781 100644
--- a/moksha/wsgiapp.py
+++ b/moksha/wsgiapp.py
@@ -17,7 +17,9 @@
# Authors: Luke Macken <lmacken(a)redhat.com>
from pylons.wsgiapp import PylonsApp
-from moksha.exc import ApplicationNotFound
+
+import moksha
+from moksha.controllers.root import RootController
class MokshaAppDispatcher(PylonsApp):
""" Moksha WSGI Application Dispatcher.
@@ -26,6 +28,10 @@ class MokshaAppDispatcher(PylonsApp):
It is instantiated and utilized by the
:class:`moksha.middleware.MokshaMiddleware`.
"""
+ def __init__(self, *args, **kw):
+ super(MokshaAppDispatcher, self).__init__(*args, **kw)
+ self.root = RootController()
+
def resolve(self, environ, start_response):
""" Uses dispatching information found in
``environ['wsgiorg.routing_args']`` to retrieve the application
@@ -33,20 +39,5 @@ class MokshaAppDispatcher(PylonsApp):
moksha application.
"""
- # Update the Routes config object in case we're using Routes
- # (Do we even need/want this routes configuration?)
- #config = request_config()
- #config.redirect = self.redirect_to
- # http://www.wsgi.org/wsgi/Specifications/routing_args
- match = environ['wsgiorg.routing_args'][1]
-
- app = match['url'].split('/')[1]
- if not app in environ['moksha.apps']:
- raise ApplicationNotFound(app)
-
- # Remaining arguments
- match['url'] = '/'.join(match['url'].strip('/').split('/')[2:])
-
- environ['pylons.routes_dict'] = match
-
- return environ['moksha.apps'][app]['controller']
+ environ['pylons.routes_dict'] = environ['wsgiorg.routing_args'][1]
+ return self.root
commit fef6c11bb85358c37cb81d9cd5f15121f0236394
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 14:30:13 2009 -0500
Replace the unnecessary moksha.{apps,_widgets,menus} StackedObjectProxies and
replace them with dictionaries setup by the Moksha Middleware.
diff --git a/moksha/__init__.py b/moksha/__init__.py
index 4f6f386..e34a9dd 100644
--- a/moksha/__init__.py
+++ b/moksha/__init__.py
@@ -2,16 +2,16 @@ from pylons.i18n import ugettext as _
from paste.registry import StackedObjectProxy
# The central feed cache, used by the Feed widget.
-feed_cache = StackedObjectProxy()
+feed_cache = None
# All loaded moksha applications
-apps = StackedObjectProxy()
+apps = None
# All loaded ToscaWidgets
-_widgets = StackedObjectProxy()
+_widgets = None
# All loaded moksha menus
-menus = StackedObjectProxy()
+menus = None
# Per-request stomp callbacks registered by rendered widget
stomp = StackedObjectProxy()
diff --git a/moksha/api/widgets/feed/feed.py b/moksha/api/widgets/feed/feed.py
index 252bda9..864b2fe 100644
--- a/moksha/api/widgets/feed/feed.py
+++ b/moksha/api/widgets/feed/feed.py
@@ -90,9 +90,9 @@ class Feed(Widget):
def iterentries(self, d=None):
url = self.url or d.get('url')
- try:
+ if moksha.feed_cache:
feed = moksha.feed_cache.fetch(url)
- except TypeError, e:
+ else:
# MokshaMiddleware not running, so setup our own feed cache.
# This allows us to use this object outside of WSGI requests.
global cache
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 74a2521..01f88a7 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -206,7 +206,7 @@ class MokshaApp(App):
def process(self):
# We return a placeholder if the app is not registered
- if not moksha._apps.has_key(self.app):
+ if not moksha.apps.has_key(self.app):
return MokshaWidget(self.label, 'placeholder',
self.content_id,
{'appname':self.app}, self.auth).process()
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py
index 4e0ef8c..85d9071 100644
--- a/moksha/middleware/middleware.py
+++ b/moksha/middleware/middleware.py
@@ -49,14 +49,14 @@ class MokshaMiddleware(object):
"""
def __init__(self, application):
- log.info('Creating MokshaMiddleware')
+ log.info('Creating Moksha Middleware')
self.application = application
self.mokshaapp = MokshaAppDispatcher()
- self.apps = {} # {'app name': WSGI Controller}
- self.menus = {} # {'menu name': MokshaMenu}
- self.widgets = {} # {'widget name': tw.api.Widget}
- self.engines = {} # {'app name': sqlalchemy.engine.base.Engine}
+ moksha.apps = {} # {'app name': tg.TGController}
+ moksha._widgets = {} # {'widget name': tw.api.Widget}
+ moksha.menus = {} # {'menu name': moksha.api.menus.MokshaMenu}
+ self.engines = {} # {'app name': sqlalchemy.engine.base.Engine}
self.load_paths()
self.load_renderers()
@@ -67,16 +67,11 @@ class MokshaMiddleware(object):
self.load_menus()
self.feed_storage = Shove(config['feed_cache'])
- self.feed_cache = Cache(self.feed_storage)
+ moksha.feed_cache = Cache(self.feed_storage)
def __call__(self, environ, start_response):
- # environ['paste.registry'].register(moksha.apps, self.apps)
- # environ['paste.registry'].register(moksha._widgets, self.widgets)
- environ['paste.registry'].register(moksha.feed_cache, self.feed_cache)
- environ['paste.registry'].register(moksha.menus, self.menus)
self.register_stomp(environ)
request = Request(environ)
-
if request.path.startswith('/appz'):
app = request.path.split('/')[1]
environ['moksha.apps'] = self.apps
@@ -86,7 +81,6 @@ class MokshaMiddleware(object):
response = Response(status='404 Not Found')
else:
response = request.get_response(self.application)
-
return response(environ, start_response)
def register_stomp(self, environ):
@@ -107,20 +101,20 @@ class MokshaMiddleware(object):
beforehand.
"""
for app_entry in pkg_resources.iter_entry_points('moksha.application'):
- if app_entry.name in self.apps:
+ if app_entry.name in moksha.apps:
raise MokshaException('Duplicate application name: %s' %
app_entry.name)
app_path = app_entry.dist.location
- self.apps[app_entry.name] = {
+ moksha.apps[app_entry.name] = {
'name': app_entry.name,
'path': app_path,
}
for widget_entry in pkg_resources.iter_entry_points('moksha.widget'):
- if widget_entry.name in self.widgets:
+ if widget_entry.name in moksha._widgets:
raise MokshaException('Duplicate widget name: %s' %
widget_entry.name)
widget_path = widget_entry.dist.location
- self.widgets[widget_entry.name] = {
+ moksha._widgets[widget_entry.name] = {
'name': widget_entry.name,
'path': widget_path,
}
@@ -131,7 +125,7 @@ class MokshaMiddleware(object):
log.info('Loading %s application' % app_entry.name)
app_class = app_entry.load()
app_path = app_entry.dist.location
- self.apps[app_entry.name] = {
+ moksha.apps[app_entry.name] = {
'name': getattr(app_class, 'name', app_entry.name),
'controller': app_class(),
'path': app_path,
@@ -141,12 +135,10 @@ class MokshaMiddleware(object):
model = __import__('%s.model' % app_entry.name,
globals(), locals(),
[app_entry.name])
- self.apps[app_entry.name]['model'] = model
+ moksha.apps[app_entry.name]['model'] = model
except ImportError:
pass
- moksha._apps = self.apps
-
def load_widgets(self):
log.info('Loading moksha widgets')
for widget_entry in pkg_resources.iter_entry_points('moksha.widget'):
@@ -157,14 +149,14 @@ class MokshaMiddleware(object):
widget = widget_class(widget_entry.name)
else:
widget = widget_class
- self.widgets[widget_entry.name] = {
+ moksha._widgets[widget_entry.name] = {
'name': getattr(widget_class, '__name__',
widget_entry.name),
'widget': widget,
'path': widget_path,
}
- moksha._widgets = self.widgets
+ moksha._widgets = moksha._widgets
def load_menus(self):
log.info('Loading moksha menus')
@@ -172,7 +164,7 @@ class MokshaMiddleware(object):
log.info('Loading %s menu' % menu_entry.name)
menu_class = menu_entry.load()
menu_path = menu_entry.dist.location
- self.menus[menu_entry.name] = menu_class(menu_entry.name)
+ moksha.menus[menu_entry.name] = menu_class(menu_entry.name)
def load_renderers(self):
""" Load our template renderers with our application paths.
@@ -183,7 +175,7 @@ class MokshaMiddleware(object):
"""
#template_paths = config['pylons.paths']['templates']
#moksha_dir = os.path.abspath(__file__ + '/../../../')
- #for app in [{'path': moksha_dir}] + self.apps.values():
+ #for app in [{'path': moksha_dir}] + moksha.apps.values():
# if app['path'] not in template_paths:
# template_paths.append(app['path'])
@@ -268,7 +260,7 @@ class MokshaMiddleware(object):
"""
moksha_conf = os.path.abspath(__file__ + '/../../../')
- for app in [{'path': moksha_conf}] + self.apps.values():
+ for app in [{'path': moksha_conf}] + moksha.apps.values():
for configfile in ('production.ini', 'development.ini'):
confpath = os.path.join(app['path'], configfile)
if os.path.exists(confpath):
@@ -294,7 +286,7 @@ class MokshaMiddleware(object):
if they don't already exist.
"""
- for name, app in self.apps.items():
+ for name, app in moksha.apps.items():
if app.get('model'):
log.debug('Creating database engine for %s' % app['name'])
self.engines[name] = create_engine(config['app_db'] % name)
15 years, 4 months
moksha/widgets
by Luke Macken
moksha/widgets/all.py | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 178e0fa5c019dd166de43a819457923f81910fb6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 01:55:47 2009 -0500
Pull in some other misc wigets that aren't exposed on any entrypoints
diff --git a/moksha/widgets/all.py b/moksha/widgets/all.py
index 36834f3..ef3b8e8 100644
--- a/moksha/widgets/all.py
+++ b/moksha/widgets/all.py
@@ -35,3 +35,7 @@ for entry_point in ('moksha.widget', 'moksha.menu', 'moksha.global'):
else:
widget = widget_class
__all__.append(widget)
+
+# Other stuff that isn't exposed
+from moksha.widgets.container import MokshaContainer
+__all__.append(MokshaContainer)
15 years, 4 months
moksha/widgets setup.cfg
by Luke Macken
moksha/widgets/all.py | 15 ++++++++-------
setup.cfg | 2 +-
2 files changed, 9 insertions(+), 8 deletions(-)
New commits:
commit 265de7808fc090b2136bdfb6124233bb6258a85c
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:58:25 2009 -0500
Make sure we pull in globals and menus into the toscawidgets.widgets entry point
diff --git a/moksha/widgets/all.py b/moksha/widgets/all.py
index 3842215..36834f3 100644
--- a/moksha/widgets/all.py
+++ b/moksha/widgets/all.py
@@ -27,10 +27,11 @@ from inspect import isclass
__all__ = []
-for widget_entry in pkg_resources.iter_entry_points('moksha.widget'):
- widget_class = widget_entry.load()
- if isclass(widget_class):
- widget = widget_class(widget_entry.name)
- else:
- widget = widget_class
- __all__.append(widget)
+for entry_point in ('moksha.widget', 'moksha.menu', 'moksha.global'):
+ for widget_entry in pkg_resources.iter_entry_points(entry_point):
+ widget_class = widget_entry.load()
+ if isclass(widget_class):
+ widget = widget_class(widget_entry.name)
+ else:
+ widget = widget_class
+ __all__.append(widget)
diff --git a/setup.cfg b/setup.cfg
index ddbcd3e..08503a6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,7 @@ output_dir = moksha/i18n
previous = true
[archive_tw_resources]
-output = tw_static
+output = toscawidgets
distributions = moksha
#compresslevel = 2
onepass = true
15 years, 4 months
6 commits - docs/main moksha/middleware moksha/streams moksha/widgets setup.cfg setup.py
by Luke Macken
docs/main/Deployment.rst | 5 ++++
moksha/middleware/middleware.py | 2 -
moksha/streams/feed/feedstream.py | 8 ++++++-
moksha/widgets/all.py | 36 ++++++++++++++++++++++++++++++++++
moksha/widgets/container/container.py | 1
setup.cfg | 10 +++++++++
setup.py | 4 +++
7 files changed, 62 insertions(+), 4 deletions(-)
New commits:
commit cf17100330f4d21b8645f1141b70067c8edb9392
Merge: f820149... 50c19ec...
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:39:49 2009 -0500
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit f820149d3361761742d9c3a444dd00ea8e43bf12
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:39:09 2009 -0500
Add a `moksha.widgets.all` module that imports all moksha widgets, and
put them on the `toscawidgets.widgets` entry point. This is so we can
use the archive_tw_resources command and pull in all of our static files.
diff --git a/moksha/widgets/all.py b/moksha/widgets/all.py
new file mode 100644
index 0000000..3842215
--- /dev/null
+++ b/moksha/widgets/all.py
@@ -0,0 +1,36 @@
+# This file is part of Moksha.
+#
+# 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.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Moksha. If not, see <http://www.gnu.org/licenses/>.
+#
+# Copyright 2008, Red Hat, Inc.
+
+"""
+A module that imports all known widgets.
+
+This is currently used by the `archive_tw_resources` setuptools command,
+which archives all of the resources used by all ToscaWidgets.
+"""
+
+import pkg_resources
+from inspect import isclass
+
+__all__ = []
+
+for widget_entry in pkg_resources.iter_entry_points('moksha.widget'):
+ widget_class = widget_entry.load()
+ if isclass(widget_class):
+ widget = widget_class(widget_entry.name)
+ else:
+ widget = widget_class
+ __all__.append(widget)
diff --git a/setup.py b/setup.py
index ca71d93..c1340c3 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,9 @@ setup(
[paste.app_install]
main = pylons.util:PylonsInstaller
+ [toscawidgets.widgets]
+ widgets = moksha.widgets.all
+
[moksha.stream]
demo = moksha.streams.demo:MokshaDemoDataStream
#livegraph = moksha.examples.livegraph:LiveGraphDataStream
commit b6d4ba5f43fc24a5eddc6acd4c92753c493c722f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:35:52 2009 -0500
Add a `python setup.py archive_tw_resources` command for production deployments.
diff --git a/setup.cfg b/setup.cfg
index 6cc77bf..ddbcd3e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -29,3 +29,13 @@ domain = moksha
input_file = moksha/i18n/moksha.pot
output_dir = moksha/i18n
previous = true
+
+[archive_tw_resources]
+output = tw_static
+distributions = moksha
+#compresslevel = 2
+onepass = true
+#yuicompressor = /home/someuser/bin/yuicompressor.jar
+
+#[aliases]
+#deploy = archive_tw_resources --force install
commit 8773292479b417a025bfe78a9405dd062db18a5a
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:35:32 2009 -0500
Some minor tweaks
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py
index aee95e0..4e0ef8c 100644
--- a/moksha/middleware/middleware.py
+++ b/moksha/middleware/middleware.py
@@ -99,8 +99,6 @@ class MokshaMiddleware(object):
'onmessageframe': defaultdict(list) # {topic: [js_callback,]}
})
-
-
def load_paths(self):
""" Load the names and paths of all moksha applications and widgets.
diff --git a/moksha/streams/feed/feedstream.py b/moksha/streams/feed/feedstream.py
index da7c0ec..b7b2e5e 100644
--- a/moksha/streams/feed/feedstream.py
+++ b/moksha/streams/feed/feedstream.py
@@ -18,8 +18,14 @@ class FeedStream(PollingDataStream):
def poll(self):
""" Poll all known feeds.
+ - Iterate over all feeds in our global moksha feed cache..
+ Problem:: the MokshaHub will not use this unless both it and the
+ Moksha WSGI app are using the same `feed_cache` database.
+
- Keep feed caches fresh.
- - Send AMQP messages for new entries
+ - Send messages to topics for new entries
+ `feed.$NAME` topic ?
+ `tag.category
"""
log.debug('FeedStream.poll()')
# gather all feed urls... from all moksha.widget Feed objects, and
diff --git a/moksha/widgets/container/container.py b/moksha/widgets/container/container.py
index 6fcfd4d..721d585 100644
--- a/moksha/widgets/container/container.py
+++ b/moksha/widgets/container/container.py
@@ -57,5 +57,4 @@ class MokshaContainer(Widget):
d.buttons += '%s,' % button[:1]
d.buttons = d.buttons[:-1]
- print "d.id = ", d.id
self.add_call(jQuery('#%s' % d.id).buildContainers())
diff --git a/setup.py b/setup.py
index c36a621..ca71d93 100644
--- a/setup.py
+++ b/setup.py
@@ -90,7 +90,7 @@ setup(
## Blueprint plugins
#blueprint_fancytype_css = moksha.widgets.blueprint:blueprint_plugin_fancytype_css
- # ↑ ↑ ↓ ↓ ← → ← → b a
+ # up up down down left right left right b a
konami_js = moksha.widgets.misc.ptd:konami
[moksha.menu]
commit 31472036050448a536fad7cfe7e3c6f642a6e451
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Feb 5 00:34:41 2009 -0500
Document how to deploy ToscaWidgets resources in production
diff --git a/docs/main/Deployment.rst b/docs/main/Deployment.rst
index 6970370..d8b6b4c 100644
--- a/docs/main/Deployment.rst
+++ b/docs/main/Deployment.rst
@@ -14,6 +14,11 @@ Setting up mod_wsgi
TODO
+Serving ToscaWidgets static resources
+-------------------------------------
+
+`Deploying projects which use ToscaWidgets <http://toscawidgets.org/documentation/ToscaWidgets/deploy.html>`_
+
Setting up orbited
------------------
commit d04ae8f3b2e0ed8ac0dc3124796e4c8a632d9c24
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Feb 4 17:29:39 2009 -0500
↑ ↑ ↓ ↓ ← → ← → b a
diff --git a/setup.py b/setup.py
index 6ae206c..c36a621 100644
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,7 @@ setup(
## Blueprint plugins
#blueprint_fancytype_css = moksha.widgets.blueprint:blueprint_plugin_fancytype_css
+ # ↑ ↑ ↓ ↓ ← → ← → b a
konami_js = moksha.widgets.misc.ptd:konami
[moksha.menu]
15 years, 4 months
moksha/lib
by John (J5) Palmieri
moksha/lib/helpers.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 50c19ec91ec20859ac9b007044dc3e92bd574ecb
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed Feb 4 17:17:19 2009 -0500
account for paths when checking if an app exists
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index e08b732..74a2521 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -197,7 +197,8 @@ class MokshaApp(App):
get sent.
"""
# FIXME figure out how to pull auth info from an app
- self.app = moksha_app
+ app = moksha_app.split('/')[0]
+ self.app = app
super(MokshaApp, self).__init__(label,
'/appz/' + moksha_app,
content_id,
15 years, 4 months
moksha/api moksha/lib moksha/middleware setup.py
by John (J5) Palmieri
moksha/api/widgets/__init__.py | 1
moksha/api/widgets/containers/dashboardcontainer.py | 2
moksha/api/widgets/containers/tabbedcontainer.py | 14 +
moksha/api/widgets/containers/templates/layout_applist.mak | 4
moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak | 7
moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak | 9
moksha/api/widgets/placeholder.py | 11 +
moksha/lib/helpers.py | 103 +++++++---
moksha/middleware/middleware.py | 5
setup.py | 2
10 files changed, 124 insertions(+), 34 deletions(-)
New commits:
commit 474f4570361b47ff61d22dcba70c0f840f614e26
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed Feb 4 16:05:00 2009 -0500
add placeholders and fix up containers to be more consitant and easier to use
* added the TabbedContainerPanes and TabbedContainerTabs widgets to abstract
out displaying apps inside of containers. Now if the internal config
format changes a bit apps won't break if they use the standard display
widgets
* fixed a few bugs with displaying widgets that had parameters
diff --git a/moksha/api/widgets/__init__.py b/moksha/api/widgets/__init__.py
index 38b79ba..6449275 100644
--- a/moksha/api/widgets/__init__.py
+++ b/moksha/api/widgets/__init__.py
@@ -1,4 +1,5 @@
from live import LiveWidget
from util import *
from grid import Grid
+from placeholder import Placeholder
diff --git a/moksha/api/widgets/containers/dashboardcontainer.py b/moksha/api/widgets/containers/dashboardcontainer.py
index 41732bf..6892d6f 100644
--- a/moksha/api/widgets/containers/dashboardcontainer.py
+++ b/moksha/api/widgets/containers/dashboardcontainer.py
@@ -7,7 +7,7 @@ from tg import config
class AppListWidget(Widget):
template = 'mako:moksha.api.widgets.containers.templates.layout_applist'
- properties = ['layout', 'category']
+ properties = ['category']
def update_params(self, d):
super(AppListWidget, self).update_params(d)
diff --git a/moksha/api/widgets/containers/tabbedcontainer.py b/moksha/api/widgets/containers/tabbedcontainer.py
index 1111084..00e5898 100644
--- a/moksha/api/widgets/containers/tabbedcontainer.py
+++ b/moksha/api/widgets/containers/tabbedcontainer.py
@@ -1,10 +1,20 @@
from tw.jquery.ui_tabs import JQueryUITabs
+from tw.api import Widget
from pylons import config, request
from repoze.what import predicates
from moksha.lib.helpers import eval_app_config, ConfigWrapper
import urllib
+class TabbedContainerTabs(Widget):
+ template = 'mako:moksha.api.widgets.containers.templates.tabbedcontainer_tabs'
+
+class TabbedContainerPanes(Widget):
+ template = 'mako:moksha.api.widgets.containers.templates.tabbedcontainer_panes'
+
+tabwidget = TabbedContainerTabs('tabs')
+panewidget = TabbedContainerPanes('panes')
+
"""
:Name: TabbedContainer
:Type: Container
@@ -49,3 +59,7 @@ class TabbedContainer(JQueryUITabs):
# not allowed to run with the current session's authorization level
tabs = ConfigWrapper.process_wrappers(tabs)
d['tabs'] = tabs
+ d['tabwidget'] = tabwidget
+ d['panewidget'] = panewidget
+ d['root_id'] = d['id']
+
diff --git a/moksha/api/widgets/containers/templates/layout_applist.mak b/moksha/api/widgets/containers/templates/layout_applist.mak
index 0fa4464..af2021a 100644
--- a/moksha/api/widgets/containers/templates/layout_applist.mak
+++ b/moksha/api/widgets/containers/templates/layout_applist.mak
@@ -6,11 +6,11 @@
% endif
<dd id="${app['id']}">
% if app.has_key('widget'):
- ${app['widget'](app['params'])}
+ ${app['widget'](**app['params'])}
% endif
</dd>
- % if app.has_key('url'):
+ % if not app.has_key('widget'):
<script type="text/javascript">
$("#${app['id']}").load("${app['url']}");
</script>
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak
new file mode 100644
index 0000000..5bc58b7
--- /dev/null
+++ b/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak
@@ -0,0 +1,7 @@
+% for t in tabs:
+ <div id="${t['content_id']}">
+ % if t.has_key('widget'):
+ ${t['widget'](**t['params'])}
+ % endif
+ </div>
+% endfor
\ No newline at end of file
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
new file mode 100644
index 0000000..6bcaab3
--- /dev/null
+++ b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
@@ -0,0 +1,9 @@
+<ul id="${root_id}">
+ % for t in tabs:
+ <li>
+ <a href="${t['url']}" title="${t['content_id']}">
+ ${t['label']}
+ </a>
+ </li>
+ % endfor
+</ul>
diff --git a/moksha/api/widgets/placeholder.py b/moksha/api/widgets/placeholder.py
new file mode 100644
index 0000000..656580e
--- /dev/null
+++ b/moksha/api/widgets/placeholder.py
@@ -0,0 +1,11 @@
+from tw.api import Widget
+
+class Placeholder(Widget):
+ engine_name = 'mako'
+ template = """
+<div class='placeholder'>
+ Moksha application <strong>${appname}</strong> is not registered yet. This is a placeholder
+ for testing purposes. When the app is registered it will appear in the
+ layout once the server is restarted.
+</div>
+"""
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 7d9982b..e08b732 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -117,25 +117,34 @@ class App(ConfigWrapper):
:Example:
hello_app = App('Hello World App',
'/appz/moksha.helloworld',
- {'greeter_name': 'J5'},
- not_anonymous())
+ params={'greeter_name': 'J5'},
+ auth=not_anonymous())
"""
- def __init__(self, label="", url="", req_params=None, auth=None):
+ def __init__(self, label="", url="", content_id="",
+ params=None, auth=None):
"""
:label: The title the application should use when rendering
in a container. Leave this blank if you do not wish the
application to be visibly labeled when rendered
:url: the url to load this application from
- :req_params: A dict of request parameters to send to the application
- when loading it from a url
+ :content_id: the id to use for url navigation and associating the
+ content with a control such as tabs needing to know
+ which div to add the content to when selected. If
+ this is not set we scrub the label of illegal characters
+ lower case it and use that as the content_id
+ :params: A dict of request parameters to send to the application
+ when loading it from a url
:auth: A list of predicates which are evaluate before the wrapper
is sent to the container. If it evaluates to False it does not
get sent.
"""
self.label = label
self.url = url
- self.req_params = req_params or {}
+ self.params = params or {}
self.auth = auth or []
+ self.content_id = content_id
+ if self.label and not self.content_id:
+ self.content_id = scrub_filter.sub('_', self.label.lower())
def process(self):
"""Check the predicates and construct the dict
@@ -146,12 +155,13 @@ class App(ConfigWrapper):
return None
query_str = ""
- if self.req_params:
- query_str = "?" + urllib.urlencode(self.req_params)
+ if self.params:
+ query_str = "?" + urllib.urlencode(self.params)
id = uuid.uuid4()
- return {'label': self.label, 'url': self.url + query_str, 'id': id}
+ return {'label': self.label, 'url': self.url + query_str, 'id': id,
+ 'content_id': self.content_id}
class MokshaApp(App):
"""A configuration wrapper class that displays a Moksa application
@@ -163,26 +173,44 @@ class MokshaApp(App):
:Example:
hello_app = App('Hello World Moksha App',
'moksha.helloworld',
- {'greeter_name': 'J5'},
- not_anonymous())
+ params={'greeter_name': 'J5'},
+ auth=not_anonymous())
"""
-
- def __init__(self, label="", moksha_app="", req_params=None, auth=None):
+ def __init__(self, label="", moksha_app="", content_id="",
+ params=None, auth=None):
"""
:label: The title the application should use when rendering
in a container. Leave this blank if you do not wish the
application to be visibly labeled when rendered
:moksha_app: the name of the entry point registered under the
moksha.application section
- :req_params: A dict of request parameters to send to the application
- when loading it
+ :content_id: the id to use for url navigation and associating the
+ content with a control such as tabs needing to know
+ which div to add the content to when selected. If
+ this is not set we scrub the label of illegal characters
+ lower case it and use that as the content_id
+ :params: A dict of request parameters to send to the application
+ when loading it
:auth: A list of predicates which are evaluate before the wrapper
is sent to the container. If it evaluates to False it does not
get sent.
"""
# FIXME figure out how to pull auth info from an app
- super(MokshaApp, self).__init__(label, '/appz/' + moksha_app, req_params, auth)
+ self.app = moksha_app
+ super(MokshaApp, self).__init__(label,
+ '/appz/' + moksha_app,
+ content_id,
+ params, auth)
+
+ def process(self):
+ # We return a placeholder if the app is not registered
+ if not moksha._apps.has_key(self.app):
+ return MokshaWidget(self.label, 'placeholder',
+ self.content_id,
+ {'appname':self.app}, self.auth).process()
+
+ return super(MokshaApp, self).process()
class Widget(ConfigWrapper):
"""A configuration wrapper class that displays a ToscaWidget. Use this
@@ -196,16 +224,22 @@ class Widget(ConfigWrapper):
hello_widget = Widget('Hello World Widget',
HelloWidget(),
- {'greeter_name': 'J5'},
- not_anonymous())
+ params={'greeter_name': 'J5'},
+ auth=not_anonymous())
"""
- def __init__(self, label="", widget="", params=None, auth=None):
+ def __init__(self, label="", widget=None, content_id="",
+ params=None, auth=None):
"""
:label: The title the widget should use when rendering
in a container. Leave this blank if you do not wish the
widget to be visibly labeled when rendered
:widget: the ToscaWidget to be rendered
+ :content_id: the id to use for url navigation and associating the
+ content with a control such as tabs needing to know
+ which div to add the content to when selected. If
+ this is not set we scrub the label of illegal characters
+ lower case it and use that as the content_id
:params: A dict of parameters to send to the widgets update_params
method when rendering it
:auth: A list of predicates which are evaluate before the wrapper
@@ -217,13 +251,18 @@ class Widget(ConfigWrapper):
self.params = params or {}
self.auth = auth or []
+ self.content_id = content_id
+ if self.label and not content_id:
+ self.content_id = scrub_filter.sub('_', self.label.lower())
+
def process(self):
if not check_predicates(self.auth):
return None
id = uuid.uuid4()
-
- return {'label': self.label, 'widget': self.widget , 'params':self.params, 'id': id}
+ url = '#' + self.content_id
+ return {'label': self.label, 'url': url,'widget': self.widget ,
+ 'params':self.params, 'id': id, 'content_id': self.content_id}
class MokshaWidget(Widget):
"""A configuration wrapper class that displays a ToscaWidget registered
@@ -232,25 +271,33 @@ class MokshaWidget(Widget):
:Example:
hello_moksha_widget = Widget('Hello Moksha Widget',
'moksha.hello',
- {'greeter_name': 'J5'},
- not_anonymous())
+ params={'greeter_name': 'J5'},
+ auth=not_anonymous())
"""
- def __init__(self, label="", name="", params=None, auth=None):
+ def __init__(self, label="", moksha_widget="", content_id="",
+ params=None, auth=None):
"""
:label: The title the widget should use when rendering
in a container. Leave this blank if you do not wish the
widget to be visibly labeled when rendered
- :name: the name of the entry point registered under the
- moksha.widget section
+ :content_id: the id to use for url navigation and associating the
+ content with a control such as tabs needing to know
+ which div to add the content to when selected. If
+ this is not set we scrub the label of illegal characters
+ lower case it and use that as the content_id
+ :moksha_widget: the name of the entry point registered under the
+ moksha.widget section
:params: A dict of parameters to send to the widgets update_params
method when rendering it
:auth: A list of predicates which are evaluate before the wrapper
is sent to the container. If it evaluates to False it does not
get sent.
"""
- widget = moksha._widgets[name]['widget']
- super(MokshaWidget, self).__init__(label=label, widget=widget, params=params, auth=auth)
+ widget = moksha._widgets[moksha_widget]['widget']
+ super(MokshaWidget, self).__init__(label=label, widget=widget,
+ content_id=content_id, params=params,
+ auth=auth)
# setup the dictionary of acceptable callables when eval'ing predicates from
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py
index 701f7d5..aee95e0 100644
--- a/moksha/middleware/middleware.py
+++ b/moksha/middleware/middleware.py
@@ -70,8 +70,7 @@ class MokshaMiddleware(object):
self.feed_cache = Cache(self.feed_storage)
def __call__(self, environ, start_response):
- environ['paste.registry'].register(moksha.apps, self.apps)
-
+ # environ['paste.registry'].register(moksha.apps, self.apps)
# environ['paste.registry'].register(moksha._widgets, self.widgets)
environ['paste.registry'].register(moksha.feed_cache, self.feed_cache)
environ['paste.registry'].register(moksha.menus, self.menus)
@@ -148,6 +147,8 @@ class MokshaMiddleware(object):
except ImportError:
pass
+ moksha._apps = self.apps
+
def load_widgets(self):
log.info('Loading moksha widgets')
for widget_entry in pkg_resources.iter_entry_points('moksha.widget'):
diff --git a/setup.py b/setup.py
index 2f17bc3..6ae206c 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ setup(
#livegraph = moksha.examples.livegraph:LiveGraphWidget
#grid = moksha.api.widgets:Grid
ptd = moksha.widgets.misc.ptd:ProcessedTowerDefense
-
+ placeholder = moksha.api.widgets:Placeholder
[moksha.global]
# The pipeline for our live widgets
15 years, 4 months
2 commits - moksha/middleware
by John (J5) Palmieri
moksha/middleware/extensionpoint.py | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
New commits:
commit 633f93cfcee082ae517d326edd469847c90c0674
Merge: 0710ae1... dff14a2...
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed Feb 4 12:00:43 2009 -0500
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
diff --cc moksha/middleware/extensionpoint.py
index c770796,14a426e..bc75d90
--- a/moksha/middleware/extensionpoint.py
+++ b/moksha/middleware/extensionpoint.py
@@@ -71,21 -71,12 +71,22 @@@ class MokshaExtensionPointMiddleware(ob
info : {'consumes':['build_message'],
'author': 'John (J5) Palmieri <johnp(a)redhat.com>',
'version': '0.1',
- 'name': 'Hello World Message'
+ 'name': 'Hello World Message'}
"""
- def __init__(self, application, module='moksha', dir='plugins/extensions'):
+ def __init__(self, application,
+ entry_point='moksha.extension_point',
+ test_dir=None):
+ """
+ :application: WSGI application to wrap
+ :extension_point: the python extry point which specifies modules to
+ scan for JavaScript extension_points
+ :test_dir: a directory to scan for JavaScript extension_points which
+ are being tested before they are added to the module
+ """
+
log.info('Creating MokshaExtensionPointMiddleware')
+ self.application = application
# if debug is False condense javascript to optimize
self.__debug = config.get('moksha.extension_points.debug')
commit 0710ae181d5216eb726aae45a1cbe969f99246f9
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed Feb 4 11:59:33 2009 -0500
user modules as entry points to find the javascript extension point directories
diff --git a/moksha/middleware/extensionpoint.py b/moksha/middleware/extensionpoint.py
index 50d687a..c770796 100644
--- a/moksha/middleware/extensionpoint.py
+++ b/moksha/middleware/extensionpoint.py
@@ -71,18 +71,34 @@ class MokshaExtensionPointMiddleware(object):
info : {'consumes':['build_message'],
'author': 'John (J5) Palmieri <johnp(a)redhat.com>',
'version': '0.1',
- 'name': 'Hello World Message'
+ 'name': 'Hello World Message'}
"""
- def __init__(self, application, module='moksha', dir='plugins/extensions'):
+ def __init__(self, application,
+ entry_point='moksha.extension_point',
+ test_dir=None):
+ """
+ :application: WSGI application to wrap
+ :extension_point: the python extry point which specifies modules to
+ scan for JavaScript extension_points
+ :test_dir: a directory to scan for JavaScript extension_points which
+ are being tested before they are added to the module
+ """
+
log.info('Creating MokshaExtensionPointMiddleware')
# if debug is False condense javascript to optimize
self.__debug = config.get('moksha.extension_points.debug')
self.__extension_cache = {}
+ self.application = application
+
+ if test_dir:
+ self.load_extension_dir(test_dir)
- # FIXME: figure out a way to load extensions like we load entry points
- self.load_extensions(module, dir)
+ for ep in pkg_resources.iter_entry_points(entry_point):
+ mod = ep.load()
+ dir = os.path.dirname(mod.__file__)
+ self.load_extension_dir(dir)
def chunk_code(self, js, filename):
start = js.find('{')
@@ -157,9 +173,8 @@ class MokshaExtensionPointMiddleware(object):
code.append(c.code)
self.__extension_cache[exttype] = code
- def load_extensions(self, module, dir):
- real_dir = pkg_resources.resource_filename(module, dir)
- for root, dirs, files in os.walk(real_dir):
+ def load_extension_dir(self, dir):
+ for root, dirs, files in os.walk(dir):
for name in files:
if name.endswith('js'):
path = os.path.join(root, name)
15 years, 4 months