本文整理汇总了Python中model.user.User.select方法的典型用法代码示例。如果您正苦于以下问题:Python User.select方法的具体用法?Python User.select怎么用?Python User.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import select [as 别名]
def process(self, wxmsg):
user = yield dbutil.do(User.select().where(User.openid == wxmsg.fromusername).get)
xml_data = ElementTree.fromstring(wxmsg.content)
user.latitude = xml_data.find('Latitude').text
user.longitude = xml_data.find('Longitude').text
user.precision = xml_data.find('Precision').text
user.updatetime = datetime.datetime.now()
yield dbutil.do(user.save)
wxmsg.response, wxmsg.responsetime = 1, datetime.datetime.now()
yield super().process(wxmsg)
示例2: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import select [as 别名]
def post(self):
try:
data = json.loads(self.request.body.decode())
code = data['eventcode']
openid = data['openid']
star = None
try:
star = yield dbutil.do(Star.select().where(
(Star.eventcode == code) & (Star.openid == openid)
).get)
except:
pass
if star:
if star.status == 1: # 已经关注
raise RuntimeError
else: # 已经取消关注
star.status = 1
star.updatetime = datetime.datetime.now()
else: # 首次关注
results = yield [
dbutil.do(Event.select(Event.id, Event.code).where(Event.code == code).get),
dbutil.do(User.select(User.id, User.openid).where(User.openid == openid).get)
]
event = results[0]
user = results[1]
star = Star(
eventid=event.get_id(),
eventcode=event.code,
userid=user.get_id(),
openid=user.openid,
createtime=datetime.datetime.now(),
status=1
)
yield dbutil.do(star.save)
self.write(Response(status=1, msg='ok', result={}).json())
except RuntimeError as e:
self.write(Response(msg='sorry,亲,用户已经关注该活动').json())
logging.exception('StarEventHandler error: {0}'.format(str(e)))
except Exception as e:
self.write(Response(msg='sorry,亲,关注活动失败').json())
logging.exception('StarEventHandler error: {0}'.format(str(e)))
示例3: process
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import select [as 别名]
def process(self, wxmsg):
user = yield dbutil.do(User.select().where(User.openid == wxmsg.fromusername).get)
user.subscribe = 0
dbutil.do(user.save)
wxmsg.response, wxmsg.responsetime = 1, datetime.datetime.now()
yield super().process(wxmsg)