本文整理汇总了Python中model.Post.body方法的典型用法代码示例。如果您正苦于以下问题:Python Post.body方法的具体用法?Python Post.body怎么用?Python Post.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.body方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import body [as 别名]
def post(self):
user = self.getAuthentificatedUser()
if not user:
return
try:
id = int(self.request.get('id'))
topic = Topic().get(db.Key.from_path('Topic', id))
except:
self.redirect('/')
return
post = Post(parent=topic.key())
post.topic = topic
if users.get_current_user():
post.author = users.get_current_user()
body = db.Text(strip_ml_tags(self.request.get('body')))
postmarkup = create(use_pygments=False)
post.body = postmarkup(body)
# replace('\n','<br />')
if post.body != '':
post.put()
message = mail.EmailMessage(sender=user.email(), subject="New message in small-forum")
message.to = "log1 <[email protected]>"
message.body = post.body + """ ... testing e-mail notification. Sorry if you get this message accidently."""
message.send()
#topic = Topic().all().filter('id =', int(self.request.get('id')))
#topic = topic[0]
#topic.getUserList()
# To Do
if self.request.get('page'):
self.redirect('/view?id=' + str(self.request.get('id')) + '&page=' + self.request.get('page'))
else:
self.redirect('/view?id=' + str(self.request.get('id')))
示例2: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import body [as 别名]
def post(self):
user = self.getAuthentificatedUser()
if not user:
return
try:
id = int(self.request.get('post_id'))
post = Post().get(db.Key.from_path('Post', id))
if post.author != user:
self.redirect('/')
return
body = db.Text(strip_ml_tags(self.request.get('body')))
postmarkup = create(use_pygments=False)
post.body = postmarkup(body)
# replace('\n','<br />')
if post.body != '':
post.put()
# re-index it!
ix = getdatastoreindex("post_"+str(post.key().id()), schema=SEARCHSCHEMA)
writer = ix.writer()
writer.add_document(body=u"%s" % post.body)
writer.commit()
except:
pass
if self.request.get('page'):
self.redirect('/view?id=' + str(self.request.get('id')) + '&page=' + self.request.get('page'))
else:
self.redirect('/view?id=' + str(self.request.get('id')))
示例3: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import body [as 别名]
def post(self):
user = self.getAuthentificatedUser()
if not user:
return
try:
id = int(self.request.get('id'))
topic = Topic().get(db.Key.from_path('Topic', id))
except:
self.redirect('/')
return
post = Post(parent=topic.key())
post.topic = topic
if users.get_current_user():
post.author = users.get_current_user()
body = db.Text(strip_ml_tags(self.request.get('body')))
postmarkup = create(use_pygments=False)
post.body = postmarkup(body)
# replace('\n','<br />')
if post.body != '':
post.put()
#mailAdditionalText = """ ... testing e-mail notification. Sorry if you get this message accidently."""
#post.sendMailToAll(user.email(), mailAdditionalText)
#####
#message = mail.EmailMessage(sender=user.email(), subject="New message in small-forum")
#message.to = "log1 (sms) <[email protected]>"
#message.body = post.body
#message.send()
#####
# To Do
if self.request.get('page'):
self.redirect('/view?id=' + str(self.request.get('id')) + '&page=' + self.request.get('page'))
else:
self.redirect('/view?id=' + str(self.request.get('id')))