本文整理汇总了Python中message.Message.all方法的典型用法代码示例。如果您正苦于以下问题:Python Message.all方法的具体用法?Python Message.all怎么用?Python Message.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message.Message
的用法示例。
在下文中一共展示了Message.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_messages
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import all [as 别名]
def delete_messages(self, mtype = None):
""" Delete messages of a specified kind.
Args:
type: A string of the message type to delete.
Due to timeout issues with App Engine, this method will currently
only succeed when running on App Engine if the number of messages
being deleted is relatively small (~hundreds). It will attempt to
delete up to 1000. The timeout retry wrapper (see
game_server/autoretry_datastore.py) and using keys only search
drastically increases the chances of success, but this method is
still not guaranteed to complete.
For more information see:
http://groups.google.com/group/google-appengine/
browse_thread/thread/ec0800a3ca92fe69?pli=1
http://stackoverflow.com/questions/108822/
delete-all-data-for-a-kind-in-google-app-engine
"""
if mtype:
db.delete(Message.all(keys_only = True).filter('msg_type =', mtype)
.ancestor(self.key()).order('date').fetch(1000))
db.delete(Message.all(keys_only = True).ancestor(self.key()).order('date')
.fetch(1000))
示例2: get
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import all [as 别名]
def get(self):
op = self.request.get('op')
if op == 'test':
for m in Message.all():
m.delete()
elif op == 'request_channel':
channelName = self.request.get('instance_id')
channelToken = channel.create_channel(channelName)
ret = {}
ret['channel_token'] = channelToken
self.out(BaseUtils.asJson(ret))
elif op == 'recent_instances':
recentInstances = []
for instance in ApiMethodsHandler.recentInstances():
recentInstances.append(instance.jsonForm())
self.out(BaseUtils.asJson(recentInstances))
elif op == 'instance_by_id':
instanceId = self.request.get('id')
if instanceId != '':
instance = ApiMethodsHandler.recentInstancesList().recentInstanceById(instanceId)
if instance != None:
self.out(BaseUtils.asJson(instance.jsonForm()))
return
self.out(BaseUtils.asJson({'id':''}))
elif op == 'check_channel':
self.notifyUser(self.request.get('channel'), 'event',
{'data':self.request.get('val')})
self.out('done')
示例3: get_messages_query
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import all [as 别名]
def get_messages_query(self, message_type, recipient,
time = datetime.min, sender = None,
keys_only = False):
""" Return a message query from this instance.
Args:
message_type: The message type to retrieve. If left as None or
the empty string then all messages matching other criteria
will be returned.
recipient: The recipient of the messages to retrieve. All
messages sent with a recipient of the empty string will also
be retrieved.
time: All messages retrieved must have been created after this
time.
sender: The sender of the message.
keys_only: If keys_only is set to true, this will only search
for messages that have recipient = recipient. Thus, it will
only include messages sent with no recipient if recipient
is set to ''.
Returns:
A query object that can be fetched or further modified.
"""
query = Message.all(keys_only = keys_only)
query.ancestor(self.key())
query.filter('date >', time)
if message_type is not None and message_type != '':
query.filter('msg_type =', message_type)
if sender:
query.filter('sender =', sender)
# Avoid doing two queries when we don't need to.
if recipient == '':
query.filter('recipient =', '')
else:
if keys_only:
query.filter('recipient =', recipient)
else:
query.filter("recipient IN", [recipient, ''])
query.order('-date')
return query