当前位置: 首页>>代码示例>>Python>>正文


Python session.Session类代码示例

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


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

示例1: post

 def post(self):
   """ will handle change of password request, will return success/fail """
   current_session = Session().get_current_session(self)
   email = current_session.get_email()
   
   old_password = self.request.get("oldpassword")
   new_password = self.request.get("newpassword")
   new_password_again = self.request.get("newpasswordagain")
   
   error_message = ""
   success = False
   if new_password != new_password_again:
     error_message = "Passwords do not match."
   else:
     """ Make sure that the account authenticates... this is a redundant check """
     if accounts_dao.authenticate_web_account(email, old_password):
       changed = accounts_dao.change_account_password(email, new_password)
       if changed:
         success = True
     else:
       error_message = "Old password incorrect."
 
   template_values = {"preferences_main" : True,
                      "password_change_attempted" : True,
                      'account_name' : email,
                      "error_message": error_message,
                      "password_changed" : success}
   self.response.out.write(template.render(constants.TEMPLATE_PATHS.CONSOLE_DASHBOARD, template_values))
开发者ID:Yonnick,项目名称:userinfuser,代码行数:28,代码来源:console.py

示例2: get

 def get(self):
   """ Ask for which widget, and then render that widget """
   widget = self.request.get("widget")
   current_session = Session().get_current_session(self)
   account = current_session.get_account_entity()
   
   widget_ref = account.trophyWidget
   render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE
   if widget == "rank":
     widget_ref = account.rankWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_RANK
   elif widget == "points":
     widget_ref = account.pointsWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_POINTS
   elif widget == "leaderboard":
     widget_ref = account.leaderWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD
   elif widget == "notifier":
     widget_ref = account.notifierWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER
   elif widget == "milestones":
     widget_ref = account.milestoneWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES  
     
   values = {"status":"success"}
   properties = widget_ref.properties()
   for property in properties:
     values[property] = getattr(widget_ref, property)
   
   self.response.out.write(template.render(render_path, values))
开发者ID:Yonnick,项目名称:userinfuser,代码行数:30,代码来源:console.py

示例3: get

 def get(self):
     self.response.out.write("You should be able to see this page, logged in or not...")
     sess = Session().get_current_session(self)
     if sess == None:
         self.response.out.write("<br/>You are not logged in!!")
     else:
         self.response.out.write("<br/>You are logged in as:")
         email = sess.get_email()
         self.response.out.write("<br/>" + email)
开发者ID:jshankhour1990,项目名称:userinfuser,代码行数:9,代码来源:test.py

示例4: post

  def post(self):
    current_session = Session().get_current_session(self)
    acc = current_session.get_account_entity()
    a_type = self.request.get("type")
    if a_type not in VALID_ANALYTICS:
      return json.dumps({'success':'false'})

    values = getattr(self, a_type + "_values")(acc)
    self.response.out.write(json.dumps(values))
开发者ID:AppScale,项目名称:UserInfuser,代码行数:9,代码来源:analytics.py

示例5: check_login

 def check_login(self, *args):
   if self.request.method != 'GET' and self.request.method != 'POST':
     self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None))
   else:
     user_session = Session().get_current_session(self)
     if user_session == None:
       self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_LOGIN, None))  
     else:
       logging.info("LEGIT user session! Email: " + user_session.get_email())
       handler_method(self, *args)
开发者ID:Yonnick,项目名称:userinfuser,代码行数:10,代码来源:utils.py

示例6: post

 def post(self):
   current_session = Session().get_current_session(self)
   account_entity = current_session.get_account_entity()
   email = account_entity.email
   bk = self.request.get("bk")
   json_ret = {'success':True,
               'reason':'Success. Badge has been deleted'}
   json_ret = json.dumps(json_ret)
   try:
     bk = badges_dao.create_badge_key_with_id(email, bk)
     badges_dao.delete_badge(bk)
   except Exception, e:
     json_ret = {'success':False,
               'reason':'Unable to remove badge' + str(e)}
开发者ID:DrOctogon,项目名称:UserInfuser,代码行数:14,代码来源:console.py

示例7: get

 def get(self):
   """ Ask for which widget, and then render that widget """
   widget = self.request.get("widget")
   current_session = Session().get_current_session(self)
   account = current_session.get_account_entity()
   
   if widget == "rank":
     widget_ref = account.rankWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_RANK
   elif widget == "points":
     widget_ref = account.pointsWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_POINTS
   elif widget == "leaderboard":
     widget_ref = account.leaderWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD
   elif widget == "notifier":
     widget_ref = account.notifierWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER
   elif widget == "milestones":
     widget_ref = account.milestoneWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES
   else:
     widget = "trophycase"
     widget_ref = account.trophyWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE  
     
   values = {"status":"success"}
   properties = widget_ref.properties()
   for property in properties:
     values[property] = getattr(widget_ref, property)
   
   
   show_with_data = self.request.get("withdata")
   if(show_with_data == "yes"):
     """ add appropriate dummy data """
     if widget == "trophycase":
       values["badges"] = self.getDummyBadges()
     elif widget == "rank":
       values["rank"] = str(format_integer(random.randint(1,1000)))
     elif widget == "points":
       values["points"] = str(format_integer(random.randint(1,10000)))
     elif widget == "leaderboard":
       pass
     elif widget == "notifier":
       pass
     elif widget == "milestones":
       pass  
     
   
   self.response.out.write(template.render(render_path, values))
