本文整理汇总了Python中models.Place.select方法的典型用法代码示例。如果您正苦于以下问题:Python Place.select方法的具体用法?Python Place.select怎么用?Python Place.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_enter
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import select [as 别名]
def do_enter():
"""Enter numbers into database"""
numbers = set(parse_numbers(request.forms.get('numbers', '')))
timestamp = datetime.datetime.now()
usr_hash = get_fingerprint(request)
result_num = []
# TODO make place variable, depending on current request
q = Place.select().where(Place.place == 'LAGESO')
lageso = q.get() if q.count() == 1 else None
if not numbers:
result_num.append(_('novalidnumbers'))
else:
for num in numbers:
if is_valid_number(num):
try:
n = Number.create(number=num.upper(), time=timestamp, place=lageso, fingerprint=usr_hash)
result_num.append(n.number)
except IntegrityError:
try:
n = Number.get(Number.number == num.upper())
# FIXME Why ain't there any value placeholder in translation string?
result_num.append(_(u'erruniquenumber') + ': {}'.format(n.number))
except DoesNotExist:
result_num.append(u'Something weired happend with {}'.format(num))
# FIXME result_num is horrible, as it contains success and failures, indistinguishable
return {'entered': result_num, 'timestamp': timestamp.strftime('%x %X')}