Prepare phase for session.

        :param session: sqlalchemy session
428119
def prepare(self, session, event):
        
        if not event:
            self.logger.warn("event empty!")
            return

        sp_key, sp_hkey = self._keygen(session)

        def _pk(obj):
            pk_values = tuple(getattr(obj, c.name)
                              for c in obj.__mapper__.primary_key)
            if len(pk_values) == 1:
                return pk_values[0]
            return pk_values

        def _get_dump_value(value):
            if hasattr(value, '__mapper__'):
                return _pk(value)
            return value
        pickled_event = {
            k: pickle.dumps({_get_dump_value(obj) for obj in objs})
            for k, objs in event.items()}
        with self.r.pipeline(transaction=False) as p:
            p.sadd(sp_key, session.meepo_unique_id)
            p.hmset(sp_hkey, pickled_event)
            p.execute()
292999
def _get_session(self):
        
        if self._session is None:
            session = self._session = self._database.session()
            session.create()
        return self._session
977380
def fin_session(self):
		
		self.__prompt_show = False
		self.__history.add(self.row())
		self.exec(self.row())
1336948
private function prepare()
    {
        $session = new Session();
        $session->start();

        $request = Request::createFromGlobals();
        $request->setSession($session);

        $this->requestStack->push($request);
        $this->tokenStorage->setToken(
            new AnonymousToken('anonymous', 'anonymous', ['ROLE_ADMINISTRATOR'])
        );
    }
692059
def set_phases(self, literals=[]):
        

        if self.minisat:
            pysolvers.minisat22_setphases(self.minisat, literals)
1175677
def magic_session(db_session=None, url=None):
    

    if db_session is not None:
        yield db_session
    else:
        session = get_session(url, expire_on_commit=False)
        try:
            try:
                yield session
            finally:
                session.commit()
        finally:
            session.close()
209450
def _wrap_sessions(sessions, request):
    
    result = set()
    for s in sessions:
        if s is SELF and request:
            result.add(request.session.session_key)
        else:
            result.add(s)
    return result
19420
def session_preparation(self):
        """"""
        self._test_channel_read()
        self.set_base_prompt()
        self.tmsh_mode()
        self.set_base_prompt()
        self.disable_paging(
            command="modify cli preference pager disabled display-threshold 0"
        )
        self.clear_buffer()
        cmd = 'run /util bash -c "stty cols 255"'
        self.set_terminal_width(command=cmd)
379137
protected function prepareInit()
    {
        $stid = oci_parse($this->raw, "ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
        oci_execute($stid);
        oci_free_statement($stid);

        $stid = oci_parse($this->raw, "ALTER SESSION SET NLS_SORT = BINARY_CI");
        oci_execute($stid);
        oci_free_statement($stid);

        $stid = oci_parse($this->raw, "ALTER SESSION SET NLS_COMP = LINGUISTIC");
        oci_execute($stid);
        oci_free_statement($stid);
    }
715384
def setPhase(self, tlsID, index):
        
        self._connection._sendIntCmd(
            tc.CMD_SET_TL_VARIABLE, tc.TL_PHASE_INDEX, tlsID, index)
1214985
def session_preparation(self):
        
        delay_factor = self.select_delay_factor(delay_factor=0)
        i = 1
        while i <= 4:
            # Comware can have a banner that prompts you to continue
            # 'Press Y or ENTER to continue, N to exit.'
            time.sleep(0.5 * delay_factor)
            self.write_channel("\n")
            i += 1

        time.sleep(0.3 * delay_factor)
        self.clear_buffer()
        self._test_channel_read(pattern=r"[>\]]")
        self.set_base_prompt()
        command = self.RETURN + "screen-length disable"
        self.disable_paging(command=command)
        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()
736049
def start(self, session_context):
        
        # is a SimpleSesson:
        session = self._create_session(session_context)

        self.session_handler.on_start(session, session_context)

        mysession = session_tuple(None, session.session_id)
        self.notify_event(mysession, 'SESSION.START')

        # Don't expose the EIS-tier Session object to the client-tier, but
        # rather a DelegatingSession:
        return self.create_exposed_session(session=session, context=session_context)
142965
def var_set(self, session, **kwargs):
        
        if not kwargs:
            session.write_line(
                self._utils.make_table(
                    ("Name", "Value"), session.variables.items()
                )
            )
        else:
            for name, value in kwargs.items():
                name = name.strip()
                session.set(name, value)
                session.write_line("{0}={1}", name, value)
647370
def prepare(cls, session, pkgen, items):
        
        for item in cls.merge(session, items):
            if hasattr(item, "id"):
                item.id.resolve(id=pkgen.get(cls), is_new=True)
            yield cls.to_dict(item)
857120
def create(self, session):
        
        sessionid = super().create(session)  # calls _do_create and verify
        self._cache(session, sessionid)
        return sessionid
478150
def add(self, session):
        
        self._items[session.session_id] = session

        if session.expiry is not None:
            self._queue.push(session)
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())