moksha/api/widgets/live/live.py | 2 +-
moksha/api/widgets/stomp/stomp.py | 21 +++++++++++++++------
moksha/commands/quickstart.py | 2 +-
3 files changed, 17 insertions(+), 8 deletions(-)
New commits:
commit 8b988440deea71d81ee280df74e049579de2bff4
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Oct 12 18:53:00 2009 -0400
An important LiveWidget improvement.
This allows for more than one Moksha Socket to be rendered at the same time on
a page without them stepping on eachother. I hit a problem in Fedora
Community when 1 socket would be requesting the orbited.js, and another socket
is trying to use the Stomp connection.
This patch will make the socket detect if the other is busy, and it will queue
up it's callbacks for when the `moksha.socket_ready` event is triggered.
diff --git a/moksha/api/widgets/stomp/stomp.py b/moksha/api/widgets/stomp/stomp.py
index f0ac2b4..29b4772 100644
--- a/moksha/api/widgets/stomp/stomp.py
+++ b/moksha/api/widgets/stomp/stomp.py
@@ -76,6 +76,7 @@ class StompWidget(Widget):
<script type="text/javascript">
if (typeof TCPSocket == 'undefined') {
moksha_callbacks = new Object();
+ moksha_socket_busy = false;
}
## Register our topic callbacks
@@ -85,12 +86,13 @@ class StompWidget(Widget):
moksha_callbacks[topic] = [];
}
moksha_callbacks[topic].push(function(json, frame) {
- ${onmessageframe[topic]};
+ ${onmessageframe[topic]}
});
% endfor
if (typeof TCPSocket == 'undefined') {
document.domain = document.domain;
+ moksha_socket_busy = true;
$.getScript("${orbited_url}/static/Orbited.js", function(){
Orbited.settings.port = ${orbited_port};
Orbited.settings.hostname = '${orbited_host}';
@@ -103,7 +105,11 @@ class StompWidget(Widget):
stomp.onclose = ${onclose};
stomp.onerror = ${onerror};
stomp.onerrorframe = ${onerrorframe};
- stomp.onconnectedframe = function(){ ${onconnectedframe} };
+ stomp.onconnectedframe = function(){
+ moksha_socket_busy = false;
+ $('body').triggerHandler('moksha.socket_ready');
+ ${onconnectedframe}
+ };
stomp.onmessageframe = function(f){
var dest = f.headers.destination;
var json = $.secureEvalJSON(f.body);
@@ -116,13 +122,18 @@ class StompWidget(Widget):
stomp.connect('${stomp_host}', ${stomp_port},
'${stomp_user}', '${stomp_pass}');
-
});
});
} else {
## Utilize the existing stomp connection
- ${onconnectedframe}
+ if (moksha_socket_busy) {
+ $('body').bind('moksha.socket_ready', function() {
+ ${onconnectedframe}
+ });
+ } else {
+ ${onconnectedframe}
+ }
}
window.onbeforeunload = function() {
commit ee7e25729087987de993475aead7b70d8a377bce
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Oct 12 18:52:34 2009 -0400
Remove some commented out code that is no longer necessary
diff --git a/moksha/api/widgets/stomp/stomp.py b/moksha/api/widgets/stomp/stomp.py
index 3389176..f0ac2b4 100644
--- a/moksha/api/widgets/stomp/stomp.py
+++ b/moksha/api/widgets/stomp/stomp.py
@@ -58,8 +58,6 @@ class StompWidget(Widget):
callbacks = ['onopen', 'onerror', 'onerrorframe',
'onclose',
'onconnectedframe', 'onmessageframe']
javascript = [jquery_json_js]
- #javascript = [stomp_js, orbited_js]
- #children = [stomp_js, orbited_js]
params = callbacks[:] + ['topics', 'notify', 'orbited_host',
'orbited_port', 'orbited_url', 'orbited_js',
'stomp_host',
'stomp_port', 'stomp_user', 'stomp_pass']
commit 96158b6b5a153db6b9a5e5d40699efefc728a9b3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Mon Oct 12 18:52:03 2009 -0400
Make our LiveWidget handle a 'topics' property along with 'topic'
diff --git a/moksha/api/widgets/live/live.py b/moksha/api/widgets/live/live.py
index 39cd7e3..6433219 100644
--- a/moksha/api/widgets/live/live.py
+++ b/moksha/api/widgets/live/live.py
@@ -33,7 +33,7 @@ class LiveWidget(Widget):
def update_params(self, d):
""" Register this widgets stomp callbacks """
super(LiveWidget, self).update_params(d)
- topics = d.get('topic', getattr(self, 'topic', None))
+ topics = d.get('topic', getattr(self, 'topic',
d.get('topics', getattr(self, 'topics', None))))
if not topics:
raise MokshaException('You must specify a `topic` to subscribe to')
topics = isinstance(topics, list) and topics or [topics]
commit 7c1fcf2ba4152d4aa9d7221062c0b2eed16440d7
Merge: bfdce5a... 6ba838f...
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Oct 10 14:38:40 2009 -0400
Merge branch 'master' of
git+ssh://git.fedorahosted.org/git/moksha
commit bfdce5a951dc525c4602bcebbaf2b37beb26d3b1
Author: Luke Macken <lmacken(a)redhat.com>
Date: Thu Oct 8 17:02:34 2009 -0400
Some further package name sanitization for our quickstarts
diff --git a/moksha/commands/quickstart.py b/moksha/commands/quickstart.py
index 6c52ddd..65d6ac3 100644
--- a/moksha/commands/quickstart.py
+++ b/moksha/commands/quickstart.py
@@ -96,7 +96,7 @@ Example usage::
self.package = raw_input(
"Enter package name [%s]: " % package).strip() or package
- self.name = pkg_resources.safe_name(self.name)
+ self.name = pkg_resources.safe_name(self.name).replace('-', '_')
self.rpm_name = self.name.replace('.', '_')
env = pkg_resources.Environment()