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


Python Session.get_account_entity方法代码示例

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


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

示例1: get

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
 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,代码行数:32,代码来源:console.py

示例2: post

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
  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,代码行数:11,代码来源:analytics.py

示例3: post

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
 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,代码行数:16,代码来源:console.py

示例4: get

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
 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,代码行数:52,代码来源:console.py

示例5: post

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
 def post(self):
   current_session = Session().get_current_session(self)
   account_entity = current_session.get_account_entity()
   email = account_entity.email
   user = self.request.get("id")
   if user == constants.ANONYMOUS_USER:
     json_ret = {"success":False,
                 "reason":"Sorry, you cannot delete this special user."}
     json_ret = json.dumps(json_ret)
     self.response.out.write(json_ret)
     return 
   json_ret = {'success':True,
               'reason':'Success. User has been deleted'}
   json_ret = json.dumps(json_ret)
   user_hash = hashlib.sha1(email + '---' + user).hexdigest()
   users_dao.delete_user(user_hash)
   self.response.out.write(json_ret)
开发者ID:Yonnick,项目名称:userinfuser,代码行数:19,代码来源:console.py

示例6: post

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
  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,代码行数:68,代码来源:badge.py

示例7: post

# 需要导入模块: from serverside.session import Session [as 别名]
# 或者: from serverside.session.Session import get_account_entity [as 别名]
  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,代码行数:74,代码来源:badge.py


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