本文整理汇总了Python中post.Post.put方法的典型用法代码示例。如果您正苦于以下问题:Python Post.put方法的具体用法?Python Post.put怎么用?Python Post.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: receive
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def receive(self, message):
post = Post()
html_bodies = message.bodies('text/html')
img_links = []
video_links = []
for content_type, body in html_bodies:
decoded_body = body.decode()
img_links.extend(self.find_image_links(decoded_body))
video_links.extend(self.find_video_links(decoded_body))
if hasattr(message, "attachments") and message.attachments:
post.attachments = []
for attachment in message.attachments:
post.attachments.append(db.Blob(attachment[1].decode()))
plaintext_bodies = message.bodies('text/plain')
allBodies = '';
for body in plaintext_bodies:
allBodies = allBodies + body[1].decode()
if hasattr(message, "subject"):
subject, encoding = decode_header(message.subject)[0]
post.caption = unicode(subject)
post.author = message.sender
post.content = allBodies
post.images = img_links
post.videos = video_links
post.source = "email"
post.put()
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
user = users.get_current_user()
if user:
post = Post(parent = Post.post_db_key(), author = user, content = self.request.get("content"))
post.put()
self.redirect('/')
示例3: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
user = users.get_current_user()
if not user or not users.is_current_user_admin():
self.redirect(users.create_login_url(self.request.uri))
return
post = Post()
post.title = self.request.POST['title']
post.put()
self.redirect('/admin/posts/edit/' + str(post.key.id()))
示例4: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
if not self.user:
self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
created_by = self.user.name
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content, created_by = created_by)
p.put()
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = "subject and content, please!"
self.render("newpost.html", subject=subject, content=content, error=error)
示例5: get_posts
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def get_posts(self):
user = users.get_current_user()
post_list = []
post_query = Post.query(ancestor = Post.post_db_key()).order(-Post.created)
post_list = post_query.fetch(10)
if user and len(post_list) == 0:
post = Post(parent = Post.post_db_key(), author = user, content = 'Hallo Leute! Hier ist mal eine allererste Version des Kollaborationswerkzeugs, ich nenne das erst mal einfach nur <b>Toolbox</b>. In dieser ersten Version kann man allerdings noch nichts machen, ich arbeite dran ;-) Schaut euch die Seite zwei, drei mal am Tag an, ich will zügig Ergebnisse liefern.')
post.put()
post_query = Post.query(ancestor = Post.post_db_key()).order(-Post.created)
post_list = post_query.fetch(10)
return post_list
示例6: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
if not self.user:
self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
created_by = self.user.user_id
display_name = self.user.name
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content,
created_by = created_by, display_name = display_name)
p.put()
#rerun the query and update the cache
Post.get_posts(True)
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = "subject and content, please!"
self.render("newpost.html", subject=subject, content=content, error=error)
示例7: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
bot_test = self.request.get('bot_test').strip().lower()
if (bot_test != 'orange'):
self.redirect('/')
return
post = Post()
if users.get_current_user():
post.author = users.get_current_user().nickname()
url = self.request.get('url').strip()
if url:
if not url.startswith("http"):
url = "http://"+url
post.images = [db.Link(url)]
post.caption = self.request.get('caption')
post.source = "homepage"
post.put()
self.redirect('/')
示例8: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
"""
Creates new post and redirect to new post page.
"""
if not self.user:
return self.redirect('/blog')
subject = self.request.get('subject')
content = self.request.get('content')
if subject and content:
p = Post(parent=blog_key(), user_id=self.user.key().id(),
subject=subject, content=content)
p.put()
self.redirect('/blog/%s' % str(p.key().id()))
else:
error = 'Empty subject and/or content!'
self.render('new-post.html', subject=subject,
content=content, error=error)
示例9: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
# If any user does not logged in redirect to homepage
if not self.user:
self.redirect('/')
values = {
'subject': self.request.get('subject').strip(),
'content': self.request.get('content').strip()}
if values['subject'] and values['content']:
post = Post(
subject=values['subject'],
content=values['content'],
user=self.user)
post.put()
self.redirect(post.link_to('show'))
else:
errors = {}
if not values['subject']:
errors['subject'] = "can't be blank"
if not values['content']:
errors['content'] = "can't be blank"
self.render("/posts/new.html", values=values, errors=errors)
示例10: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import put [as 别名]
def post(self):
self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
postid = self.request.get("postid")
post = self.request.get("post")
user = self.request.get("user")
key = self.request.get("key")
value = self.request.get("value")
query = Post.all()
query.filter("postid = ", postid)
postResult = query.fetch(1000)
post = Post(postid=postid, post=post)
if len(postResult) > 0:
post = postResult[0]
else:
post.put()
tag = Tag(userid=user, postkey=post.key(), tag_key=key, tag_value=value)
tag.put()
query = Relation.all()
query.filter("user = ", user)
followers = query.fetch(1000)
for f in followers:
tag.addToStream(f.follower)
self.response.out.write("Tagged post " + postid + " with " + user + ":" +
key + "=" + value)