Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

comet example working again

git-svn-id: http://evserver.googlecode.com/svn/trunk@74 e9bb6d7e-af12-11dd-bad7-87afd3b02348
  • Loading branch information...
commit 7f50e7b26dc815b91048252e4f057b8dc99324db 1 parent e1d813b
majek04 authored
View
17 evserver/examples/comet.py
@@ -14,7 +14,6 @@
log = logging.getLogger(os.path.basename(__file__))
-
urls = (
'/static/([^/]+)', 'staticfiles',
'/', 'staticfiles',
@@ -38,9 +37,8 @@ def GET(self, filename='index.html'):
web.header('Content-Type', mt )
f = open(path)
data = f.read()
- web.output(data)
f.close()
- return
+ return data
class comet:
@@ -49,7 +47,7 @@ def GET(self):
i = web.input(transport='iframe', callback='c')
if i.transport == 'longpoll':
return comet_longpoll().GET()
- t = transports.get_transport(i.transport, i.callback)
+ t = transports.get_transport(i.transport.encode('utf-8'), i.callback.encode('utf-8'))
for k, v in t.get_headers():
web.header(k, v)
@@ -92,7 +90,7 @@ def iterator():
except GeneratorExit:
pass
os.close(fd)
- web.ctx.output = iterator()
+ return iterator()
class comet_longpoll:
def GET(self):
@@ -160,7 +158,7 @@ def iterator():
except GeneratorExit:
pass
os.close(fd)
- web.ctx.output = iterator()
+ return iterator()
@@ -176,8 +174,7 @@ def POST(self):
fd = os.open(path, os.O_WRONLY | os.O_NONBLOCK)
os.write(fd, web.data() )
os.close(fd)
- web.output('ok')
- return
+ return 'ok'
class cometread:
@@ -215,7 +212,7 @@ def iterator():
except GeneratorExit:
pass
os.unlink(fname)
- web.ctx.output = iterator()
+ return iterator()
class cometread_longpoll:
def GET(self):
@@ -246,7 +243,7 @@ def iterator():
except GeneratorExit:
pass
os.unlink(fname)
- web.ctx.output = iterator()
+ return iterator()
# from http://code.google.com/p/modwsgi/wiki/IntegrationWithWebPy
View
5 evserver/examples/static/index.html
@@ -171,13 +171,14 @@
<script>
<!--
var cross_domain = true;
+ var cross_domain_domain = 'comet.' + ('' + document.location).split('/')[2];
function change_domain_settings(){
cross_domain = !cross_domain;
if(!cross_domain)
document.getElementById('header-domain').innerHTML = 'Current domain tests';
else
- document.getElementById('header-domain').innerHTML = 'Cross-domain tests (comet.'+document.domain+')';
+ document.getElementById('header-domain').innerHTML = 'Cross-domain tests ('+cross_domain_domain+')';
}
change_domain_settings();
@@ -208,7 +209,7 @@
function create_comet(url, user_callback, transport_local){
if(cross_domain)
- return comet_crossdomain_connection('http://comet.'+document.domain+'/static/crosscomet.html', url, user_callback, transport_local);
+ return comet_crossdomain_connection('http://'+cross_domain_domain+'/static/crosscomet.html', url, user_callback, transport_local);
return comet_connection(url, user_callback, transport_local);
}
View
2  evserver/transports.py
@@ -1,5 +1,5 @@
-import evserver.other.json
+import evserver.other.json as json
import os, os.path, logging
log = logging.getLogger(os.path.basename(__file__))
Please sign in to comment.
Something went wrong with that request. Please try again.