当前位置: 首页>>代码示例>>Python>>正文


Python Post.author方法代码示例

本文整理汇总了Python中model.Post.author方法的典型用法代码示例。如果您正苦于以下问题:Python Post.author方法的具体用法?Python Post.author怎么用?Python Post.author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Post的用法示例。


在下文中一共展示了Post.author方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [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')))
开发者ID:phphtmlcreator,项目名称:Very-Small-Forum-For-GAE,代码行数:34,代码来源:main.py

示例2: post

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [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())    
开发者ID:BlowBlood,项目名称:blowblood,代码行数:33,代码来源:blog.py

示例3: post

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [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')))
开发者ID:ahyangyi,项目名称:killard,代码行数:35,代码来源:main.py

示例4: post

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [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))
     preview = self.request.get('preview', None)
     if preview is not None:
       forum = self.getForumInstance()
       postmarkup = create(use_pygments=False)
       body = strip_ml_tags(self.request.get('body'))
       body2 = postmarkup(body)
       template_values = {
         'url' : users.CreateLogoutURL(self.request.uri),
         'user' : user,
         'forum' : forum,
         'topic' : topic,
         'body' : body,
         'body2' : body2,
         'page' : 100
       }
       path = os.path.join(os.path.dirname(__file__), os.path.join('templates', 'previewPost.htm'))
       self.response.out.write(template.render(path, template_values))
       return
   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()
     # index it!
     ix = getdatastoreindex("post_"+str(post.key().id()), schema=SEARCHSCHEMA)
     writer = ix.writer()
     writer.add_document(body=u"%s" % post.body)
     writer.commit()
     # end index
     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')))
开发者ID:itsredwan,项目名称:tunedforum,代码行数:59,代码来源:main.py

示例5: post

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [as 别名]
 def post(self, subdomain, lense=None):
     if self.request.headers['Content-type'] == 'application/json':
         post = Post(**json.loads(self.request.body))
         post.prefix = self.request.uri
         post.author = self.current_user
         post.save(db=self.db)
         self.set_header('Location', post.url)
         self.set_status(201)
     else:
         self.send_error(500)
开发者ID:palimadra,项目名称:dustbin,代码行数:12,代码来源:app.py

示例6: get_posts_on_page

# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import author [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
开发者ID:dahuocang,项目名称:git_repo,代码行数:24,代码来源:pa6.py


注:本文中的model.Post.author方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。