def __set_in_mc_db_to_true_if_ok(self, force_persist=False): enc_len = len(Session._Session__encode_data(self.ss.data)) if enc_len * 4 / 3 <= self.app_args['cookie_only_threshold']: self.ss.in_db = self.ss.in_mc = False # cookie-only self.data_should_be_in_cookie = True if not force_persist: return else: self.data_should_be_in_cookie = False # once its into mc, it will stay there until terminate() or a flush_all() self.ok_if_in_mc_remotely = True if self.dirty and self.dirty is not Session.DIRTY_BUT_DONT_PERSIST_TO_DB: self.ss.in_db = not self.app_args['no_datastore'] and self.api_statuses['db_can_wr'] and self.api_statuses['db_can_rd'] if self.ss.in_db: self.ok_if_in_db_remotely = True # once its in, it will stay there until terminate() self.keys_in_mc_only.clear() # pushed them all to the db elif self.dirty is Session.DIRTY_BUT_DONT_PERSIST_TO_DB: self.ss.in_db = False self.ss.in_mc = self.api_statuses['mc_can_wr'] and self.api_statuses['mc_can_rd']
def __set_in_mc_db_to_true_if_ok(self, force_persist=False): enc_len = len(Session._Session__encode_data(self.ss.data)) if enc_len * 4 / 3 <= self.app_args['cookie_only_threshold']: self.ss.in_db = self.ss.in_mc = False # cookie-only self.data_should_be_in_cookie = True if not force_persist: return else: self.data_should_be_in_cookie = False # once its into mc, it will stay there until terminate() or a flush_all() self.ok_if_in_mc_remotely = True if self.dirty and self.dirty is not Session.DIRTY_BUT_DONT_PERSIST_TO_DB: self.ss.in_db = not self.app_args[ 'no_datastore'] and self.api_statuses[ 'db_can_wr'] and self.api_statuses['db_can_rd'] if self.ss.in_db: self.ok_if_in_db_remotely = True # once its in, it will stay there until terminate() self.keys_in_mc_only.clear() # pushed them all to the db elif self.dirty is Session.DIRTY_BUT_DONT_PERSIST_TO_DB: self.ss.in_db = False self.ss.in_mc = self.api_statuses['mc_can_wr'] and self.api_statuses[ 'mc_can_rd']