本文整理汇总了Python中blog.models.Blog.put方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.put方法的具体用法?Python Blog.put怎么用?Python Blog.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSort
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import put [as 别名]
def testSort(self):
tb1 = Blog(title='first', slug='first', body='first')
tb1.put()
tb2 = Blog(title='second', slug='second', body='second')
tb2.put()
self.assertEqual('second', Blog.query().order(-Blog.posted).fetch(1)[0].title)
示例2: create_blog
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import put [as 别名]
def create_blog(request):
if request.method == 'POST':
items = request.POST
if not items['title'] or not items['slug'] or not items['body']:
messages.error(request, 'Title, Slug, Body are required fields.')
return redirect('create_blog')
b = Blog(title=items['title'], slug=items['slug'], body=str(items['body']))
if 'gtoken' in request.COOKIES:
gitkit_user = gitkit.VerifyGitkitToken(request.COOKIES['gtoken'])
if gitkit_user:
b.author = gitkit_user.email
if get_uploads(request, 'image') and request.FILES.get('image'):
blob_key = get_uploads(request, 'image')[0].key()
b.blob_key = blob_key
b.put()
return HttpResponseRedirect('/')
else:
return render(request, 'blog/create_blog.html', {'upload_url': blobstore.create_upload_url(success_path='/create_blog')})
示例3: testQueryBlog
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import put [as 别名]
def testQueryBlog(self):
tb = Blog(title='abc', slug='abc', body='abc')
tb_key = tb.put()
qry = Blog.query_blog(tb_key)
result = qry.fetch()
self.assertEqual('abc', result[0].body)
示例4: testBlogEntry
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import put [as 别名]
def testBlogEntry(self):
tb = Blog(title='KEIFJUE', slug='PDEMDKS', body='MDOWMF')
tb.put()
result = self.app.get('/')
self.assertIn('KEIFJUE', result.body)
self.assertIn('MDOWMF', result.body)