开发者ID:DrOctogon,项目名称:UserInfuser,代码行数:50,代码来源:console.py

示例8: post

  def post(self):
    #TODO
    # IN the future we should try to move this logic to data access utility layer
    # and have the handler portion be in console.py
    current_session = Session().get_current_session(self)
    account = current_session.get_account_entity()
    if not account:
      self.response.out.write("Problem with your account. Please email support.")
      return  

    #TODO make sure badge name is not taken, or warn if overwritting
    badge_name = self.request.get("badgename")
    badge_name = string.replace(badge_name, " ", "_")
    badge_name = string.replace(badge_name, "-", "_")

    badge_theme = self.request.get("badgetheme")
    badge_theme= string.replace(badge_theme, "-", "_")
    badge_theme = string.replace(badge_theme, " ", "_")

    badge_des = self.request.get("badgedescription")

    upload_files = self.get_uploads('file')
    blob_info = upload_files[0]

    badge_file_name = blob_info.filename
    badge_ext = get_file_ext(badge_file_name)     
    if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES:
      self.redirect_error("Image must be png, jpeg, or gif")
      return 
      
    logging.info("File ext:"+badge_ext)
    if not badge_name:
      self.redirect_error("No name given")
      return 
    if not badge_des:
      self.redirect_error("No description given")
      return 
    if not badge_theme: 
      self.redirect_error("No theme given")
      return 
    if not blob_info:
      self.redirect_error("No file given")
      return 
    if blob_info.size > constants.MAX_BADGE_SIZE:
      self.redirect_error("File is too large. Must be smaller than " + str(constants.MAX_BADGE_SIZE) + " bytes")
      return 
    perm = "private"
    if account.email == constants.ADMIN_ACCOUNT:
      perm = "public" 

    badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm)

    badge = badges_dao.create_badge_type(badge_key,
                      badge_name,
                      badge_des,
                      account,
                      badge_theme,
                      badge_ext,
                      blob_info=blob_info)
    self.redirect('/adminconsole/badges')
    return
    # redirect to badge download for viewing
    values = {"badge_upload_success": True,
              "account_name": account.email,
              "badgekey": badge_key,
              "badgeLink": badge.downloadLink,
              "badgedescription": badge_des,
              "badgealt": badge_des,
              "badgename": badge_name,
              "badgeperm": perm}

    self.response.out.write(template.render(TEMPLATE_PATHS.CONSOLE_DASHBOARD, values))
开发者ID:Yonnick,项目名称:userinfuser,代码行数:72,代码来源:badge.py

示例9: post

  def post(self):
    #TODO
    # IN the future we should try to move this logic to data access utility layer
    # and have the handler portion be in console.py
    current_session = Session().get_current_session(self)
    account = current_session.get_account_entity()
    if not account:
      self.response.out.write("Problem with your account. Please email support.")
      return  

    #TODO make sure badge name is not taken, or warn if overwritting
    badge_name = self.request.get("badgename")
    badge_name = string.replace(badge_name, " ", "_")
    badge_name = string.replace(badge_name, "-", "_")

    badge_theme = self.request.get("badgetheme")
    badge_theme= string.replace(badge_theme, "-", "_")
    badge_theme = string.replace(badge_theme, " ", "_")

    badge_des = self.request.get("badgedescription")

    upload_files = self.get_uploads('file')
    blob_info = upload_files[0]

    badge_file_name = blob_info.filename
    badge_ext = get_file_ext(badge_file_name)     
    if badge_ext not in constants.IMAGE_PARAMS.VALID_EXT_TYPES:
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=BadImageType')
      return 
      
    logging.info("File ext:"+badge_ext)
    if not badge_name:
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=NoNameGiven')
      return 
    if not badge_des:
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=NoDescriptionGiven')
      return 
    if not badge_theme: 
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=NoThemeGiven')
      return 
    if not blob_info:
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=InternalError')
      return 
    if blob_info.size > constants.MAX_BADGE_SIZE:
      delete_blob(blob_info)
      self.redirect('/adminconsole/badges?error=FileTooLarge')
      return 
    perm = "private"
    if account.email == constants.ADMIN_ACCOUNT:
      perm = "public" 

    badge_key = badges_dao.create_badge_key(account.email, badge_theme, badge_name, perm)

    badge = badges_dao.create_badge_type(badge_key,
                      badge_name,
                      badge_des,
                      account,
                      badge_theme,
                      badge_ext,
                      blob_info=blob_info)
    self.redirect('/adminconsole/badges')
开发者ID:AppScale,项目名称:UserInfuser,代码行数:66,代码来源:badge.py

示例10: get

 def get(self):
     sess = Session().get_current_session(self)
     if sess != None:
         sess.terminate()
     self.redirect("/adminconsole")
开发者ID:phamthaithinh,项目名称:UserInfuser,代码行数:5,代码来源:logout.py


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