mirror of https://github.com/peter4431/rq.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
602 B
Python
29 lines
602 B
Python
class NoRedisConnectionException(Exception):
|
|
pass
|
|
|
|
|
|
class RedisConnectionProxy(object):
|
|
def __init__(self):
|
|
self.stack = []
|
|
|
|
def _get_current_object(self):
|
|
try:
|
|
return self.stack[-1]
|
|
except IndexError:
|
|
msg = 'No Redis connection configured.'
|
|
raise NoRedisConnectionException(msg)
|
|
|
|
def pop(self):
|
|
return self.stack.pop()
|
|
|
|
def push(self, db):
|
|
self.stack.append(db)
|
|
|
|
def __getattr__(self, name):
|
|
return getattr(self._get_current_object(), name)
|
|
|
|
|
|
conn = RedisConnectionProxy()
|
|
|
|
__all__ = ['conn']
|