本文整理匯總了Python中model.Entry.image方法的典型用法代碼示例。如果您正苦於以下問題:Python Entry.image方法的具體用法?Python Entry.image怎麽用?Python Entry.image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類model.Entry
的用法示例。
在下文中一共展示了Entry.image方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from model import Entry [as 別名]
# 或者: from model.Entry import image [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
#.........這裏部分代碼省略.........