This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Usage: | |
import debug | |
class BaseHandler(tornado.web.RequestHandler): | |
def get_error_html(self, status_code, **kwargs): | |
if self.application.settings['debug']: | |
return debug.display(self, kwargs['exception']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Copyright 2010 Josiah Carlson | |
Released into the public domain | |
copy_redis.py | |
A convenient utility function for copying data from one redis server to | |
another. | |
Requires http://github.com/andymccurdy/redis-py . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------ model.py ---------------- | |
meta = MetaData() | |
usersession_table = Table('kg_usersession', meta, | |
Column('session_id', String(32), primary_key=True), | |
Column('user_id', BigInteger, index=True, nullable=False), | |
Column('create_time', DateTime, index=True), | |
Column('expire_time', DateTime, index=True), | |
Column('site', String(10)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------- clients.py ---------- | |
class PikaPubSubSubscribeClient(object): | |
def __init__(self, message_processor, | |
host, | |
port, | |
virtual_host, | |
username, | |
password, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------- clients.py -------- | |
class PikaPubSubPublishClient(object): | |
def __init__(self, host=settings.APP_MESSAGER_DEFAULT_HOST, | |
port=settings.APP_MESSAGER_DEFAULT_PORT, | |
virtual_host=settings.APP_MESSAGER_DEFAULT_VIRTUALHOST, | |
username=settings.APP_MESSAGER_DEFAULT_USERNAME, | |
password=settings.APP_MESSAGER_DEFAULT_PASSWORD, | |
exchange_name='ground', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------- consumer --------------- | |
import simplejson | |
def check_callable(cb): | |
if not callable(cb): | |
raise TypeError("callback isn't a callable") | |
class ConsumerBase(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------- webdis_consumer.py ---------- | |
# -*- coding: utf-8 - | |
import simplejson | |
import httplib | |
def check_callable(cb): | |
if not callable(cb): | |
raise TypeError("callback isn't a callable") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import tornado | |
import tornadio | |
from handlers import PostMessageHandler, MessageConnection | |
import settings | |
MessageRouter = tornadio.get_router(MessageConnection, resource='message/*', extra_re='\d+', extra_sep='/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('connection', function(client){ | |
// helper function that goes inside your socket connection | |
client.connectSession = function(fn) { | |
if (!client.request || !client.request.headers || !client.request.headers.cookie) { | |
disconnectAndRedirectClient(client,function() { | |
console.log('Null request/header/cookie!'); | |
}); | |
return; | |
} |
OlderNewer