def wrapper(*args, **kwargs): saved = routers.using_slave() routers.use_slave(use_slave) try: return func(*args, **kwargs) finally: routers.use_slave(saved)
def process_request(self, request): routers.randomize_slave() if request.method == 'POST': routers.use_slave(False) else: routers.use_slave(True)