Allows attaching stateless information to the class using the
        flask session dict
164461
def set_key(cls, k, v):
        
        k = cls.__name__ + "__" + k
        session[k] = v
1234618
def session_state_view(request, template_name, **kwargs):
    ''

    session = request.session

    demo_count = session.get('django_plotly_dash', {})

    ind_use = demo_count.get('ind_use', 0)
    ind_use += 1
    demo_count['ind_use'] = ind_use

    context = {'ind_use' : ind_use}

    session['django_plotly_dash'] = demo_count

    return render(request, template_name=template_name, context=context)
793288
def register_internal_data(cls):
    
    with app.app_context():
        if getattr(cls, 'endpoint', None) is None:
            orig_class = cls
            cls = type('Sandman' + cls.__name__, (cls, Model), {})
            cls.__from_class__ = orig_class
        current_app.class_references[cls.__tablename__] = cls
        current_app.class_references[cls.__name__] = cls
        current_app.class_references[cls.endpoint()] = cls
        if not getattr(cls, '__related_tables__', None):
            cls.__related_tables__ = set()
701076
def set_attributes(self, session_key, attributes):
        
        session = self._lookup_required_session(session_key)
        session.set_attributes(attributes)
        self.session_handler.on_change(session)
777893
def _toState(self, state, *args, **kwargs):
        
        try:
            method = getattr(self, '_state_%s' % state)
        except AttributeError:
            raise ValueError("No such state %r" % state)

        log.msg("%s: to state %r" % (self.__class__.__name__, state))
        self._state = state
        method(*args, **kwargs)
1157835
public function classSessionToAssignData ($key_list = [], $parent_path_list = []) {
		$key_list = (array) $key_list;
		$key_list = empty($key_list) ? static::GetClassSessionNames() : $key_list;

		$parent_path_list = (array) $parent_path_list;

		$assign_data_set = [];

		if (empty($parent_path_list)) {
			foreach ($key_list as $key) {
				$assign_data_set[$key] = static::ReadClassSession($key);
			}
		} else {
			$class_session = static::ReadClassSession($parent_path_list);
			foreach ($key_list as $key) {
				$assign_data_set[$key] = isset($class_session[$key]) ? $class_session[$key] : null;
			}
		}

		return $assign_data_set;
	}
1318207
def set_session_info(self, info):
        '''
        
        '''
        if not self.info:
            self.info = SessionInfo()
            info_d = self.info.as_dict()
            ks = []
            vs = []
            for k, v in info_d.items():
                ks.append(k)
                vs.append(v)
            self.insert(ks, vs)
        changed = self.info.copy(info)
        if changed:
            self.update(self.info.as_dict())
78560
def pass_session_attributes(self):
        """"""
        for key, value in six.iteritems(self.request.session.attributes):
            self.response.sessionAttributes[key] = value
1008411
def session(self, value):
        """"""

        # unset session token
        if value is None:
            self._session = None
            return

        if not isinstance(value, dict):
            raise ValueError("session info is required")

        session_parsed = {}

        for key in ["session_token", "time", "secret_key"]:
            if key not in value:
                raise ValueError("Missing parameter: {}".format(key))
            session_parsed[key] = value[key]

        for key in ["ekey", "pkey"]:
            # nice to have, but not mandatory
            if key in value:
                session_parsed[key] = value[key]

        self._session = session_parsed
1006282
def _check_state_value(cls):
        
        state_value = cls.context.get_config('initial_state', None)
        state_value = state_value or getattr(
            cls.context.new_class, cls.context.state_name, None
        )

        if not state_value:
            raise ValueError(
                "Empty state is disallowed, yet no initial state is given!"
            )
        state_value = (
            cls.context
            .new_meta['translator']
            .translate(state_value)
        )
        cls.context.state_value = state_value
793528
def as_dash_app(self):
        '''
        
        '''
        dateless_dash_app = getattr(self, '_stateless_dash_app_instance', None)
        if not dateless_dash_app:
            dateless_dash_app = get_stateless_by_name(self.app_name)
            setattr(self, '_stateless_dash_app_instance', dateless_dash_app)
        return dateless_dash_app
557137
def bind(self, flask_app):
        """"""
        self.metadata.bind(flask_app, self.name, self.group)
1075107
def attach_session(self):
        
        assert self.session is None
        root = self.find_root()
        session = self.Session(root)
        root.inject_context(session=session)
        return session
1313795
def get_cookies_for_class(session, class_name,
                          cookies_file=None,
                          username=None,
                          password=None):
    
    if cookies_file:
        cookies = find_cookies_for_class(cookies_file, class_name)
        session.cookies.update(cookies)
        logging.info('Loaded cookies from %s', cookies_file)
    else:
        cookies = get_cookies_from_cache(username)
        session.cookies.update(cookies)
        if validate_cookies(session, class_name):
            logging.info('Already authenticated.')
        else:
            get_authentication_cookies(session, class_name, username, password)
            write_cookies_to_cache(session.cookies, username)
1071501
def send_state(self, key=None):
        
        state = self.get_state(key=key)
        if len(state) > 0:
            if self._property_lock:  # we need to keep this dict up to date with the front-end values
                for name, value in state.items():
                    if name in self._property_lock:
                        self._property_lock[name] = value
            state, buffer_paths, buffers = _remove_buffers(state)
            msg = {'method': 'update', 'state': state, 'buffer_paths': buffer_paths}
            self._send(msg, buffers=buffers)
720718
def init_app(self, app):
        
        app.extensions = getattr(app, "extensions", {})

        # If using Flask-SQLAlchemy, attach db.session to ModelSchema
        if has_sqla and "sqlalchemy" in app.extensions:
            db = app.extensions["sqlalchemy"].db
            self.ModelSchema.OPTIONS_CLASS.session = db.session
        app.extensions[EXTENSION_NAME] = self
377193
def read_info(self):
        '''
        
        '''
        self.select('*')
        row = self._cursor.fetchone()
        if not row:
            return None
        info_d = self.row_to_dict(row)
        return SessionInfo.from_dict(info_d)