本文整理汇总了Python中models.Person.all方法的典型用法代码示例。如果您正苦于以下问题:Python Person.all方法的具体用法?Python Person.all怎么用?Python Person.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: look_command
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def look_command(self, msg):
channel = self.person.channel
if not channel:
msg.reply(u'* 您應該先進頻道內再用此一語法查詢.')
return
if not msg.arg:
q = Person.all().filter('channel =', channel)
else:
q = Person.all().filter('channel =', channel).filter('name =', msg.arg)
people = q.fetch(self._NAME_LIMIT + 1)
lines = []
for p in people:
lines.append(u'*** %s email 是 %s' % (p.name, p.user.email()))
msg.reply(u'\n'.join(lines))
示例2: get_person
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def get_person(self, username):
if username == "":
return None
logging.debug("finding person by username: >" + username + "<")
q = Person.all().filter("username =", username)
return q.get()
示例3: UpdateChannelStats
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def UpdateChannelStats(self):
"""Recompute num_members for a channel."""
channel = Channel.ChannelByName(self.request.get('channel'), create=False)
if not channel: return # channel became empty?
num_members = int(self.request.get('num_members', '0'))
q = Person.all(keys_only=True).filter('channel =', channel).order('__key__')
start_at = self.request.get('start_at')
if start_at:
q.filter('__key__ >', db.Key(start_at))
people = q.fetch(self._STATS_BATCH)
if people:
# More to go.
num_members += len(people)
params = {
'channel': channel.name,
'num_members': num_members,
'start_at': str(people[-1]),
}
taskqueue.Task(url='/task/update-channel-stats',
params=params).add('stats')
return
# Finished
channel.num_members = num_members
channel.put()
logging.debug('%s now has %d members.' % (channel, num_members))
示例4: names_command
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def names_command(self, msg):
"""Handle /names commands."""
m = re.match(r'^(#(?P<channel>' + Channel.CHANNEL_NAME_REGEX + '))?$',
msg.arg)
if not m:
msg.reply('* Bad /names syntax')
return
if m.group('channel'):
channel = Channel.ChannelByName(m.group('channel'), create=False)
if not channel:
msg.reply('* No such channel: #%s' % m.group('channel'))
return
else:
channel = self.person.channel
if not channel:
msg.reply('* You either need to be in a channel, or specify one.')
return
q = Person.all().filter('channel =', channel)
people = q.fetch(self._NAME_LIMIT + 1)
if len(people) <= self._NAME_LIMIT:
people = people[0:self._NAME_LIMIT]
names = sorted([str(p) for p in people])
msg.reply('* Members of %s: %s' % (channel, ' '.join(names)))
else:
msg.reply('* More than %d people in %s' % (self._NAME_LIMIT, channel))
示例5: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def get(self):
# 編集確認
person_id = self.request.get("id")
person_obj = ''
if (person_id):
person_obj = Person.get( person_id )
# 所有しない発言者IDを指定された場合は一覧へリダイレクトする
if person_obj and person_obj.owner != users.get_current_user():
self.redirect(urls.APP_PERSON_URL)
return
# 所有する発言者を取得します
query = Person.all()
query.filter( 'owner = ', users.get_current_user() )
query.order('-created_on')
owned_persons = query.fetch(limit = 1000)
# 所有する発言者の名言を取得する
meigens = ''
if person_obj:
query = Meigen.all()
query.filter( 'owner = ', users.get_current_user() )
query.filter( 'person = ', person_obj )
meigens = query.fetch(limit = 1000)
# 画面を表示する
Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, { 'persons': owned_persons, 'current_person': person_obj, 'meigens': meigens } )
示例6: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def get(self):
people = Person.all().order("first_name").order("last_name").fetch(MAX_FETCH_LIMIT)
people_list = []
for person in people:
people_list.append(
person.to_json_dict("first_name", "last_name", "is_starred", "is_active", "is_deleted", "when_created")
)
self.response.out.write(json.dumps(people_list))
示例7: postdeploy
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def postdeploy(self):
if not Person.all(keys_only=True).fetch(limit=1):
key = Person(
key_name="[email protected]", login="ampatspell", password="freak", email="[email protected]"
).put()
self.response["key"] = str(key)
else:
self.respond_with_error("At least one user exists")
示例8: individual
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def individual(self, person_id):
# 発言者取得
person_obj = Person.get(person_id)
message = ''
if (not person_obj):
message = '指定された発言者は登録されていません'
# 発言者の名言を取得
query = Meigen.all().order('-created_on')
query.filter( 'person = ', person_obj )
meigens_of_person = query.fetch( limit = 1000 )
Viewer.generate(Viewer(), self.response, INDIVIDUAL_TEMPLATE_PATH,
{ 'current_person': person_obj,
'current_meigens': meigens_of_person,
'persons': Person.all().order('-created_on'),
'message': message })
示例9: who_command
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def who_command(self, msg):
m = re.match(r'^(#(?P<channel>' + Channel.CHANNEL_NAME_REGEX + '))?$',
msg.arg)
if not m:
msg.reply(u'* /who 後面的頻道名稱似乎有誤')
return
if m.group('channel'):
channel = Channel.ChannelByName(m.group('channel'), create=False)
if not channel:
msg.reply(u'* 沒有您要查的頻道: #%s' % m.group('channel'))
return
else:
channel = self.person.channel
if not channel:
msg.reply(u'* 您應該先進頻道內再用此一語法查詢.')
return
q = Person.all().filter('channel =', channel)
people = q.fetch(self._NAME_LIMIT + 1)
if len(people) <= self._NAME_LIMIT:
people = people[0:self._NAME_LIMIT]
names = sorted([p.name for p in people])
msg.reply(u'* 在 %s 頻道內的人有: %s' % (channel, ', '.join(names)))
else:
msg.reply(u'* 在頻道 %s 的人數超過 %d' % (channel, self._NAME_LIMIT))
示例10: Broadcast
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def Broadcast(self):
channel = Channel.ChannelByName(self.request.get('channel'), create=False)
if not channel: return # channel became empty?
message = self.request.get('message')
skip_person = self.request.get('skip')
if skip_person:
skip_person = Person.PersonByEmail(skip_person)
q = Person.all().filter('channel =', channel).order('__key__')
start_at = self.request.get('start_at')
if start_at:
q.filter('__key__ >', db.Key(start_at))
people = q.fetch(self._BROADCAST_BATCH)
jids = []
for p in people:
if skip_person == p:
continue
jids.append(p.jid())
if not jids:
return
try:
xmpp.send_message(jids, message)
except xmpp.InvalidJidError:
logging.error('InvalidJidError caught. JIDs were [%s]',
', '.join(['"%s"' % x for x in jids]))
raise
# Add a task for the next batch.
params = {
'channel': channel.name,
'message': message,
'start_at': str(people[-1].key()),
}
if skip_person:
params['skip'] = skip_person.jid()
taskqueue.Task(url='/task/broadcast', params=params).add('chats')
示例11: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def get(self):
# 所有する発言者のみ取得する
query = Person.all()
query.filter( 'owner = ', users.get_current_user() )
query.order('-created_on')
owned_persons = query.fetch(limit = 1000)
# 所有する名言のみ取得する
query = Meigen.all()
query.filter( 'owner = ', users.get_current_user() )
query.order('-created_on')
owned_meigens = query.fetch(limit = 1000)
# 編集確認
meigen_id = self.request.get("id")
meigen_obj = ''
if (meigen_id):
meigen_obj = Meigen.get( meigen_id )
# 画面を表示する
Viewer.generate(Viewer(), self.response, TEMPLATE_PATH,
{'persons': owned_persons,
'meigens': owned_meigens,
'current_meigen': meigen_obj })
示例12: all
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import all [as 别名]
def all(self):
people = Person.all().with_cursor(self.request.get("cursor"))
self.response["data"] = [person.to_json() for person in people]
self.response["cursor"] = people.cursor()