• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python session.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tg.session.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pwd_expired_change

    def pwd_expired_change(self, **kw):
        require_authenticated()
        return_to = kw.get('return_to')
        kw = F.password_change_form.to_python(kw, None)
        ap = plugin.AuthenticationProvider.get(request)
        try:
            expired_username = session.get('expired-username')
            expired_user = M.User.query.get(username=expired_username) if expired_username else None
            ap.set_password(expired_user or c.user, kw['oldpw'], kw['pw'])
            expired_user.set_tool_data('allura', pwd_reset_preserve_session=session.id)
            expired_user.set_tool_data('AuthPasswordReset', hash='', hash_expiry='')  # Clear password reset token

        except wexc.HTTPUnauthorized:
            flash('Incorrect password', 'error')
            redirect(tg.url('/auth/pwd_expired', dict(return_to=return_to)))
        flash('Password changed')
        session.pop('pwd-expired', None)
        session['username'] = session.get('expired-username')
        session.pop('expired-username', None)

        session.save()
        h.auditlog_user('Password reset (via expiration process)')
        if return_to and return_to != request.url:
            redirect(return_to)
        else:
            redirect('/')
开发者ID:abhinavthomas,项目名称:allura,代码行数:26,代码来源:auth.py


示例2: pwd_expired_change

    def pwd_expired_change(self, **kw):
        require_authenticated()
        return_to = kw.get("return_to")
        kw = F.password_change_form.to_python(kw, None)
        ap = plugin.AuthenticationProvider.get(request)
        try:
            expired_username = session.get("expired-username")
            expired_user = M.User.query.get(username=expired_username) if expired_username else None
            ap.set_password(expired_user or c.user, kw["oldpw"], kw["pw"])
            expired_user.set_tool_data("allura", pwd_reset_preserve_session=session.id)
            expired_user.set_tool_data("AuthPasswordReset", hash="", hash_expiry="")  # Clear password reset token

        except wexc.HTTPUnauthorized:
            flash("Incorrect password", "error")
            redirect(tg.url("/auth/pwd_expired", dict(return_to=return_to)))
        flash("Password changed")
        session.pop("pwd-expired", None)
        session["username"] = session.get("expired-username")
        session.pop("expired-username", None)

        session.save()
        h.auditlog_user("Password reset (via expiration process)")
        if return_to and return_to != request.url:
            redirect(return_to)
        else:
            redirect("/")
开发者ID:joequant,项目名称:allura,代码行数:26,代码来源:auth.py


示例3: check_phone_verification

 def check_phone_verification(self, pin, **kw):
     p = plugin.ProjectRegistrationProvider.get()
     request_id = session.get('phone_verification.request_id')
     number_hash = session.get('phone_verification.number_hash')
     res = p.check_phone_verification(c.user, request_id, pin, number_hash)
     if 'error' in res:
         res['error'] = jinja2.Markup.escape(res['error'])
         res['error'] = h.really_unicode(res['error'])
     return res
开发者ID:apache,项目名称:allura,代码行数:9,代码来源:project.py


示例4: clear

 def clear(self):
     try:
         session.get('skip', set()).remove(self.name)
     except KeyError:
         pass
     session['settings'].pop(self.name, None)
     session.save()
     flash(_('Settings cleared'))
     redirect(self.url)
开发者ID:TimmGit,项目名称:posy,代码行数:9,代码来源:root.py


示例5: index

 def index(self):
     result = None
     if session.get('username') is not None:
         user = DBSession.query(User).filter_by(user_name=session.get('username')).first()
         if user is not None and user.is_cloud():
             if session['cloud_only'] == True:
                 override_template(self.index, 'genshi:stackone.templates.clouddashboard')
         
     result = self.controller_impl.index()
     return dict(result)
开发者ID:smarkm,项目名称:ovm,代码行数:10,代码来源:root.py


示例6: oauth_callback

 def oauth_callback(self, **kw):
     client_id = config.get("github_importer.client_id")
     secret = config.get("github_importer.client_secret")
     if not client_id or not secret:
         return  # GitHub app is not configured
     oauth = OAuth2Session(client_id, state=session.get("github.oauth.state"))
     token = oauth.fetch_token(
         "https://github.com/login/oauth/access_token", client_secret=secret, authorization_response=request.url
     )
     c.user.set_tool_data("GitHubProjectImport", token=token["access_token"])
     redirect(session.get("github.oauth.redirect", "/"))
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:11,代码来源:__init__.py


