本文整理汇总了Python中model.Tag.count_pic方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.count_pic方法的具体用法?Python Tag.count_pic怎么用?Python Tag.count_pic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Tag
的用法示例。
在下文中一共展示了Tag.count_pic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import count_pic [as 别名]
def post(self):
if users.is_current_user_admin():
key = self.request.get('key')
if key :
e = db.get(key)
else:
e = Entry()
type = self.request.get('type')
if not type:
type = 'link'
title = self.request.get('title')
e.title = title.replace('&','&').replace('<','<').replace('>','>')
url = self.request.get('url')
purl= self.request.get('purl')
if type == 'pic' and not key:
e.url = purl.replace('&','&').replace('<','<').replace('>','>')
else:
e.url = url.replace('&','&').replace('<','<').replace('>','>')
content = self.request.get('content')
e.content = content
if not key:
e.addtime +=datetime.timedelta(hours=+8)
e.private = bool(int(self.request.get('private')))
e.type = type
if type =='pic' and not key:
if url:
try:
result = urlfetch.fetch(url)
if result.status_code == 200:
e.image = db.Blob(result.content)
except :
self.response.out.write('获取图片超时!')
return
else:
myfile = self.request.get("myfile")
if not myfile:
self.response.out.write( '没有选择文件!')
return
try:
e.image = db.Blob(myfile)
except :
self.response.out.write( '文件上传失败!')
return
if key:#更新数据
for oldtag in e.tags:
tag = Tag.all().filter('name',oldtag)
if(tag.count(1)>0):
t = tag.get()
if type == 'link':
t.count_link -=1
if type == 'note':
t.count_note -=1
if type == 'pic':
t.count_pic -=1
t.put()
else:#新增数据
max_pageCount =900 #超过此数据,则pageid递增
entry = Entry.all().order('-addtime')
if entry.count()>0:
cur_pageid = entry.get().pageid
else:
cur_pageid = 0
cur_pageCount = entry.filter('pageid =',cur_pageid).count(1000)
if cur_pageCount>=max_pageCount:
e.pageid = cur_pageid+1
else:
e.pageid = cur_pageid
e.tags = []
tag_names = self.request.get('tags').split()
for tag_name in tag_names:
tag = Tag.all().filter('name',tag_name)
if(tag.count(1)>0):
t = tag.get()
if type == 'link':
t.count_link +=1
if type == 'note':
t.count_note +=1
if type == 'pic':
t.count_pic +=1
t.usetime = datetime.datetime.now()
t.put()
else:
t = Tag()
t.name = tag_name
if type == 'link':
t.count_link =1
#.........这里部分代码省略.........