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


Python Account.query方法代码示例

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


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

示例1: server_expired

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def server_expired():
    server = get_server(request.form['server'])
    sender = '[email protected]' + get_application_id() + '.appspotmail.com'
    site_url = 'http://' + get_application_id() + '.appspot.com'
    for account in Account.query():
        message = mail.EmailMessage(sender=sender, to=account.email)
        message.subject = "Server expire notification: %s" % server.server_name
        show_url = url_for('server.show', server_key=server.key.urlsafe())
        message_body = "Server %s is expired at %s\n %s%s" \
                       % (server.server_name, server.expire_date,
                          site_url, show_url)

        if server.blocked:
            url = 'http://%s/manager/expired/%s'\
                    % (server.ip_address, server.token)
            result = fetch_server_url(url=url, retry_count=3)
            if result.status_code == 200:
                if result.content == 'TRUE':
                    message_body += '\n Server %s is blocked upon expiry, %s'\
                                    % (server.server_name, server.expire_date)
                else:
                    message_body += '\n %s' % result.content
            else:
                message_body += '\n Unable to reach %s to block upon expiry, %s'\
                                % (server.server_name, server.expire_date)

        message.body = message_body
        message.send()

    return make_response('')
开发者ID:ariunbayar,项目名称:isp,代码行数:32,代码来源:tasks.py

示例2: delete

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def delete(account):
    encoded_key = request.args["account"]
    acc = ndb.Key(urlsafe=encoded_key)
    acc.delete()
    flash(u"Account deleted!")

    return render_template("account/accounts.html", account=account, accounts=Account.query())
开发者ID:ariunbayar,项目名称:isp,代码行数:9,代码来源:__init__.py

示例3: add

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def add(account):
    if request.method == "POST":
        account = Account()
        account.email = request.form["email"]
        account.role = request.form["role"]
        account.put()
        flash(u"Account added!")
        return render_template("account/accounts.html", account=account, accounts=Account.query())
    else:
        return render_template("account/account_add.html", account=account)
开发者ID:ariunbayar,项目名称:isp,代码行数:12,代码来源:__init__.py

示例4: check

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
    def check(*args, **kwargs):
        user = users.get_current_user()
        if user:
            email = user.email()
            account = Account.query().filter(Account.email==email.lower()).get()
            if isinstance(account, Account):
                kwargs.update({'account': account})
                return fn(*args, **kwargs)

        return abort(403)
开发者ID:ariunbayar,项目名称:isp,代码行数:12,代码来源:decorator.py

示例5: check_server_user_limit

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def check_server_user_limit():
    sender = '[email protected]' + get_application_id() + '.appspotmail.com'
    site_url = 'http://' + get_application_id() + '.appspot.com'
    servers = Server.query()
    accounts = Account.query()
    for server in servers:
        if server.user_limit:
            for account in accounts:
                message = mail.EmailMessage(sender=sender, to=account.email)
                message_body = ''
                show_url = url_for('server.show', server_key=server.key.urlsafe())
                url = 'http://%s/manager/user_count/%s'\
                      % (server.ip_address, server.token)
                result = fetch_server_url(url=url, retry_count=3)
                if result.status_code == 200:
                    user_count = result.content

                    if user_count > server.user_limit:
                        message.subject = "Server expire notification: %s" % server.server_name
                        message_body += "User limit reached on %s." \
                                        "User limit: %s, Current users: %s\n %s%s" \
                                        % (server.server_name, server.user_limit,
                                           user_count, site_url, show_url)

                        if server.blocked:
                            url = 'http://%s/manager/add_user_blocked/%s'\
                                  % (server.ip_address, server.token)
                            result = fetch_server_url(url=url, retry_count=3)

                            user_blocked = result.content
                            if user_blocked == 'TRUE':
                                message_body += "Server %s add user is restricted to %s" \
                                                % (server.server_name, server.user_limit)
                            else:
                                message_body += '\n %s' % user_blocked
                else:
                    message_body += 'Unable to reach %s to retrieve user count \
                                    upon user limit check' % server.server_name

                message.body = message_body
                message.send()

    return make_response('hello')
开发者ID:ariunbayar,项目名称:isp,代码行数:45,代码来源:tasks.py

示例6: list

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def list(account):
    return render_template("account/accounts.html", account=account, accounts=Account.query())
开发者ID:ariunbayar,项目名称:isp,代码行数:4,代码来源:__init__.py

示例7: get_account

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import query [as 别名]
def get_account(email):
    account = Account.query().filter(Account.email==email).get()
    return account
开发者ID:ariunbayar,项目名称:isp,代码行数:5,代码来源:helpers.py


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