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


Python Account.get_by_id方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
 def post(self, account_id, todo_list_id, todo_item_id):
     self.response.headers['Content-Type'] = 'application/json'
     try:
         account = Account.get_by_id(int(account_id))
         todo_list = TodoList.get_by_id(id=int(todo_list_id), parent=account.key)
         item_data = json.loads(self.request.body)
         todo_iem = TodoItem.get_by_id(id=int(todo_item_id), parent=todo_list.key)
         if todo_iem:
             todo_iem.populate(**item_data)
             todo_iem.put()
             item_dict = todo_iem.to_dict(exclude=['created', 'updated', 'todo_list'])
             item_dict['id'] = todo_iem.key.id()
             self.response.out.write(json.dumps(item_dict))
         else:
             result = {'error': 'Bad Request', 'message': 'Invalid todo item %s' % todo_item_id}
             self.response.set_status(400, json.dumps(result))
             self.response.out.write(json.dumps(result))
     except AttributeError as ae:
         result = {'error': 'Bad request', 'message': ae.message}
         self.response.set_status(400, json.dumps(result))
         self.response.out.write(json.dumps(result))
     except Exception as e:
         result = {'error': 'Unexpected error has occurred', 'message': e.message}
         self.response.set_status(500, json.dumps(result))
         self.response.out.write(json.dumps(result))
开发者ID:gipsy86147,项目名称:mytodolistapp,代码行数:27,代码来源:api.py

示例2: get

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
    def get(self, project_id):
        project_id = int(project_id)
        project = Project.get_by_id(project_id)

        account = get_account()
        projects_posted = account.projects_posted

        is_owner = False
        if project_id in projects_posted:
            is_owner = True

        if project.winner == None:
            bidders = project.bidders
            bidders_expanded = []
            for bidder_id in bidders:
                bidder = Account.get_by_id(bidder_id).guser.email()
                bidders_expanded.append({
                    'id': bidder_id,
                    'email': bidder,
                    'is_owner': is_owner
                })
            response = bidders_expanded
        else:
            response = {'winner': project.winner}
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(response))
开发者ID:N0tinuse,项目名称:senior_project,代码行数:28,代码来源:info.py

示例3: site_check

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
def site_check(user_id):
    account = Account.get_by_id(user_id)
    failed_site_reports = []
    for site in account.sites:
        if site:
            result = urlfetch.fetch(site)
            if result.status_code != 200:
                failed_site_reports.append(
                    "site {} failed with a {} status code".format(
                        site,
                        result.status_code
                    )
                )
    if failed_site_reports:
        failed_site_report = '\n'.join(failed_site_reports)
        message = mail.EmailMessage()
        message.sender = '[email protected][email protected]'
        message.body = """Failures for your site on {}:
        {}
        """.format('downtime-toy.appspot.com', failed_site_report)
        message.subject = "Notification of site failures"
        message.to = account.email
        try:
            message.send()
            logging.info(
                "sent email to {} for failed sites.".format(account.email)
            )
        except:
            logging.warn(
                "failed to send owner email to {} for failed sites.".format(
                    account.email
                )
            )
    else:
        logging.info("no failed sites for email {}".format(account.email))
开发者ID:sagersmith8,项目名称:gae_starter,代码行数:37,代码来源:main.py

示例4: setAccountInfo

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
def setAccountInfo(info):
	e = Account.get_by_id(info['uid'])
	if e:
		pass
	else:
		account = Account(id = info['uid'], uid = info['uid'], name = info['display_name'], country = info['country'], link = info['referral_link'], 
		quota_normal = info['quota_info']['normal'], quota_shared = info['quota_info']['shared'], quota_quota = info['quota_info']['quota'])
		account.put()
开发者ID:var,项目名称:dbxcard,代码行数:10,代码来源:dataaccess.py

示例5: get

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
 def get(self, account_id, todo_list_id):
     self.response.headers['Content-Type'] = 'application/json'
     try:
         account = Account.get_by_id(int(account_id))
         todo_list = TodoList.get_by_id(id=int(todo_list_id), parent=account.key)
         todo_list_dict = todo_list.to_dict(exclude=['account', 'created', 'updated'])
         self.response.out.write(json.dumps(todo_list_dict))
     except Exception as e:
         result = {'error': 'Unexpected error has occurred', 'message': e.message}
         self.response.set_status(500, json.dumps(result))
         self.response.out.write(json.dumps(result))
开发者ID:gipsy86147,项目名称:mytodolistapp,代码行数:13,代码来源:api.py

示例6: inner

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
 def inner(*args, **kwargs):
     handler = args[0]
     account_id = kwargs.get('account_id')
     auth = handler.request.params.get('auth') or handler.session.get('auth')
     if auth:
         account = Account.get_by_id(int(account_id))
         auth_token = AuthToken.query(AuthToken.token == auth, ancestor=account.key).get()
         if auth_token and auth_token.account.id() == int(account_id):
             ret = func(*args, **kwargs)
             return ret
     handler.response.headers['Content-Type'] = 'application/json'
     handler.response.set_status(401, 'Not Authenticated')
     handler.response.out.write(json.dumps({'error': 'Not Authenticated'}))
开发者ID:gipsy86147,项目名称:mytodolistapp,代码行数:15,代码来源:common.py

示例7: get_logged_in_account

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
 def get_logged_in_account(self):
     account_id = self.get_session_id()
     if account_id:
         return Account.get_by_id(long(account_id))
开发者ID:zxul767,项目名称:Wikipages,代码行数:6,代码来源:authenticated.py

示例8: getUserName

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import get_by_id [as 别名]
def getUserName(uid):
	e = Account.get_by_id(int(uid))
	if e:
		return e.name
	else:
		pass
开发者ID:var,项目名称:dbxcard,代码行数:8,代码来源:dataaccess.py


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