Just trying to play around with the tgext.socketio used here
https://github.com/amol-/tgext.socketio
quickstarted a new project using the most recent version of tg 2.3.X.
Copy pasted the code pretty much as is.
Modified development.ini and when i launch (gearbox serve) the application
crashes instantly with no traceback.
(realtime)vagrant@vagrant-ubuntu-trusty-64:~/realtime/src$ gearbox
--verbose serve -c development.ini
/home/vagrant/realtime/local/lib/python2.7/site-packages/pkg_resources.py:991:
UserWarning: /home/vagrant/.python-eggs is writable by group/others and
vulnerable to attack when used with get_resource_filename. Consider a more
secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE
environment variable).
warnings.warn(msg, UserWarning)
21:17:54,639 DEBUG [tg.configuration.milestones] Register <bound method
JSONEncoder._load_config of <tg.jsonify.JSONEncoder object at
0x7f21c99cf4d0>> to be called when config_ready reached
21:17:54,681 DEBUG [tg.configuration.milestones] Register <bound method
TGFlash._load_config of <tg.flash.TGFlash object at 0x7f21c903e810>> to be
called when config_ready reached
21:17:54,717 DEBUG [tg.configuration.milestones] Register <bound method
Decoration._resolve_expositions of <Decoration 139783081607568 for
<function _default at 0x7f21c8ecd5f0>>> to be called when renderers_ready
reached
21:17:54,720 DEBUG [tg.configuration.milestones] Register <bound method
Decoration._resolve_expositions of <Decoration 139783081721616 for
<function _default at 0x7f21c8eed488>>> to be called when renderers_ready
reached
21:17:54,778 DEBUG [tg.configuration.app_config] Initializing
configuration, package: 'realtime'
21:17:54,779 DEBUG [tg.configuration.milestones] config_ready milestone
reached
21:17:54,779 DEBUG [tg.configuration.milestones] renderers_ready milestone
reached
21:17:54,789 DEBUG [tg.configuration.milestones] environment_loaded
milestone reached
21:17:54,789 DEBUG [tg.configuration.milestones] environment_loaded
milestone reached
development.ini
============
[server:main]
use = egg:tgext.socketio#socketio
socketio_resource = socketio
#use = egg:gearbox#wsgiref
host = 0.0.0.0
port = 8080
set debug = false
root.py
========
from tg import expose, flash, require, url, lurl, request, redirect,
tmpl_context
from tg.i18n import ugettext as _, lazy_ugettext as l_
from tg.exceptions import HTTPFound
from tg import predicates
from realtime import model
from realtime.model import DBSession, metadata
from realtime.lib.base import BaseController
from realtime.controllers.error import ErrorController
from tgext.socketio import SocketIOTGNamespace, SocketIOController
__all__ = ['RootController']
class PingPong(SocketIOTGNamespace):
def on_ping(self, attack):
if attack['type'] == 'fireball':
for i in range(10):
self.emit('pong', {'sound': 'bang!'})
else:
self.emit('pong', {'sound': 'pong'})
class SocketIO(SocketIOController):
pingpong = PingPong
@expose()
def page(self, **kw):
return """
<html>
<body>
<div>
<a class="ping" href="#" data-attack="ping">Ping</a>
<a class="ping" href="#" data-attack="fireball">Fireball</a>
<a class="ping" href="#" data-attack="auto">Auto</a>
<a class="ping" href="#" data-attack="error">Error</a>
</div>
<div id="result"></div>
<script
src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script
src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script>
$(function(){
var socket = io.connect('/pingpong', {'resource':'socketio'});
socket.on('pong',function(data){
$('#result').append(data.sound + '<br/>');
});
socket.on('error',function(error, info) {
if (error == 'method_access_denied') { alert(info); }
else { console.log(info); alert(error); }
});
$('.ping').click(function(event){
event.preventDefault();
socket.emit('ping',{'type':$(this).data('attack')});
});
});
</script>
</body>
</html>
"""
class RootController(BaseController):
socketio = SocketIO()
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.