0
通常Web2py錯誤很容易理解,但這讓我很難過。Web2py類型錯誤檢索圖像
我用web2py食譜的例子來製作上傳圖片的縮略圖。它會生成一個縮略圖,但我無法檢索該文件。我得到以下錯誤:
<type 'exceptions.TypeError'>(Can't retrieve auth_user.thumb.a7433c1cbe652f44.jpg)
的文件在上傳目錄,並可以對圖片查看器查看,但我不能從數據庫中調用它。無論是從數據庫管理員還是通過視圖。
這是Traceback,當我點擊從數據庫管理員的鏈接。
Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/www-data/web2py/applications/Urban_Gatherer/controllers/appadmin.py", line 464, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 194, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/applications/Urban_Gatherer/controllers/appadmin.py", line 140, in download
return response.download(request, db)
File "/home/www-data/web2py/gluon/globals.py", line 407, in download
(filename, stream) = field.retrieve(name,nameonly=True)
File "/home/www-data/web2py/gluon/dal.py", line 9332, in retrieve
raise TypeError('Can\'t retrieve %s' % name)
TypeError: Can't retrieve auth_user.thumb.a7433c1cbe652f44.jpg
我不知道什麼是錯的。
這裏是我的控制器
def make_thumb(table, image_id, size=(250, 250)):
import os
from PIL import Image
this_image = table(image_id)
im = Image.open(os.path.join(request.folder, 'uploads', this_image.avatar))
im.thumbnail(size, Image.ANTIALIAS)
thumb= 'auth_user.thumb.%s.jpg' % this_image.avatar.split('.')[2]
im.save(os.path.join(request.folder, 'uploads', thumb), 'jpeg')
this_image.update_record(thumb=thumb
)
我以爲我是在片失去的東西,但我改爲3,我似乎仍然懷念B16部分。不知道爲什麼?
那完美。你真的瞭解你的東西。謝謝 *我試圖添加評論,但不能把控制器放在這裏,所以我加了問題。這是配方。 – 4BY 2013-04-29 04:28:57