def get_current_user(self): """Tornado standard method--implemented our way.""" expiration = self.settings.get("auth_timeout", "14d") # Need the expiration in days (which is a bit silly but whatever): expiration = float(total_seconds(convert_to_timedelta(expiration))) / float(86400) user_json = self.get_secure_cookie("gateone_user", max_age_days=expiration) if not user_json: return None user = tornado.escape.json_decode(user_json) # Add the IP attribute user["ip_address"] = self.request.remote_ip return user
def get_current_user(self): """Tornado standard method--implemented our way.""" expiration = self.settings.get('auth_timeout', "14d") # Need the expiration in days (which is a bit silly but whatever): expiration = (float(total_seconds(convert_to_timedelta(expiration))) / float(86400)) user_json = self.get_secure_cookie("gateone_user", max_age_days=expiration) if not user_json: return None user = tornado.escape.json_decode(user_json) # Add the IP attribute user['ip_address'] = self.request.remote_ip return user
def __init__(self, interval='1s', io_loop=None, runner=None): if isinstance(interval, basestring): interval = convert_to_timedelta(interval) interval = interval.total_seconds() * 1000 if not runner: runner = ThreadedRunner() self.runner = runner self._running = False self.interval = interval self.io_loop = io_loop or IOLoop.current() self._pc = PeriodicCallback(self._schedule_check, self.interval, io_loop) self._id_counter = count(start=1) # For generating unique IDs self._schedules = {}
def __init__(self, interval='1s', io_loop=None, runner=None): if isinstance(interval, basestring): interval = convert_to_timedelta(interval) interval = interval.total_seconds() * 1000 if not runner: runner = ThreadedRunner() self.runner = runner self._running = False self.interval = interval self.io_loop = io_loop or IOLoop.current() self._pc = PeriodicCallback( self._schedule_check, self.interval, io_loop) self._id_counter = count(start=1) # For generating unique IDs self._schedules = {}
def __init__(self, **kwargs): self.io_loop = IOLoop.current() self.executor = None self.shutdown_timeout = None self.timeout = kwargs.pop('timeout', None) if not self.timeout: self.timeout = timedelta(seconds=30) if not isinstance(self.timeout, timedelta): self.timeout = convert_to_timedelta(self.timeout) self.interval = kwargs.pop('interval', None) if not self.interval: self.interval = "30s" global MEMO # Use a global so that instances can share the cache if not MEMO: MEMO = AutoExpireDict(timeout=self.timeout, interval=self.interval)