本文整理汇总了Python中models.Message.max_id方法的典型用法代码示例。如果您正苦于以下问题:Python Message.max_id方法的具体用法?Python Message.max_id怎么用?Python Message.max_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.max_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import max_id [as 别名]
def get(self):
# Get the id that indicate where is the start point of new messages:
current_id = int(self.request.get('id'))
messages = Message.all().order('-postID').filter("postID > ", current_id)
msg_set = messages.fetch(10)
self.response.headers['Content-Type'] = 'text/xml'
self.response.headers['Cache-Control'] = 'no-cache'
# Start writing the xml content:
self.response.out.write('<?xml version="1.0"?>\n')
self.response.out.write(' <response>\n')
self.response.out.write(' <id>%d</id>\n' % Message.max_id() )
for msg in msg_set:
if not msg.isRemoved:
self.response.out.write(' <message>\n')
self.response.out.write(' <author>%s</author>\n' % msg.author.nickname() )
self.response.out.write(' <postID>%d</postID>\n' % msg.postID )
self.response.out.write(' <content>%s</content>\n' % msg.content )
self.response.out.write(' <rcount>%d</rcount>\n' % msg.rCount )
self.response.out.write(' <time>%s</time>\n' % msg.postDate )
self.response.out.write(' </message>\n')
self.response.out.write(' </response>\n')
示例2: post
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import max_id [as 别名]
def post(self):
message = Message()
user = users.get_current_user()
if user:
message.author = user
#Added the content to the message:
message.content = cgi.escape(self.request.get('content'))
#Assigned the id to the message:
message.postID = Message.max_id() + 1
message.put()