本文整理汇总了Python中model.User.select方法的典型用法代码示例。如果您正苦于以下问题:Python User.select方法的具体用法?Python User.select怎么用?Python User.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.select方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populate
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def populate(self):
# clear the existing cache
for x in range(0, len(self)):
self.pop()
if self.location != 'global':
location = Location.get(self.location)
if location.is_region:
hubs = location.has_hubs
profile_select = User.select(AND(IN(User.q.homeplaceID, hubs),
User.q.public_field==1,
User.q.active==1,
User.q.description != u"",
User.q.modified > datetime.datetime.now() - datetime.timedelta(days=365))).orderBy('modified').reversed()[:30]
else:
profile_select = User.select(AND(User.q.homeplaceID==location,
User.q.public_field==1,
User.q.active==1,
User.q.description != u"",
User.q.modified > datetime.datetime.now() - datetime.timedelta(days=365))).orderBy('modified').reversed()[:30]
else:
profile_select = User.select(AND(User.q.public_field==1,
User.q.active==1,
User.q.description != u"",
User.q.modified > datetime.datetime.now() - datetime.timedelta(days=365))).orderBy('modified').reversed()[:30]
for profile in profile_select:
cache_obj = self.objectcache_factory(profile)
self.append(cache_obj)
示例2: admin
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def admin(user):
""" Show the admin page """
# This where clause should be (User.is_active is True) to comply
# with PEP-8, but peewee doesn't support that syntax.
users = User.select().where(User.is_active == True).order_by(User.name)
return template.render(
"admin.tpl", users=users, title="Admin", user=user, email_url=(settings.EMAIL_PATH if settings.DEBUG else None)
)
示例3: verify_password
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def verify_password(username, alleged_password):
try:
user = User.select().where(User.username == username).get()
verification = (crypt(alleged_password, user.password) == user.password)
logging.debug('verify_password: username={}, encrypted_password={}, alleged_password={}, verification={}'.format(username, user.password, alleged_password, verification))
if verification:
AuthExt.save(user=user)
return verification
except Exception as e:
logging.exception('verify_password')
return False
示例4: job
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def job(self):
# This where clause should be (User.is_active is True) to comply
# with PEP-8, but peewee doesn't support that syntax.
users = User.select().where(User.is_active == True)
# Send Email Digests (if necessary)
for user in filter(lambda user: user.is_due(self.now), users):
if self.send_email(user, self.create_digest, Subjects.DIGEST):
user.update_last_sent(self.now)
# Send Reminders (if necessary)
for user in filter(lambda user: user.is_late(self.now), users):
if self.send_email(user, self.create_reminder, Subjects.REMINDER):
user.update_last_reminded(self.now)
示例5: locate_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def locate_user(username, apikey):
'''
Select user from database using Username + API Key.
Returns None upon failure.
'''
if not username or not apikey:
logging.info('Trying to locate user but Username/APIKey empty.')
return None
results = User.select().join(ApiKey).where((User.username==username) & (ApiKey.key==apikey))
if results.count() != 1:
logging.info("Unable to locate user.")
return None
return results[0]
示例6: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def get(self):
page = int(self.get_argument("page", 1))
pagesize = self.settings['admin_pagesize']
keyword = self.get_argument("keyword", None)
ft = (User.id > 0)
if keyword:
keyword = keyword + '%'
ft = ft & (User.mobile % keyword)
uq = User.select().where(ft)
total = uq.count()
users = uq.paginate(page, pagesize).order_by(User.signuped.desc())
self.render('admin/user.html', users = users, total = total, page = page, pagesize = pagesize)
示例7: index
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def index(self, program=None):
program = util.session("current_program", identity.current.user.programID, program)
if identity.in_group("global_admin") and int(program) == 0:
userlist = User.select()
program = identity.current.user.programID
elif int(program) == 0:
program = identity.current.user.programID
userlist = User.selectBy(programID=program)
else:
userlist = User.selectBy(programID=program)
programlist = Program.select()
return dict(
program=Program.get(program),
programlist=programlist,
curProg=self.curProg,
userlist=userlist,
shaded=util.shaded,
)
示例8: syncUserGotchis
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def syncUserGotchis():
print "add missing gotchis"
for person in User.select():
downloadGotchi(person.id)
示例9: validate_email
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def validate_email(form, field):
cnt = User.select().where(User.email == field.data).count()
if cnt:
raise ValidationError("This email is already in use.")
示例10: validate_username
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import select [as 别名]
def validate_username(form, field):
cnt = User.select().where(User.username == field.data).count()
if cnt:
raise ValidationError("This username is already in use.")