Commit c28650ea authored by Denis Bilenko's avatar Denis Bilenko

webchat examples: pep8

parent efc4c6d1
...@@ -40,7 +40,7 @@ class ChatRoom(object): ...@@ -40,7 +40,7 @@ class ChatRoom(object):
try: try:
for index, m in enumerate(self.cache): for index, m in enumerate(self.cache):
if m['id'] == cursor: if m['id'] == cursor:
return json_response({'messages': self.cache[index+1:]}) return json_response({'messages': self.cache[index + 1:]})
return json_response({'messages': self.cache}) return json_response({'messages': self.cache})
finally: finally:
if self.cache: if self.cache:
...@@ -63,4 +63,3 @@ def create_message(from_, body): ...@@ -63,4 +63,3 @@ def create_message(from_, body):
def json_response(value, **kwargs): def json_response(value, **kwargs):
kwargs.setdefault('content_type', 'text/javascript; charset=UTF-8') kwargs.setdefault('content_type', 'text/javascript; charset=UTF-8')
return HttpResponse(simplejson.dumps(value), **kwargs) return HttpResponse(simplejson.dumps(value), **kwargs)
#!/usr/bin/python #!/usr/bin/python
from django.core.management import execute_manager from django.core.management import execute_manager
try: try:
import settings # Assumed to be in the same directory. import settings # Assumed to be in the same directory.
except ImportError: except ImportError:
import sys import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
......
...@@ -11,12 +11,13 @@ from django.core.signals import got_request_exception ...@@ -11,12 +11,13 @@ from django.core.signals import got_request_exception
sys.path.append('..') sys.path.append('..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'webchat.settings' os.environ['DJANGO_SETTINGS_MODULE'] = 'webchat.settings'
def exception_printer(sender, **kwargs): def exception_printer(sender, **kwargs):
traceback.print_exc() traceback.print_exc()
got_request_exception.connect(exception_printer) got_request_exception.connect(exception_printer)
call_command('syncdb') call_command('syncdb')
print 'Serving on 8088...' print 'Serving on 8088...'
WSGIServer(('', 8088), WSGIHandler()).serve_forever() WSGIServer(('', 8088), WSGIHandler()).serve_forever()
...@@ -11,4 +11,3 @@ urlpatterns += patterns('django.views.static', ...@@ -11,4 +11,3 @@ urlpatterns += patterns('django.views.static',
'serve', { 'serve', {
'document_root': settings.MEDIA_ROOT, 'document_root': settings.MEDIA_ROOT,
'show_indexes': True })) 'show_indexes': True }))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment