我是python和Google App Engine的新手。我試圖從Nick Johnson博客重構這段代碼以使用webapp2和python 2.7。 http://blog.notdot.net/2009/10/Blogging-on-App-Engine-part-1-Static-serving如何解決此類型錯誤?
無論如何,當我運行下面的代碼時,我得到這個錯誤。
TypeError: get() takes exactly 2 arguments (1 given)
我認爲它可能與路徑變量沒有被定義有關,但我不知道如何定義它。
import webapp2
from google.appengine.ext import webapp
from google.appengine.ext import db
class StaticContent(db.Model):
body = db.BlobProperty()
content_type = db.StringProperty(required=True)
last_modified = db.DateTimeProperty(required=True, auto_now=True)
def get(path):
return StaticContent.get_by_key_name(path)
def set(path, body, content_type, **kwargs):
content = StaticContent(
key_name=path,
body=body,
content_type=content_type,
**kwargs)
content.put()
return content
class MainHandler(webapp2.RequestHandler):
def get(self, path):
content = get(path)
if not content:
self.error(404)
return
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
@systempuntoout給你答案,但我不會把一個方法得到這樣並用它在獲取處理程序中。這可能會導致你的問題。 – aschmid00
您已經刪除了堆棧跟蹤中幾乎所有有用的信息。請在將來包括完整的堆棧跟蹤,而不僅僅是最後一行。 –