示例7: post_logout

    def post_logout(self, came_from=url('/')):
        try:
            if session.get('username'):
                UIUpdateManager().del_user_updated_entities(session['username'], session['group_names'])
                UIUpdateManager().del_user_updated_tasks(session['username'])
                TopCache().delete_usercache(session.get('auth'))

        except Exception as e:
            print_traceback()
            LOGGER.error(to_str(e))

        session.delete()
开发者ID:smarkm,项目名称:ovm,代码行数:12,代码来源:ControllerImpl.py


示例8: index

    def index(self, *args, **kw):
        '''
        Find first not set up service
        '''
        for name, item in self.menu:
            if name in session.get('skip', set()):
                continue
            if name not in session.get('settings', {}):
                redirect(item.url)
        # Redirect to the first item in list
        # redirect(self.menu[0][1].url)

        # Redirect to the last item in list
        redirect(item.url)
开发者ID:TimmGit,项目名称:posy,代码行数:14,代码来源:root.py


示例9: oauth_callback

 def oauth_callback(self, **kw):
     client_id = config.get('github_importer.client_id')
     secret = config.get('github_importer.client_secret')
     if not client_id or not secret:
         return  # GitHub app is not configured
     oauth = OAuth2Session(
         client_id, state=session.get('github.oauth.state'))
     token = oauth.fetch_token(
         'https://github.com/login/oauth/access_token',
         client_secret=secret,
         authorization_response=request.url
     )
     c.user.set_tool_data('GitHubProjectImport',
                          token=token['access_token'])
     redirect(session.get('github.oauth.redirect', '/'))
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:15,代码来源:__init__.py


示例10: get_all_instance_categories

 def get_all_instance_categories(self):
     try:
         return self.csep_service.get_all_instance_categories_db(session.get('servicepoint_id'))
     except Exception as ex:
         print_traceback()
         LOGGER.error(to_str(ex))
         raise ex
开发者ID:smarkm,项目名称:ovm,代码行数:7,代码来源:CMSCloudXMLRPC.py


示例11: fetch

   def fetch(self, page, rows, sidx, sord, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rows)
      except:
         offset = 0
         page = 1
         rows = 25

      apps = DBSession.query(Campaign).filter(Campaign.deleted==None)
      total = 1 + apps.count() / rows
      column = getattr(Campaign, sidx)
      apps = apps.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ { 'id'  : a.cmp_id, 'cell': row(a) } for a in apps ]

      return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:31,代码来源:cc_campaign.py


示例12: fetch

    def fetch(self, page, rows, sidx, sord, **kw):
        """ Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      """

        # Try and use grid preference
        grid_rows = session.get("grid_rows", None)
        if rows == "-1":  # Default value
            rows = grid_rows if grid_rows is not None else 25

        # Save grid preference
        session["grid_rows"] = rows
        session.save()
        rows = int(rows)

        try:
            page = int(page)
            rows = int(rows)
            offset = (page - 1) * int(rp)
        except:
            offset = 0
            page = 1
            rows = 25

        apps = DBSession.query(Application)
        total = apps.count()
        column = getattr(Application, sidx)
        apps = apps.order_by(getattr(column, sord)()).offset(offset).limit(rows)
        rows = [{"id": a.app_id, "cell": row(a)} for a in apps]

        return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:31,代码来源:application.py


示例13: ajaxAddtoCart

    def ajaxAddtoCart( self, **kw ):
        _id = kw.get( 'id', None ) or None
        if not _id : return {'flag' : 1 , 'msg' : 'No ID provided!'}

        try:
            items = session.get( 'items', [] )
            tmp = {
                   '_k' : "%s%s" % ( dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 100, 10000 ) ) ,
                   'id' : _id,
                   }
            qs = []
            for qk, qv in self._filterAndSorted( "option_qty", kw ):
                if not qv : continue
                q, _ = qv.split( "|" )
                if not q.isdigit() : continue
                qs.append( int( q ) )
            tmp['qty'] = sum( qs ) if qs else 0

            p = qry( Product ).get( _id )
            tmp['values'], tmp['optionstext'] = self._formatKW( kw, p )
            items.append( tmp )
            session['items'] = items
            session.save()
            return {'flag' : 0 , 'total' : len( session['items'] )}
        except:
            traceback.print_exc()
            return {'flag' : 1, 'msg':'Error occur on the sever side!'}
