moksha/api moksha/public
by John (J5) Palmieri
moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak | 2 +-
moksha/api/widgets/selectable/templates/selectable.mak | 8 +++++---
moksha/public/javascript/ui/moksha.ui.tabs.js | 10 +++++++---
3 files changed, 13 insertions(+), 7 deletions(-)
New commits:
commit 6e240d4f1f9c4e111898d1de944c8ce3c3b8f869
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Wed Apr 22 19:06:07 2009 -0400
make tab widget more presise when selecting elements
* We were picking up all li's instead of just the tab li's so we needed
to narrow our search from the whole widget to just the tab div
* when selecting a tab deselect from our list of li's instead of
deselecting from the newly selected tab's siblings. We do this
because tabs can span multiple ul's
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
index a3991ae..9e194d0 100644
--- a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
+++ b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak
@@ -1,5 +1,5 @@
-<div id="${root_id}">
+<div id="${root_id}_tabs">
<%def name="display_category(cat)">
% if cat.get('label'):
<H4>${cat['label']}</H4>
diff --git a/moksha/api/widgets/selectable/templates/selectable.mak b/moksha/api/widgets/selectable/templates/selectable.mak
index 12d03c6..0414525 100644
--- a/moksha/api/widgets/selectable/templates/selectable.mak
+++ b/moksha/api/widgets/selectable/templates/selectable.mak
@@ -1,12 +1,14 @@
<div class="links" id="${content_id}">
% for i, c in enumerate(categories):
- <h4>
+ % if c['label']:
+ <h4>
${c['label']}
- </h4>
+ </h4>
+ % endif
<ul>
% for j, item in enumerate(c['items']):
<li>
- <a id="${content_id}_${i}_${j}" href="${item['link']}" >${item['label']}</a>
+ <a id="${content_id}_${i}_${j}" href="javascript:moksha.goto('${item['link']}')" >${item['label']}</a>
% if 'data' in item:
<script type="text/javascript">
<%
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js
index 649624c..afa27df 100644
--- a/moksha/public/javascript/ui/moksha.ui.tabs.js
+++ b/moksha/public/javascript/ui/moksha.ui.tabs.js
@@ -61,7 +61,10 @@ $.widget("ui.mokshatabs", {
},
tabify: function(init) {
- this.$lis = $('ul li:has(>a[href])', this.element);
+ var tab_id = this.element.attr('id') + '_tabs';
+ this.$lis = $('#' + tab_id + ' ul li:has(>a[href])', this.element);
+ console.log(this.$lis)
+ console.log(this.element);
this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
this.$panels = $([]);
@@ -263,8 +266,9 @@ $.widget("ui.mokshatabs", {
/*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
$.ajaxHistory.update(clicked.hash);
}*/
- $li.addClass(o.selectedClass)
- .siblings().removeClass(o.selectedClass);
+
+ self.$lis.removeClass(o.selectedClass);
+ $li.addClass(o.selectedClass);
hideTab(clicked, $hide, $show);
}
15 years, 1 month
2 commits - moksha/api moksha/lib moksha/public
by John (J5) Palmieri
moksha/api/widgets/containers/templates/dashboardcontainer.mak | 4
moksha/lib/helpers.py | 53 ++++++++--
moksha/public/javascript/moksha.js | 23 +++-
3 files changed, 67 insertions(+), 13 deletions(-)
New commits:
commit 0571e9b586f5e77b72ea50115b2236e3e89803c7
Merge: ae0e089... c4f7802...
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 21 22:29:38 2009 -0400
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
commit ae0e0893d6a5b92d3d11e98c9bb81aa0c9403664
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 21 22:28:15 2009 -0400
fix handling and checking of multiple query key values
diff --git a/moksha/api/widgets/containers/templates/dashboardcontainer.mak b/moksha/api/widgets/containers/templates/dashboardcontainer.mak
index a9042da..d55435d 100644
--- a/moksha/api/widgets/containers/templates/dashboardcontainer.mak
+++ b/moksha/api/widgets/containers/templates/dashboardcontainer.mak
@@ -4,8 +4,4 @@
${applist_widget(category=c)}
% endfor
</div>
-
- <div id="overlay">
- <div id="preloader"><img src="/toscawidgets/resources/moksha.widgets.layout.layout/static/loader.gif" alt="" /></div>
- </div>
</div>
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 01cc726..2abe9ca 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -43,8 +43,7 @@ def _update_params(params, d):
value = _update_params(value, d)
value = json.dumps(value)
elif isinstance(value, list):
- # FIXME: This should be recursive
- value = json.dumps(value)
+ value = value
if value != None:
p[k] = value
@@ -273,14 +272,23 @@ class App(ConfigWrapper):
def _create_query_string(self, params):
qlist = []
for k, i in params.iteritems():
- s = str(i)
- s = urllib.quote_plus(s)
+ if isinstance(i, (list, tuple)):
+ # break out lists into multiple entries of the same key
+ for j in i:
+ s = str(j)
+ s = urllib.quote_plus(s)
+ qlist.append("%s=%s" % (k, s))
+
+ else:
+ s = str(i)
+ s = urllib.quote_plus(s)
- qlist.append("%s=%s" % (k, s))
+ qlist.append("%s=%s" % (k, s))
result = ""
if qlist:
result = '?' + '&'.join(qlist)
+
return result
def process(self, d=None):
@@ -491,12 +499,43 @@ class MokshaWidget(Widget):
auth=auth,
css_class=css_class)
+class param_contains(Predicate):
+ """
+ Checks the parameters of the environment and return True if the
+ parameter contains the value specified. If the parameter is a list
+ (more than one value) then check each item in the list.
+ Note this is the environment params (query string and post file) not the TG
+ or ToscaWidget param dicts
+ """
+ message = u'Parameter "%(param)s" is does not contain value "%(value)s"'
+
+ def __init__(self, param, value, **kwargs):
+ super(param_contains, self).__init__(**kwargs)
+ self.param = param
+ self.value = value
+
+ def evaluate(self, environ, credentials):
+ req = Request(environ)
+ p = req.params.getall(self.param)
+
+ if not p:
+ return self.unmet(param = self.param, value = self.value)
+
+ print p
+ for v in p:
+ print v, '==', self.value
+ if v == self.value:
+ return
+
+ return self.unmet(param = self.param, value = self.value)
+
class param_has_value(Predicate):
"""
Checks the parameters of the environment and return True if the
- parameter specified holds a value
+ parameter specified holds a value. Note this is the environment params
+ (query string and post file) not the TG or ToscaWidget param dicts
"""
- message = u'Parameter "%s(param)" is not set'
+ message = u'Parameter "%(param)s" is not set'
def __init__(self, param, empty_str_is_valid = False, **kwargs):
super(param_has_value, self).__init__(**kwargs)
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js
index 0cd73d8..eaeca92 100644
--- a/moksha/public/javascript/moksha.js
+++ b/moksha/public/javascript/moksha.js
@@ -276,7 +276,15 @@ moksha = {
var qlist = []
for (q in this.queryKey) {
- qlist.push(q + '=' + this.queryKey[q]);
+ var value = this.queryKey[q]
+ if (typeof(value) == 'string') {
+ qlist.push(q + '=' + value);
+ } else {
+ // must be a list, break up into seperate query elements
+ for (i in value) {
+ qlist.push(q + '=' + value[i]);
+ }
+ }
}
var query = qlist.join('&')
@@ -298,7 +306,18 @@ moksha = {
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
- if ($1) uri[o.q.name][$1] = $2;
+ if ($1) {
+ var value = uri[o.q.name][$1];
+ if (value) {
+ if (typeof(value) === 'string')
+ value = [value];
+
+ value.push($2);
+ uri[o.q.name][$1] = value;
+ } else {
+ uri[o.q.name][$1] = $2;
+ }
+ }
});
return uri;
15 years, 1 month
5 commits - docs/main moksha/lib moksha/public
by Luke Macken
docs/main/Features.rst | 33 +++++++++---------
docs/main/MessageBrokers.rst | 2 +
docs/main/Middleware.rst | 28 +++++++++++++++
docs/main/MokshaPlatform.rst | 31 -----------------
docs/main/Technology.rst | 5 ++
docs/main/Vision.rst | 1
moksha/lib/app_globals.py | 39 +++++++---------------
moksha/public/images/Powered-by-moksha_button.png |binary
8 files changed, 64 insertions(+), 75 deletions(-)
New commits:
commit c4f78029c76505fface19946d971d807cd858712
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 23:33:03 2009 -0400
Document the role that Twisted plays in the stack
diff --git a/docs/main/Technology.rst b/docs/main/Technology.rst
index 4c6ac63..f17cda6 100644
--- a/docs/main/Technology.rst
+++ b/docs/main/Technology.rst
@@ -75,3 +75,8 @@ receives, stores, and routes messages using the AMQP protocol. `RHM
<http://rhm.et.redhat.com/>`_ is a persistence extension to the Qpid AMQP
broker that allows message storage using either a libaio-based asynchronous
journal or synchronously with Berkely DB. -
+
+`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`.
commit 627afd7be71c30faf0fbf9208a27c6f9ed39f75e
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 23:27:27 2009 -0400
Fix some inter-doc sphinx linkage
diff --git a/docs/main/Features.rst b/docs/main/Features.rst
index 8088b94..fab5ea5 100644
--- a/docs/main/Features.rst
+++ b/docs/main/Features.rst
@@ -40,9 +40,7 @@ reusable "Widgets", which are essentially just bundles of HTML, JavaScript,
CSS, and render-time logic. The ToscaWidgets WSGI Middleware is also integrated
into Moksha, which handles intelligently injecting Widget resources.
-Moksha also provides a variety of other Widgets, including a LiveWidget_ API
-for creating real-time message-driven widgets that can efficiently acquire data
-from a variety of sources.
+Moksha also provides a variety of other Widgets, including a :doc:`LiveWidget` API for creating real-time message-driven widgets that can publish and subscribe to message :doc:`Topics`.
Resource Connectors
-------------------
@@ -59,19 +57,20 @@ infrastructure environments.
Expert System
--------------
-The MokshaHub_ gives you Expert System-like functionality by providing APIs for
-interacting with a variety of knowledge bases (SQLAlchemy models, Resource
-Connectors, Caches, Message Queues, etc), and can easily monitor and 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 DataStreamers_ 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 FeedStream_, that automatically handles fetching, parsing, caching, and
-sending notifications for all known feeds at a regular interval.
-
-These are loaded by the MokshaHub_, and are executed outside of the WSGI
+:doc:`MokshaHub` gives you Expert System-like functionality by providing
+APIs for interacting with a variety of knowledge bases (SQLAlchemy models,
+Resource Connectors, Caches, Message Queues, etc), and can easily monitor and
+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
+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,
+parsing, caching, and sending notifications for all known feeds at a regular
+interval.
+
+These are loaded by :doc:`MokshaHub`, and are executed outside of the WSGI
application stack, but they are still able to access the Database, Cache,
MessageHub, etc.
diff --git a/docs/main/MessageBrokers.rst b/docs/main/MessageBrokers.rst
index 92ad2ed..c61452c 100644
--- a/docs/main/MessageBrokers.rst
+++ b/docs/main/MessageBrokers.rst
@@ -33,3 +33,5 @@ The :class:`MokshaHub` will then automatically connect up to your AMQP broker an
AMQP support in Moksha has been tested with `Qpid <http://qpid.apache.org>`_.
+
+`RabbitMQ <http://rabbitmq.com>`_ support is under development. See the :doc:`RabbitMQ` documentation for details on testing it.
commit 1ecf12a22c32adfa8308900090cb3222d5b238fb
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 23:23:11 2009 -0400
Move some of our WSGI middleware docs around
diff --git a/docs/main/Middleware.rst b/docs/main/Middleware.rst
index 41ecaa5..bed47a5 100644
--- a/docs/main/Middleware.rst
+++ b/docs/main/Middleware.rst
@@ -45,3 +45,31 @@ how it looks in TurboGears2. If you're using Moksha as a stand-alone platform,
TurboGears2 allows us to easily insert middleware directly on top of the raw
application, so we then have the ability to use the paste.registry,
sessions, and caching.
+
+Moksha's Full Platform WSGI Stack
+---------------------------------
+
+Not only can Moksha be inserted into any existing `WSGI <http://wsgi.org>`_-compliant application,
+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
+=============================== ===============
diff --git a/docs/main/MokshaPlatform.rst b/docs/main/MokshaPlatform.rst
deleted file mode 100644
index ab5cb56..0000000
--- a/docs/main/MokshaPlatform.rst
+++ /dev/null
@@ -1,31 +0,0 @@
-===============
-Moksha Platform
-===============
-
-Not only can Moksha be inserted into any existing WSGI-compliant application,
-but on it's own offers a comprehensive top-to-bottom middleware stack that
-provides a vast plethora of additional functionality.
-
-`WSGI <http://wsgi.org>`_ Middleware Stack
-------------------------------------------
-
-=============================== ===============
-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
-=============================== ===============
diff --git a/docs/main/Vision.rst b/docs/main/Vision.rst
index b3b031c..28738f1 100644
--- a/docs/main/Vision.rst
+++ b/docs/main/Vision.rst
@@ -5,7 +5,6 @@ The Vision
:maxdepth: 2
Introduction
- MokshaPlatform
DataAggregation
DataInterpretation
DataPersistence
commit 8eea13943408671927db2eba6e32952e75b96506
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 23:10:31 2009 -0400
Add a powered by moksha icon, thanks to Mizmo :)
diff --git a/moksha/public/images/Powered-by-moksha_button.png b/moksha/public/images/Powered-by-moksha_button.png
new file mode 100644
index 0000000..7818754
Binary files /dev/null and b/moksha/public/images/Powered-by-moksha_button.png differ
commit dfb22cc24630628fa7898f08bb3c911bd5d3ed29
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 22:47:49 2009 -0400
Dumb down our globals object.
Comment out some experimental functionality that are not currently using.
diff --git a/moksha/lib/app_globals.py b/moksha/lib/app_globals.py
index e665e71..ccd1da8 100644
--- a/moksha/lib/app_globals.py
+++ b/moksha/lib/app_globals.py
@@ -1,16 +1,15 @@
"""The application's Globals object"""
-import logging
-import inspect
+#import logging
+#import inspect
-from tg import config
-from shove import Shove
+#from tg import config
+#from shove import Shove
-from moksha.exc import CacheBackendException
-from moksha.lib.cache import Cache
+#from moksha.exc import CacheBackendException
+#from moksha.lib.cache import Cache
-
-log = logging.getLogger(__name__)
+#log = logging.getLogger('moksha')
class Globals(object):
"""Globals acts as a container for objects available throughout the
@@ -22,21 +21,9 @@ class Globals(object):
initialization and is available during requests via the 'g'
variable
"""
- timeout = int(config.get('beaker.cache.timeout', '0'))
- try:
- self.cache = Cache(config['beaker.cache.url'], timeout)
- except (CacheBackendException, KeyError), e:
- log.warning(str(e))
- self.cache = None
-
- #def __getattribute__(self, *args, **kw):
- # # @@ TODO: Namespace moksha app's Global objects
- # # load them in the middlware...
- # # ensure that this object is always in pylons.g, even if we are
- # # running a full moksha stack, or as middleware
- # # proxy to them on incoming request
- # print "Globals.__getattr__(%s)" % locals()
- # frame = inspect.currentframe()
- # caller = frame.f_back.f_back.f_globals['__name__']
- # print "caller = ", caller
- # return object.__getattribute__(self, *args, **kw)
+ #timeout = int(config.get('beaker.cache.timeout', '0'))
+ #try:
+ # self.cache = Cache(config['beaker.cache.url'], timeout)
+ #except (CacheBackendException, KeyError), e:
+ # log.warning(str(e))
+ # self.cache = None
15 years, 1 month
moksha/middleware
by John (J5) Palmieri
moksha/middleware/csrf.py | 51 +++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 16 deletions(-)
New commits:
commit 3251b70579662a9f53cde4c7ca634d9743eb3010
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 20 19:04:05 2009 -0400
fix how we append the csrf token during login so we don't munch the query string
diff --git a/moksha/middleware/csrf.py b/moksha/middleware/csrf.py
index ddab4e1..d107eb2 100644
--- a/moksha/middleware/csrf.py
+++ b/moksha/middleware/csrf.py
@@ -32,16 +32,45 @@ from paste.httpexceptions import HTTPFound
from paste.request import parse_formvars, parse_dict_querystring
from paste.response import replace_header
from urlparse import urlparse, urlunparse
+from urllib import urlencode
from repoze.who.interfaces import IMetadataProvider
from zope.interface import implements
try:
+ from urlparse import parse_qs
+except:
+ from cgi import parse_qs
+
+try:
from hashlib import sha1
except ImportError:
from sha import sha as sha1
log = logging.getLogger(__name__)
+def update_qs(uri, d):
+ """
+ Helper function for updating query string values. Similar to calling
+ update on a dictionary except we modify the query string of the uri
+ instead of another dictionary.
+ """
+ loc = list(urlparse(uri))
+ query_dict = parse_qs(loc[4])
+ query_dict.update(d)
+
+ # seems that we have to sanitize a bit here
+ query_list = []
+ for k, v in query_dict.items():
+ if isinstance(v, list):
+ for item in v:
+ query_list.append((k, item))
+ else:
+ query_list.append((k, v))
+
+ loc[4] = urlencode(query_list)
+
+ return urlunparse(loc)
+
class CSRFProtectionMiddleware(object):
"""
CSRF Protection WSGI Middleware.
@@ -153,14 +182,9 @@ class CSRFProtectionMiddleware(object):
if environ.get(self.auth_state):
log.debug("CSRF_AUTH_STATE; rewriting headers")
token = environ.get('repoze.who.identity', {}).get(self.csrf_token_id)
- path = []
- for part in urlparse(response.location):
- if part.startswith(self.csrf_token_id):
- path.append('')
- else:
- path.append(part)
- path[4] += self.csrf_token_id + '=' + token
- response.location = urlunparse(path)
+
+ loc = update_qs(response.location, {self.csrf_token_id: str(token)})
+ response.location = loc
log.debug("response.location = %s" % response.location)
environ[self.auth_state] = None
@@ -254,14 +278,9 @@ class CSRFMetadataProvider(object):
# This occurs during login in some application configurations
if isinstance(app, HTTPFound) and environ.get(self.auth_state):
log.debug('Got HTTPFound(302) from repoze.who.application')
- path = []
- for part in urlparse(app.location()):
- if part.startswith(self.csrf_token_id):
- path.append('')
- else:
- path.append(part)
- path[4] += self.csrf_token_id + '=' + str(token)
- replace_header(app.headers, 'location', urlunparse(path))
+ loc = update_qs(app.location(), {self.csrf_token_id: str(token)})
+
+ replace_header(app.headers, 'location', loc)
log.debug('Altered headers: %s' % str(app.headers))
else:
log.warning("Invalid session cookie %r, not setting CSRF token!" %session_id)
15 years, 1 month
moksha/public
by John (J5) Palmieri
moksha/public/javascript/ui/moksha.ui.grid.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit c99adf19356118cbe7fcf2c84e9dc6aba327e89c
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 20 17:54:12 2009 -0400
don't use extensions if the scripts have not been loaded
diff --git a/moksha/public/javascript/ui/moksha.ui.grid.js b/moksha/public/javascript/ui/moksha.ui.grid.js
index c685716..f373eee 100644
--- a/moksha/public/javascript/ui/moksha.ui.grid.js
+++ b/moksha/public/javascript/ui/moksha.ui.grid.js
@@ -105,7 +105,8 @@
$new_row.show();
// run any included extension points
- moksha.extensions.grep_extensions($new_row);
+ if (moksha.extensions)
+ moksha.extensions.grep_extensions($new_row);
},
append_row: function(row_data) {
15 years, 1 month
2 commits - moksha/connector
by John (J5) Palmieri
moksha/connector/connector.py | 4 +-
moksha/connector/utils.py | 68 ++++++++++++++++++++++--------------------
2 files changed, 39 insertions(+), 33 deletions(-)
New commits:
commit fb784ac85adc5e61d86dabb5da8aabba3f81fe25
Merge: aa1e1e0... 477e247...
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 20 17:41:59 2009 -0400
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
commit aa1e1e0ef3e2fbb111071920521d9281b01bc71f
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 20 17:41:18 2009 -0400
fixed weighting algorythm
diff --git a/moksha/connector/connector.py b/moksha/connector/connector.py
index 9c47a9d..a1f9522 100644
--- a/moksha/connector/connector.py
+++ b/moksha/connector/connector.py
@@ -352,10 +352,10 @@ class ISearch(IQuery):
cls._query_paths[path]['columns'],
cls._search_cache)
search_string = cls.filters.filter(filters).get('search')
- results = s.search(search_string)
+ results = s.search(search_string, primary_key_col, start_row, rows_per_page)
- return (len(results), results[start_row:start_row + rows_per_page])
+ return results
qpath = cls.register_query(path = path,
query_func = query_func,
diff --git a/moksha/connector/utils.py b/moksha/connector/utils.py
index 7192576..a49813b 100644
--- a/moksha/connector/utils.py
+++ b/moksha/connector/utils.py
@@ -260,41 +260,41 @@ class WeightedSearch(object):
self.cache = cache
self.cols = cols
- def weigh(self, search_term, weighted_hash):
+ def weigh(self, search_term, weighted_item):
search_term_len = len(search_term)
- l = len(self.cols)
+ col_count = len(self.cols)
# each field gets a decelerating percentage of it's calculated weight
# e.g. each consecutive field is an order of magnatude less important
# than the previous field
- factor = 1/sum(xrange(l))
+ factor = 1.0/float(sum(xrange(1, col_count+1)))
- r = weighted_hash[0]
- for i, result_field in enumerate(self.cols):
- x = l - i
- weight_factor = x * factor
+ item = weighted_item[0]
+ for i, col_label in enumerate(self.cols):
+ x = col_count - i
+ weight_factor = float(x) * factor
- l_result_field = r.get(result_field, '')
- if not isinstance(l_result_field, basestring):
- l_result_field = ''
+ col_value = item.get(col_label, '')
+ if not isinstance(col_value, basestring):
+ col_value = ''
else:
- l_result_field.lower()
+ col_value = col_value.lower()
- index = l_result_field.find(search_term)
+ index = col_value.find(search_term)
while(index != -1):
- weighted_hash[1] += self.LIGHT_WEIGHT * weight_factor
+ weighted_item[1] += self.LIGHT_WEIGHT * weight_factor
if index == 0:
# in front
- weighted_hash[1] += self.MEDIUM_WEIGHT * weight_factor
- if search_term_len == len(l_result_field):
- weighted_hash[1] += self.HEAVY_WEIGHT
+ weighted_item[1] += self.MEDIUM_WEIGHT * weight_factor
+ if search_term_len == len(col_value):
+ weighted_item[1] += self.HEAVY_WEIGHT
- if index + search_term_len == l:
+ if index + search_term_len == len(col_value):
# in back
- weighted_hash[1] += self.MEDIUM_WEIGHT * weight_factor
+ weighted_item[1] += self.MEDIUM_WEIGHT * weight_factor
- index = l_result_field.find(search_term, index + 1)
+ index = col_value.find(search_term, index + 1)
def weighted_sort(self, a, b):
result = 0
@@ -306,41 +306,47 @@ class WeightedSearch(object):
result = cmp(a_val[self.cols.key_index(0)], b_val[self.cols.key_index(0)])
return result
- def search(self, search_string):
+ def search(self, search_string, primary_key_col, start_row, rows_per_page):
if not search_string:
return []
search = search_string.lower().replace(',', ' ').split()
+ if not primary_key_col:
+ primary_key_col = self.cols.key_index(0)
+
weighted_results = {}
+ raw_search = []
for s in search:
results = self.cache.get_value(key = s,
createfunc=lambda : self.search_func(s),
type="memory",
expiretime=self.CACHE_EXPIRE_TIME)
+ if results:
+ raw_search.extend(results)
- for r in results:
- rkey = r[self.cols.key_index(0)]
-
+ for s in search:
+ for r in raw_search:
+ id = r[primary_key_col]
# if we have already weighted this result get the
# weighted hash to add weight to
# else we create a new weighted hash
- if rkey in weighted_results:
- weighted_hash = weighted_results[rkey]
+ if id in weighted_results:
+ weighted_item = weighted_results[id]
else:
- weighted_hash = [r, 0]
-
+ weighted_item = [r, 0]
- self.weigh(s, weighted_hash)
- weighted_results[rkey] = weighted_hash
+ self.weigh(s, weighted_item)
+ weighted_results[id] = weighted_item
sorted_list = weighted_results.values()
sorted_list.sort(self.weighted_sort)
for i, v in enumerate(sorted_list):
- sorted_list[i] = v[0]
+ if v[0] > 0:
+ sorted_list[i] = v[0]
- return sorted_list
+ return (len(sorted_list), sorted_list[start_row:start_row + rows_per_page])
15 years, 1 month
moksha/api
by Luke Macken
moksha/api/widgets/moksha.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
New commits:
commit 477e247b85d968b70ffdb5332a43b2795761378d
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 12:46:14 2009 -0400
Ensure we use 'asbool' when pulling values from the pylons.config
diff --git a/moksha/api/widgets/moksha.py b/moksha/api/widgets/moksha.py
index c1990d1..b592bde 100644
--- a/moksha/api/widgets/moksha.py
+++ b/moksha/api/widgets/moksha.py
@@ -58,15 +58,14 @@ moksha_profile = ${profile};
def update_params(self, d):
super(MokshaGlobals, self).update_params(d)
- if pylons.config.get('debug'):
- d['debug'] = 'true'
+ d['base_url'] = tg.url('/')
- if pylons.config['global_conf'].get('profile'):
+ if asbool(pylons.config.get('debug')):
+ d['debug'] = 'true'
+ if asbool(pylons.config['global_conf'].get('profile')):
d['profile'] = 'true'
- d['base_url'] = tg.url('/')
identity = pylons.request.environ.get('repoze.who.identity')
-
if identity:
d['csrf_token'] = identity.get(self.csrf_token_id, '')
d['user_id'] = identity.get('user_id', '')
15 years, 2 months
moksha/api
by Luke Macken
moksha/api/widgets/moksha.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
New commits:
commit ba961f7dd3995cd5d1dcbb8a1b80baddeca78e9f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Apr 20 12:40:09 2009 -0400
Only add the extension point javascript to the moksha global if it is enabled
diff --git a/moksha/api/widgets/moksha.py b/moksha/api/widgets/moksha.py
index 7115b2f..c1990d1 100644
--- a/moksha/api/widgets/moksha.py
+++ b/moksha/api/widgets/moksha.py
@@ -16,19 +16,22 @@
# Copyright 2008, Red Hat, Inc.
# Authors: John (J5) Palmieri <johnp(a)redhat.com>
-from tw.jquery import jquery_js
-from tw.api import JSLink
-from tw.api import Widget
import tg
import pylons
+from tw.api import JSLink
+from tw.api import Widget
+from tw.jquery import jquery_js
+from paste.deploy.converters import asbool
+
moksha_js = JSLink(modname="moksha", filename='public/javascript/moksha.js',
javascript=[jquery_js])
-moksha_extension_points_js = JSLink(modname="moksha", filename='public/javascript/moksha.extensions.js',
- javascript=[moksha_js])
+moksha_extension_points_js = JSLink(modname="moksha",
+ filename='public/javascript/moksha.extensions.js',
+ javascript=[moksha_js])
class MokshaGlobals(Widget):
- javascript = [moksha_js, moksha_extension_points_js]
+ javascript = [moksha_js]
template = """<script type="text/javascript">
moksha_base_url = "${base_url}";
moksha_csrf_token = "${csrf_token}";
@@ -49,6 +52,8 @@ moksha_profile = ${profile};
def __init__(self, *args, **kw):
super(MokshaGlobals, self).__init__(*args, **kw)
self.csrf_token_id = tg.config.get('moksha.csrf.token_id', '_csrf_token')
+ if asbool(tg.config.get('moksha.extensionpoints', False)):
+ self.javascript.append(moksha_extension_points_js)
def update_params(self, d):
super(MokshaGlobals, self).update_params(d)
15 years, 2 months
docs/main
by Luke Macken
docs/main/DataAggregation.rst | 8 +++++++-
docs/main/DataInterpretation.rst | 6 +++---
docs/main/Introduction.rst | 29 ++++++++---------------------
3 files changed, 18 insertions(+), 25 deletions(-)
New commits:
commit daa69859b11d8aaa7a03db97fa2fe3fb8e51806e
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Apr 18 16:05:40 2009 -0400
Some documentation tweaks
diff --git a/docs/main/DataAggregation.rst b/docs/main/DataAggregation.rst
index 93d14aa..46990a5 100644
--- a/docs/main/DataAggregation.rst
+++ b/docs/main/DataAggregation.rst
@@ -7,7 +7,11 @@ Moksha provides many ways to acquire data in an efficient manner.
Messaging layer
---------------
-Moksha can communicate with various message brokers, using the `AMQP <http://amqp.org>`_ and/or `STOMP <http://stomp.codehaus.org/Protocol>`_ protocols. It also provides a simple API for sending and consuming messages, as well as allowing widgets to subscribe to live messages streams within the users web browser.
+Moksha can communicate with various message brokers, using the `AMQP
+<http://amqp.org>`_ and/or `STOMP <http://stomp.codehaus.org/Protocol>`_
+protocols. It also provides a simple API for producing and consuming messages,
+as well as allowing widgets to subscribe to live messages streams within the
+users web browser.
Caching layer
-------------
@@ -16,6 +20,8 @@ A flexible caching layer is available to all Moksha widgets and applications.
This middleware is setup by TurboGears2, and trivializes the act of caching
expensive operations.
+Moksha also provides recipies for integrating with nginx & memcached.
+
Resource layer
--------------
diff --git a/docs/main/DataInterpretation.rst b/docs/main/DataInterpretation.rst
index 9b17b20..3ab2fa0 100644
--- a/docs/main/DataInterpretation.rst
+++ b/docs/main/DataInterpretation.rst
@@ -2,7 +2,8 @@
Data Interpretation
===================
-Moksha provides various mechanisms that allows applications to easily interpret dynamic data, along with adding additional functionality to it.
+Moksha provides various mechanisms that allows applications to easily interpret
+dynamic data, along with adding additional functionality to it.
Collaborative glue
------------------
@@ -14,7 +15,7 @@ Live streams
------------
Any data source, even if moksha has to occasionally poll it, can be displayed
-as a 'live' widget on any web site. Data streams can also easily expose
+as a 'live' widget. "Data streams", or Producers, can also easily expose
themselves through an AMQP or STOMP message queue, allowing other applications
and services to interact with new data, as it is discovered.
@@ -31,4 +32,3 @@ Gives developers the ability to add additional functionality to predictable
patterns found within dynamic data streams. For example, an extension point
could find all occurences of known project names within a data feed, and easily
turn them into a dynamic hover menu that could display related data.
-
diff --git a/docs/main/Introduction.rst b/docs/main/Introduction.rst
index c2e171c..100b1ac 100644
--- a/docs/main/Introduction.rst
+++ b/docs/main/Introduction.rst
@@ -3,9 +3,9 @@ What is Moksha?
A Platform
~~~~~~~~~~
-A highly scalable platform for creating, running, and wielding dashboards of
-live collaborative widgets that extract and extend data from arbitrary
-resources in an intelligent and efficient manner.
+A highly scalable platform for creating dashboards of live collaborative
+widgets. Moksha makes it simple for these widgets to extract and extend data
+from arbitrary resources in an intuitive and efficient manner.
A Framework
~~~~~~~~~~~
@@ -15,27 +15,14 @@ applications. It is designed to allow non-developers to easily develop
applications in isolation, without worrying about the under/over-lying software
stack.
-A Language
-~~~~~~~~~~
-A language for creating powerful reusable widgets that communicate with a
-variety of external resources and can be displayed and collaborated upon in
-real-time, turning every page into a live social dashboard.
+An Architecture
+~~~~~~~~~~~~~~~
+Moksha brings many existing technologies together to create a next-generation
+web architecture that is designed to simplify the creation of create rich,
+powerful, live web applications that can easily bridge existing services.
A Hub
~~~~~
Moksha also acts as a live notification hub that allows people and other
applications and services to create, publish, and subscribe to arbitrary
message streams.
-
-A Community
-~~~~~~~~~~~
-Gives people the ability to create adhoc groups based around any
-project/idea/initiative/location. It facilitates live interactive discourse,
-by default, and ensures that every voice is heard.
-
-A Mentor
-~~~~~~~~~
-Moksha will also facilitate collaboration around various tasks, projects,
-ideas, etc, could maintain state for various workflow processes. Since it will
-be aware of all of it's sub-communities, it could potentially delegate tasks to
-teams or users based on the skills required to complete the task, while providing guidance along the way to help achieve goals.
15 years, 2 months
8 commits - moksha/api moksha/public
by Máirín Duffy
moksha/api/widgets/containers/templates/tabbedcontainer.mak | 2 +-
moksha/public/javascript/ui/moksha.ui.grid.js | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
New commits:
commit 9fb2f2d4acc4693f496f15bab8ac8ffdb4830ff5
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Fri Apr 17 17:04:42 2009 -0400
fixing wrong css class in pager
diff --git a/moksha/public/javascript/ui/moksha.ui.grid.js b/moksha/public/javascript/ui/moksha.ui.grid.js
index b71e5fa..c685716 100644
--- a/moksha/public/javascript/ui/moksha.ui.grid.js
+++ b/moksha/public/javascript/ui/moksha.ui.grid.js
@@ -403,9 +403,9 @@
for (i in alph) {
var a = alph[i];
- var page = $('<li />').html(a).addClass('page-button').addClass('current-button');
+ var page = $('<li />').html(a).addClass('page-button').addClass('current-page');
if (a!=curr_alpha) {
- page.removeClass('current-button');
+ page.removeClass('current-page');
var page_link = $('<a href="javascript:void(0)"></a>').html(a);
page_link.data('alpha_page.moksha_grid', a);
@@ -605,4 +605,4 @@ $.extend( $.template.helpers , {
);
-})(jQuery);
\ No newline at end of file
+})(jQuery);
commit 6ec2a1141eb179fc2e882061e818742950b2a2db
Merge: d4a107d... a74b20f...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Fri Apr 17 14:11:10 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit d4a107d1f635e8f783e68988dfbdafb5c753281f
Merge: 172b8a3... ae0f12d...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Fri Apr 17 09:35:57 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit 172b8a367ade6ab5b307c0656df3ed76e99bc864
Merge: 534beac... 9541ef7...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Thu Apr 16 09:48:26 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit 534beac114b4332fb2822863818664eefa5076db
Merge: 1cce912... 0b5c829...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Wed Apr 15 14:17:45 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit 1cce9125adb6bc6e78144933861b88169d07371a
Merge: 3b2fcdd... 84844a1...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Tue Apr 14 14:54:26 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit 3b2fcdd029389ca9266f2e5764fbc8b09ab18650
Merge: f1ee0c0... f1e9417...
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Tue Apr 14 09:31:47 2009 -0400
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/moksha
commit f1ee0c014344814595656e8a3ec74ba2210abc32
Author: Máirín Duffy <duffy(a)redhat.com>
Date: Mon Apr 13 17:48:41 2009 -0400
fixing some issues with sidebars getting cut off by header
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer.mak b/moksha/api/widgets/containers/templates/tabbedcontainer.mak
index 22a27f5..32b964a 100644
--- a/moksha/api/widgets/containers/templates/tabbedcontainer.mak
+++ b/moksha/api/widgets/containers/templates/tabbedcontainer.mak
@@ -8,4 +8,4 @@
</li>
% endfor
</ul>
-</div>
\ No newline at end of file
+</div>
15 years, 2 months