Split out the redis hostname for user events and build logs as a string config. Modularize the user events and fix all callers.

This commit is contained in:
Jake Moshenko 2014-05-30 14:25:29 -04:00
parent 4c1538ca90
commit d1f4fbdacc
6 changed files with 37 additions and 12 deletions

View file

@ -17,6 +17,27 @@ class UserEventBuilder(object):
return UserEventListener(self._redis_host, username, events)
class UserEventsBuilderModule(object):
def __init__(self, app=None):
self.app = app
if app is not None:
self.state = self.init_app(app)
else:
self.state = None
def init_app(self, app):
redis_hostname = app.config.get('USER_EVENTS_REDIS_HOSTNAME')
user_events = UserEventBuilder(redis_hostname)
# register extension with app
app.extensions = getattr(app, 'extensions', {})
app.extensions['userevents'] = user_events
return user_events
def __getattr__(self, name):
return getattr(self.state, name, None)
class UserEvent(object):
"""
Defines a helper class for publishing to realtime user events