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


Python BlogPost.put方法代码示例

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


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

示例1: create_blog_post

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
def create_blog_post(title, blurb, content):

    published = datetime.now() + timedelta(days=-random.randint(1, 50))
    p = BlogPost(title=title, blurb=blurb, content=content, published=published)
    p.put()

    for i in range(0, random.randint(0, 5)):
        random_comment(p)
开发者ID:Docalytics,项目名称:app-engine-datastore-migrations,代码行数:10,代码来源:bootstrap.py

示例2: test_label

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
  def test_label(self):
    for feed_item in None, {}:
      bp = BlogPost(id='x')
      bp.put()
      self.assertEquals('BlogPost x [no url]', bp.label())

    bp = BlogPost(id='x', feed_item={'permalinkUrl': 'http://perma/link'})
    bp.put()
    self.assertEquals('BlogPost x http://perma/link', bp.label())
开发者ID:sanduhrs,项目名称:bridgy,代码行数:11,代码来源:models_test.py

示例3: submitApost

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
  def submitApost(self):
      returnedTags=[]
 
      def Tagupdate (tag):
          #logging.info(self.tags.filter('tag',tag).count())
          if  tag!="" and self.tags.filter('tag',tag).count()==0:#tag does not exist
              return(Tag(tag=tag).put())
          else:
              return(self.tags.filter('tag',tag)[0].key())#otherwise find its key
          
      posttagkeys=[]
     
      if not self.tags:#Tags are empty therefore insert new tags
          posttagkeys=[Tag(tag=tag).put() for tag in self.posttags  if tag!=""]
      elif self.posttags[0]!="": posttagkeys=map(Tagupdate ,self.posttags)
      for key in posttagkeys:
          obj=db.get(key)
          returnedTags.append({"tag":obj.tag,"tagid":obj.key().id()})  
      catnames=[]
      catkeys=[]
      if self.categories:   #categories exist make list of them 
          [catnames.append(catobj.category) for catobj in self.categories]
          [catkeys.append(catobj.key()) for catobj in self.categories]
          catobjs=dict(zip(catnames,catkeys))
          if  self.postcategory in catobjs.keys():catkey=catobjs[self.postcategory]
          else:#this post has a new category
              newcatobj=Category()
              newcatobj.category=self.postcategory 
              newcatobj.put()
              catkey=newcatobj.key()
      else:
          newcatobj=Category()
          newcatobj.category=self.postcategory
          newcatobj.put()
          catkey=newcatobj.key()
   
            
      
      post=BlogPost()
      post.title=self.title
      post.body=self.body
      post.tags=posttagkeys
      post.category=catkey
      post.put()
     
      self.deleteMemcache(self)
      self.refetch(self)
      return(post.key(),returnedTags)
开发者ID:,项目名称:,代码行数:50,代码来源:

示例4: db_build

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
def db_build():
    """ Convert all markdown file in ./data/blog into
        html and put them in the datastore.
    """
    
    # turn on code fencing...and pyshell
    md = markdown2.Markdown(extras=['fenced-code-blocks', 'pyshell'])

    # grab all markdown files and convert them to html
    for filename in get_files_of_type('md', './data/blog'):

        with open(filename, 'r') as f:
            md_text = f.read()
            html = md.convert(md_text)
            title = os.path.basename(filename).rsplit('.', 1)[0].lower()

            post = BlogPost(title=title, markdown=md_text, html=html)
            post.put()

            logging.info("Putting blogpost '{}' into datastore...".format(title))
开发者ID:rlmv,项目名称:mysite,代码行数:22,代码来源:db.py

示例5: post

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
 def post(self):
     name = self.request.get('name')
     user = users.get_current_user()
     if name:
         prof = Profile(
             name=name,
             user=user
         )
         prof.put()
     category_link = self.request.get('category')
     category = Category.all().filter('link = ', category_link).get()
     p = BlogPost(
         title=self.request.get('title'),
         body=self.request.get('body'),
         category=category
     )
     p.teaser = self.makeTeaser(p.body)
     user_name, prof_id = self.getUserNameAndID(user)
     p.author_name = user_name
     p.put()
     self.redirect('/')
开发者ID:yanzay,项目名称:pagankolo,代码行数:23,代码来源:main.py

示例6: post

# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import put [as 别名]
 def post(self):
     subject = self.request.get("subject")
     content = self.request.get("content")
     if subject and content:
         newpost = BlogPost(subject=subject, content=content)
         key = newpost.put()
         memcache.set("front_page", None)
         self.redirect("/unit3/blog/%s" % key.id())
     else:
         self.write(
             blog_post_form,
             {"subject": subject, "content": content, "error": "Both subject and content are required."},
         )
开发者ID:jadinvt,项目名称:gapengine-sbox,代码行数:15,代码来源:blog.py


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