本文整理汇总了Python中model.Post.title方法的典型用法代码示例。如果您正苦于以下问题:Python Post.title方法的具体用法?Python Post.title怎么用?Python Post.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import title [as 别名]
def post(self):
post = Post()
post.title = self.request.get('title_input')
post.content = self.request.get('content')
post.tags_commas = self.request.get('tags')
user = users.get_current_user()
post.author = user
post.catalog = self.request.get('blogcatalog')
private = self.request.get('private')
if private:
post.private = True;
else:
post.private = False;
#try: #no need this ugly permalink now!
# permalink = util.get_permalink(post.date,util.translate('zh-CN','en', util.u(post.title,'utf-8')))
# if not permalink:
# raise Exception
#except Exception:
# self.response.out.write("transalte error in title %s = %s<br />\n" % (post.title,util.get_permalink(post.date,util.translate('zh-CN','en', util.u(post.title,'utf-8')))))
# return
#check the permalink duplication problem.
#maxpermalinkBlog = db.GqlQuery("select * from Post where permalink >= :1 and permalink < :2 order by permalink desc",permalink, permalink+u"\xEF\xBF\xBD").get()
#if maxpermalinkBlog is not None:
# permalink = maxpermalinkBlog.permalink+ post.date.strftime('-%Y-%m-%d')
#post.permalink = permalink
post.save()
util.flushCategoryLists()
util.flushArchiveLists()
util.flushTagLists()
util.flushPublicPosts()
return self.redirect(post.full_permalink())
示例2: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import title [as 别名]
def post(self):
my_post = Post()
my_post.title = self.get_argument("title")
my_post.content = self.get_argument("content")
my_post.category_id = int(self.get_argument("category"))
my_post.tags = self.get_model_list(
Tag,
**dict(in_=[("id", self.get_arguments("tags"))])
)
my_post.post_time = datetime.now()
self.insert(my_post)
self.redirect("/admin/posts")
示例3: new_post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import title [as 别名]
def new_post():
post = Post()
post.title = request.form.get("title","untitled")
post.author_id = session['user_id']
post.slug = slugify(post.title)
post.created_at = datetime.datetime.now()
post.updated_at = datetime.datetime.now()
db_session.add(post)
db_session.commit()
return redirect(url_for("edit", id=post.id))
示例4: get_posts_on_page
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import title [as 别名]
def get_posts_on_page(soup,postlist):
# find by id
listdiv=soup.find(id="d_list")
for child in listdiv: #this is the UL under div
if child.name is not None:
for grandchild in child: # this is the lis under uL
if grandchild.name is not None:
post = Post()
time=grandchild.find_all("i")[0]
if time.text!=today:
continue
post.date=unicode(time.text).replace("/","-")
a=grandchild.find_all("a")[0]
post.link=a["href"]
post.title=unicode(a.text).replace("*","")
for grangrandchild in grandchild:
if type(grangrandchild) == NavigableString:
rawstr= unicode(grangrandchild).replace('-','').strip()
if(rawstr.strip()!=""):
post.author=rawstr[0:rawstr.index(" ")]
postlist.append(post)
return postlist