本文整理汇总了Python中models.Account.all方法的典型用法代码示例。如果您正苦于以下问题:Python Account.all方法的具体用法?Python Account.all怎么用?Python Account.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_existing
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def find_existing(cls, email):
hash = hashlib.md5(email).hexdigest()
found = Account.all().filter("hash =", hash).get()
if not found:
found = Account.all().filter("hashes =", hash).get()
if not found:
found = Email.all().filter("email =", email).get()
return found
示例2: get
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def get(self, hash):
if Account.all().filter('api_key =', self.request.get('api_key')).get():
if (Account.all().filter('hash =', hash.lower()).get()) or (Account.all().filter('hashes =', hash.lower()).get()):
self.response.out.write("200 OK")
else:
self.error(404)
self.response.out.write("404 User not found")
else:
self.error(403)
self.response.out.write("403 Missing required parameters")
示例3: get
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def get(self):
# We fetch all the accounts
authors = Account.all()
# We fetch the last ten messages
message_query = Message.all().order('-date')
messages = message_query.fetch(10)
# Check if user is logged in
unknown_user = False
if users.get_current_user():
# Generate the logout url
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
anon = False
# We check that the user is registered
accounts = Account.all()
accounts.filter('user = ', users.get_current_user())
account = accounts.get()
if account == None:
unknown_user = True
else:
# Generate the login url
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
anon = True
# Check if user is admin
is_admin = users.is_current_user_admin()
# Choose a random title
titles = ('<a>PINT</a>Spot', '<a>PINT</a>ed', '<a>PINT</a>Me', '<a>PINT</a>Soft', '<a>PINT</a>Hard', '<a>PINT</a>SM', '<a>PINT</a>ware', '<a>PINT</a>BDSM', '<a>PINT</a>BSD', '<a>PINT</a>LSD', '<a>PINT</a>ou (or ubuntu)', '<a>PINT</a>ubuntu', 'i<a>PINT</a>', 'you<a>PINT</a>', 'Google <a>PINT</a>', '<a>PINT</a>Please', '<a>PINT</a>Sorry', '<a>PINT</a>Welcomed', '<a>PINT</a>Again', '<a>PINT</a>guin', 'JustOne<a>PINT</a>', 'JustAnother<a>PINT</a>', 'OneMore<a>PINT</a>', 'Bier&<a>PINT</a>', '<a>PINT</a>OfVodka', '<a>PINT</a>ade', '<a>PINT</a>aid', '<a>PINT</a>ADD', '<a>PINT</a>INC', '<a>PINT</a>agramme', '<a>PINT</a>-A-Gramme', '<a>PINT</a>-A-Kilo', 'Pound-A-<a>PINT</a>', 'Fish<a>PINT</a>', '<a>PINT</a>Sized', 'Mystic<a>PINT</a>', 'Super<a>PINT</a>', 'Hyper<a>PINT</a>', 'Quantic<a>PINT</a>', 'QuantumOf<a>PINT</a>', 'Electro<a>PINT</a>', 'Royal<a>PINT</a>', 'Republican<a>PINT</a>', 'YesWeCan...<a>PINT</a>', 'WhatTheFucking...<a>PINT</a>', 'IVotedFor<a>PINT</a>', 'WhatSThe<a>PINT</a>', '<a>PINT</a>Aday', '<a>PINT</a>IsMine', 'my<a>PINT</a>!', '<a>PINT</a>Book', '<a>PINT</a>Book-Air', 'less Air, more <a>PINT</a>', 'Apple<a>PINT</a>', 'Web<a>PINT</a>', 'Command+<a>PINT</a>', 'Ctrl+Meta+Alt+<a>PINT</a>', ':<a>PINT</a>', '3Click<a>PINT</a>', 'Black<a>PINT</a>', '<a>PINT</a>sh', '<a>PINT</a> (<a>PINT</a> Is Not Twilight)', 'tinP', 'tniP', 'Tonight<a>PINT</a>', 'Coffee<a>PINT</a>', 'Breakfast<a>PINT</a>', 'Bacon<a>PINT</a>', '<a>PINT</a>Pause', '<a>PINT</a>-nic', '<a>PINT</a>Address', '<a>PINT</a>Phone', 'Multi<a>PINT</a>', 'Simple<a>PINT</a>...', 'FourFingers<a>PINT</a>', 'Start<a>PINT</a>', 'Stop<a>PINT</a>', '<a>PINT</a>', '<a>PINT</a>EGER', 'FloatOr<a>PINT</a>', '<a>PINT</a>Pointer', 'Master<a>PINT</a>er', 'License<a>PINT</a>er', 'GNU<a>PINT</a>', '<a>PINT</a>ix', '<a>PINT</a>ux', '<a>PINT</a>ium', '<a>PINT</a>OS', 'ThanksForThe<a>PINT</a>', 'LordOfThe<a>PINT</a>', 'Piss<a>PINT</a>', '<a>PINT</a>8', '666 Number Of The <a>PINT</a>', 'Bug<a>PINT</a>', 'BlueScreenOf<a>PINT</a>', '<a>PINT</a>Panic', '<a>PINT</a>OSleep', '<a>PINT</a>craft', 'War<a>PINT</a>', '<a>PINT</a>OfDead', '<a>PINT</a>sOfTheCaribeans', 'TheLast<a>PINT</a>', '<a>PINT</a>:Revolution', '<a>PINT</a>:Resurrection', 'Evil<a>PINT</a>', 'TheIncredible<a>PINT</a> ', 'X<a>PINT</a> ', 'Y<a>PINT</a>', 'Why<a>PINT</a>', 'Inexhaustible<a>PINT</a>', 'SauronS<a>PINT</a>', 'Sleepy<a>PINT</a>', 'NeverSleep<a>PINT</a>', '<a>PINT</a>Wars', 'P1N7')
random_title = random.choice(titles)
# These values are to be sent to the template
template_values = {
'random_title': random_title,
'unknown_user': unknown_user,
'messages': messages,
'authors': authors,
'url': url,
'url_linktext': url_linktext,
'anon': anon,
'is_admin': is_admin
}
# We get the template path then show it
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
示例4: get_or_init_account
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def get_or_init_account(user):
account = Account.all().filter('user =', user).get()
if account is None:
account = Account(user=user)
account.put()
return account
示例5: process_request
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def process_request(self, request):
""" This function sets up the user object
Depending on the value of require_login, it
can return None as 'profile'.
"""
#Get Google user_id
google_user = users.get_current_user()
account = None
is_admin = False
logging.info(request.META['HTTP_USER_AGENT'])
if google_user:
#Check if the user already has a site profile
user_id = google_user.user_id()
is_admin = users.is_current_user_admin()
q = Account.all()
q.filter('google_user =', google_user)
account = q.get()
if not account:
nickname = hashlib.md5(google_user.nickname()).hexdigest()[:10]
account = Account(user_id = user_id, nickname = nickname)
account.put()
box = Box(title='My Box')
box.put()
request.user = account
Account.current_user_account = account
request.user_is_admin = is_admin
示例6: _handler
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def _handler(self, account_slug, customer_slug, post=False):
user = users.get_current_user()
if user:
account = Account.all()\
.filter('user =', user).filter('slug =', account_slug).get()
customer = Customer.all()\
.filter('account =', account).filter('slug =', customer_slug).get()
if post:
form = CustomerForm(instance=customer, data=self.request.POST)
if form.is_valid():
# Save the data, and redirect to the view page
form.save()
self.redirect(account.get_absolute_url())
else:
form = CustomerForm(instance=customer)
path = os.path.join(os.path.dirname(__file__), 'templates/customer_details.html')
self.response.out.write(template.render(path, {
'account': account,
'customer': customer,
'form': form,
'user': user,
'logout_url': users.create_logout_url("/")
}))
else:
self.redirect(users.create_login_url(self.request.uri))
示例7: get
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def get(self):
account_count = Account.all().count(1000)
app_count = App.all().count(1000)
html = """<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<value>%(app_count)d</value>
<text>Apps</text>
</item>
<item>
<value>0</value>
<text></text>
</item>
<item>
<value>%(account_count)d</value>
<text>Accounts</text>
</item>
</root>
""" % dict(
account_count=account_count, app_count=app_count
)
# return Response(html, content_type="text/xml")
self.response.headers["Content-Type"] = "text/xml"
self.response.write(html)
示例8: __init__
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def __init__(self, user, *args, **kwargs):
super(ExpenseForm, self).__init__(*args, **kwargs)
self.fields['account'].query = Account.all().filter('user =', user)\
.order('name')
self.fields['category'].query = Category.all()\
.filter('user =', user)\
.filter('type =', 'Custo')\
.order('name').fetch(1000)
示例9: _auth
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def _auth(self, *args, **kwargs):
user = users.get_current_user()
if user is None:
return render_json_response(self, {"error": "signed-out"})
account = Account.all().filter("user", user).get()
if account is None:
account = create_account(user)
return func(self, user, account, *args, **kwargs)
示例10: choose_account_page
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def choose_account_page(self):
accounts = Account.all()
template_values = {
'accounts': accounts,
'logout_url': users.create_logout_url("/")
}
path = os.path.join(os.path.dirname(__file__), 'choose_account.html')
self.response.out.write(template.render(path, template_values))
示例11: post
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def post(self):
notice_hash = self.request.path.split('/')[-1]
notice = Notification.all().filter('hash =', notice_hash).get()
target = Account.all().filter('api_key =', self.request.get('api_key')).get()
channel = notice.channel
if notice and channel.status == 'enabled' and channel.target.key() == target.key():
self.response.out.write(notice.dispatch())
else:
self.error(404)
示例12: post
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def post(self, hash):
hash = hash.lower()
target = Account.all().filter("hash =", hash).get()
if not target:
target = Account.all().filter("hashes =", hash).get()
source = Account.all().filter("api_key =", self.request.get("api_key")).get()
channel = Channel.all().filter("target =", target).filter("source =", source).get()
approval_notice = None
if not channel and source and target:
channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
channel.put()
approval_notice = channel.get_approval_notice()
channel.send_activation_email()
if channel:
notice = Notification(channel=channel, text=strip_tags(self.request.get("text")), icon=source.source_icon)
for arg in ["title", "link", "icon", "sticky", "tags"]:
value = strip_tags(self.request.get(arg, None))
if value:
setattr(notice, arg, value)
notice.put()
# Increment the counter on the channel to represent number of notices sent
channel.count += 1
channel.put()
if channel.status == "enabled":
notice.dispatch()
self.response.out.write("OK\n")
elif channel.status == "pending":
self.response.set_status(202)
if approval_notice:
approval_notice.dispatch()
self.response.out.write("OK\n")
else:
self.response.out.write("202 Pending approval")
elif channel.status == "disabled":
self.response.set_status(202)
self.response.out.write("202 Accepted but disabled")
else:
self.error(404)
self.response.out.write("404 Target or source not found")
示例13: checkUser
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def checkUser(self, user):
accounts = Account.all()
user_ids = []
for acc in accounts:
user_ids.append(acc.user_id)
uid = user.nickname()
if uid not in user_ids:
account = Account(key_name=uid, user_id=uid)
account.put()
示例14: handle_hayhay
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def handle_hayhay(**kwargs):
description = 'Hayhaytv'
action = kwargs.get('action', '')
data = kwargs.get('data', {})
if action == 'add_account':
form_data = {
'email': data['identity'],
'password': data['password']
}
resp = requests.post(login_url, data=form_data)
resp_data = resp.json()
if resp_data['object'] == "check_login" and resp_data.get('success', '') == 'success':
acc = Account()
acc.site = 'www.hayhaytv.vn'
acc.identity = data['identity']
acc.password = data['password']
db.session.add(acc)
db.session.commit()
return jsonify({'ok': True})
return jsonify({'ok': False})
elif action == 'login':
acc = Account.query.filter(Account.site == 'www.hayhaytv.vn').order_by(func.random()).limit(1)
if acc.all():
acc = acc.all()[0]
else:
return jsonify({'ok': False, 'error': 'No have account'})
form_data = {
'email': acc.identity,
'password': acc.password
}
requests.post(login_url, data=form_data, cookies={session_key: str(data['cookies'][session_key])})
return jsonify({'ok': True})
elif action == 'get_script_clear_ads':
return jsonify({
'ok': True,
'data': {'url': url_for('static', filename='js/hayhaytv_clear_ads.js', _external=True)}
})
elif action == 'get_info':
return description + ': Login vip, clear ads'
示例15: post
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import all [as 别名]
def post(self):
new_user = Account()
accounts = Account.all()
accounts.filter('nickname = ', self.request.get('nickname'))
nick_already_exist = accounts.get()
if nick_already_exist == None:
new_user.user = users.get_current_user()
new_user.nickname = self.request.get('nickname')
new_user.put()
self.redirect('/')