本文整理汇总了Python中model.user.User.gql方法的典型用法代码示例。如果您正苦于以下问题:Python User.gql方法的具体用法?Python User.gql怎么用?Python User.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import gql [as 别名]
def check(self):
if self._is_xhr:
from model.user import User
user = User.gql('WHERE name = :1', self.params['name']).get()
result = {'ok': user is None}
self.render(json=self.to_json(result))
else:
self.render(text='')
示例2: create
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import gql [as 别名]
def create(self):
"""
Create the ID
"""
try:
# retrieve the parameters
u = self.params['user']
if len(u['name']) < 2 or len(u['name']) > 16:
raise 'ID 長度有誤'
from google.appengine.api import users
from model.user import User
from model.counter import Counter
from random import randint
user = User.gql('WHERE name = :1', u['name']).get()
if user is not None:
raise 'ID 重覆'
guser = users.get_current_user()
# create user entity
user = User(key_name=guser.email(),
name=u['name'],
email=guser.email())
user.put()
# add user counter
shard_name = randint(0, 3)
counter = Counter.get_by_key_name('user_counter_%d' % shard_name)
if counter is None:
counter = Counter(key_name='user_counter_%d' % shard_name, name="user_counter")
counter.count += 1
counter.put()
if self.session.has_key('error'):
del self.session['error']
self.session.put()
self.redirect('/auth')
except Exception, ex:
self.session['error'] = ex
self.session.put()
self.redirect('/signup')