以下で非常に奇妙なエラーが発生しています。
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self, resource):
iconKey = str(urllib.unquote(resource))
if iconKey:
blob_info = blobstore.get(iconKey)
if blob_info:
url = images.get_serving_url(blob_key=iconKey, size=200)
self.response.out.write('<h1>%s</h1><small>%s</small><br/><br/><img src="%s" alt="%s">' % ('A Title', '11-26-1997', url, 'A Title'))
応答は次のとおりです。
TypeError: get() takes exactly 1 argument (2 given)
このコードは、URL 要求の末尾を取得してiconKey
var に渡し、それを blob キーとして使用して画像の blobstore にアクセスし、images.get_serving_url()
メソッドでサービス URL を作成することを想定しています。
誰もこれに遭遇しましたか?@staticmethod
定義にパラメーターを追加しようとしましget
たが、もちろん、get
メソッドが を介してリクエストにアクセスできなくなりましたself
。
編集
何かを変更したところ、別のエラーが発生しました。私はURL に([^/]+)?
正規表現を使用していました。URL はどこで、メソッドに/view/icon/76M5e-xIStHRJDYyXBXjDA==
渡されるリソースは URL の末尾になります。get()
76M5e-xIStHRJDYyXBXjDA==
(.*)
以下の@systempuntooutの回答に従って、正規表現を変更するだけです。今、私はこのエラーを受け取ります:AttributeError: split
このスタックトレースで:
ERROR 2011-07-15 13:19:39,949 __init__.py:463] split
Traceback (most recent call last):
File "/Users/mac/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 700, in __call__
handler.get(*groups)
File "/Users/mac/icondatabase/main.py", line 72, in get
iconKey = str(urllib.unquote(self.request))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py", line 1164, in unquote
File "/Users/mac/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob/webob/__init__.py", line 500, in __getattr__
raise AttributeError(attr)
AttributeError: split
INFO 2011-07-15 13:19:39,958 dev_appserver.py:4217] "GET /view/icon/76M5e-xIStHRJDYyXBXjDA== HTTP/1.1" 500 -
INFO 2011-07-15 13:19:40,250 dev_appserver.py:4217] "GET /favicon.ico HTTP/1.1" 404 -