开发者ID:LamCiuLoeng,项目名称:aeo,代码行数:27,代码来源:ordering.py


示例14: ajaxSavetoCart

    def ajaxSavetoCart( self, **kw ):
        _k = kw.get( "_k", None )
        if not _k : return {'flag' : 1 , 'msg' : 'No ID provided!'}

        try:
            items = session.get( 'items', [] )
            for index, item in enumerate( items ):
                if item['_k'] != _k : continue
                p = qry( Product ).get( item['id'] )
                item['values'], item['optionstext'] = self._formatKW( kw , p )
                qs = []
                for qk, qv in self._filterAndSorted( "option_qty", kw ):
                    if not qv : continue
                    q, _ = qv.split( "|" )
                    if not q.isdigit() : continue
                    qs.append( int( q ) )
                item['qty'] = sum( qs ) if qs else 0
                items[index] = item
                session['items'] = items
                session.save()
                return {'flag' : 0 , 'optionstext' : item['optionstext'], }
        except:
            traceback.print_exc()
            return {'flag' : 1 , 'msg' : 'Error occur on the sever side!'}
        return {'flag' : 1 , 'msg' : 'No such item!'}
开发者ID:LamCiuLoeng,项目名称:aeo,代码行数:25,代码来源:ordering.py


示例15: outcall_fetch

   def outcall_fetch(self, page, rows, sidx, sord, cust_id, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rp)
      except:
         offset = 0
         page = 1
         rows = 25

      data = DBSession.query(Outcall, CDR) \
         .outerjoin(CDR, Outcall.uniqueid==CDR.uniqueid) \
         .filter(Outcall.cust_id==cust_id)

      total = 1 + data.count() / rows
      column = getattr(Outcall, sidx)
      data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ 
         { 'id'  : a.Outcall.out_id, 'cell': outcall_row(a) } for a in data ]

      return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:35,代码来源:cc_outcall.py


示例16: customer_fetch

   def customer_fetch(self, page, rows, sidx, sord, cmp_id, **kw):
      ''' Function called on AJAX request made by FlexGrid
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * int(rows)
      except:
         offset = 0
         page = 1
         rows = 25

      data = DBSession.query(Customer). \
         filter(Customer.cmp_id==cmp_id). \
         filter(Customer.active==True)
      total = 1 + data.count() / rows
      column = getattr(Customer, sidx if sidx!='name' else 'lastname')
      data = data.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      rows = [ { 'id'  : a.cust_id, 'cell': customer_row(a) } for a in data ]

      return dict(page=page, total=total, rows=rows)
开发者ID:sysnux,项目名称:astportal,代码行数:33,代码来源:cc_outcall.py


示例17: fetch

   def fetch(self, page, rows, sidx='lastname', sord='asc', _search='false',
          searchOper=None, searchField=None, searchString=None, **kw):
      ''' Function called on AJAX request made by Grid JS component
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * rows
      except:
         offset = 0
         page = 1
         rows = 25

      pb = sorted(phonebook_list(request.identity['user'].user_id,
                         searchOper,
                         searchField,
                         searchString),
                  key = itemgetter(sidx),
                  reverse = True if sord=='desc' else False)
      total = len(pb)/rows+1
      data = [ { 'id'  : b['pb_id'], 'cell': row(b) } for b in pb[offset:offset+rows] ]

      return dict(page=page, total=total, rows=data)
开发者ID:sysnux,项目名称:astportal,代码行数:35,代码来源:phonebook.py


