1

我有以下模型:

class Book(ndb.Model):
    title = ndb.StringProperty()
    description = ndb.TextProperty()

我的处理程序:

    class UploadBookHandler(webapp2.RequestHandler):
        def post(self):
            title = self.request.get('title')
            logging.info(title)
            description = self.request.get('description')
            logging.info(description)
            #category = Category(id=4785074604081152)
            book = Book()
            book.title=title
            book.description=description
            book.put()
            #todo.category=category

当我 curl --data "title=test&description=testmore" localhost:9082/uploadbook

我不断收到此错误:

ERROR    2013-05-23 09:46:34,174 wsgi.py:219] 
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
    handler = __import__(path[0])
  File "/Users/johnwesonga/projects/todolist/todolist.py", line 26, in <module>
    class UploadTodoHandler(webapp2.RequestHandler):
  File "/Users/johnwesonga/projects/todolist/todolist.py", line 37, in UploadTodoHandler
    book.put()
NameError: name 'book' is not defined
4

0 回答 0