示例18: send_email_to_user

    def send_email_to_user(self, msg):
        # Query sender and password from email credential table
        # Query mail_server,port,use_secure from the email setup table for curenly  logged in user
        # receiver: to be queried from users table
        self.msg = msg
        curr_user_id = session.get("userid")
        # query users table to retrieve email address of currenlt logged in user
        userRecord = DBSession.query(User.email_address).filter(User.user_name == curr_user_id).first()
        if userRecord:
            self.receivers = userRecord.email_address
        emailservers = self.get_mailservers()
        for eachmailserver in emailservers:
            if eachmailserver:
                self.mail_server = eachmailserver["MailSetup"].mail_server
                self.port = int(eachmailserver["MailSetup"].port)
                self.secure_type = int(eachmailserver["MailSetup"].use_secure)
                self.cred_details = eachmailserver["Creds"].cred_details
                self.password = self.cred_details["password"]
                self.sender = self.cred_details["user_email"]
                result = False
                if self.secure_type == NONSECURE:
                    result = EmailManager().send_nonsecure(
                        self.mail_server, self.port, self.sender, self.receivers, msg
                    )
                elif self.secure_type == TLS:
                    result = EmailManager().send_tls(
                        self.mail_server, self.port, self.sender, self.password, self.receivers, msg
                    )
                else:
                    result = EmailManager().send_ssl(
                        self.mail_server, self.port, self.sender, self.password, self.receivers, msg
                    )

                if result == True:
                    return "Test mail sent from " + eachmailserver["MailSetup"].mail_server
开发者ID:hewei-chn,项目名称:openconvirt,代码行数:35,代码来源:EmailService.py


示例19: fetch

   def fetch(self, page, rows, sidx='name', sord='desc', _search='false',
          searchOper=None, searchField=None, searchString=None, **kw):
      ''' Function called on AJAX request made by Grid JS component
      Fetch data from DB, return the list of rows + total + current page
      '''

      # Try and use grid preference
      grid_rows = session.get('grid_rows', None)
      if rows=='-1': # Default value
         rows = grid_rows if grid_rows is not None else 25

      # Save grid preference
      session['grid_rows'] = rows
      session.save()
      rows = int(rows)

      try:
         page = int(page)
         rows = int(rows)
         offset = (page-1) * rows
      except:
         offset = 0
         page = 1
         rows = 25

      queue = DBSession.query(Queue)
      total = queue.count()/rows + 1
      column = getattr(Queue, sidx)
      queue = queue.order_by(getattr(column,sord)()).offset(offset).limit(rows)
      data = [ { 'id'  : q.queue_id, 'cell': row(q) } for q in queue ]

      return dict(page=page, total=total, rows=data)
开发者ID:sysnux,项目名称:astportal,代码行数:32,代码来源:queues.py


示例20: index

    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)
        user_lab = session.get("current_lab", None)
        mail = user.email
        mail_tmp = mail.split("@")
        mail_final = mail_tmp[0] + "AT" + mail_tmp[1]
        user_TH_path = trackhubs_path() + "/" + user_lab + "/" + mail_final
        trackhubs = []
        if os.path.exists(user_TH_path):
            list_trackhubs = os.listdir(user_TH_path)
            for t in list_trackhubs:
                th_path = user_TH_path + "/" + t
                #the only one directory into at this th level is named by the assembly used for it
                for i in os.listdir(th_path):
                    path_to_test = th_path + "/" + i
                    if os.path.isdir(path_to_test):
                        assembly = i
                if not assembly:
                    break
                else:
                    #hub_url = th_path + "/hub.txt"
                    hostname = socket.gethostname().lower()
                    #because of aliasing
                    if hostname == "ptbbsrv2.epfl.ch":
                        hostname = "biorepo.epfl.ch"
                    hub_url = "http://" + hostname + url("/trackHubs/") + user_lab + "/" + mail_final + "/" + t + "/hub.txt"
                    th = Trackhub(t, 'http://genome.ucsc.edu/cgi-bin/hgTracks?hubUrl=' + hub_url + "&db=" + assembly)
                    trackhubs.append(th)

        all_trackhubs = [util.to_datagrid(TrackhubGrid(), trackhubs, " UCSC's Trackhub(s)", len(trackhubs) > 0)]

        return dict(page='trackhubs', model=trackhubs, items=all_trackhubs, value=kw)
开发者ID:bbcf,项目名称:biorepo,代码行数:32,代码来源:trackhub.py



注:本文中的tg.session.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python session.save函数代码示例发布时间:2022-05-27
下一篇:
Python decorators.Decoration类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap