这是我的代码:
class save(BaseRequestHandler):
def get(self):
counter = Counter.get_by_key_name('aa-s')
counter.count += 1
url = "http://www.google.com"
result = urlfetch.fetch(url)
if result.status_code == 200:
counter.ajax = result.content
counter.put()
self.redirect('/')
,错误是:
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
handler.get(*groups)
File "F:\ss\Task Queue\main.py", line 48, in get
counter.ajax = result.content
File "D:\Program Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line 542, in __set__
value = self.validate(value)
File "D:\Program Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line 2453, in validate
raise BadValueError('Property %s is not multi-line' % self.name)
BadValueError: Property ajax is not multi-line
INFO 2010-11-04 08:24:29,905 dev_appserver.py:3283] "GET /save HTTP/1.1" 500 -
所以我找不到错误,
是的。感谢
答案 0 :(得分:5)
您正在尝试将结果存储到counter.ajax中,这是一个没有multiline = True的StringProperty。在'ajax'的定义中设置multiline = True,或者用TextProperty()替换它。后者几乎肯定是正确的答案 - TextProperties可以更长,而且没有索引。
答案 1 :(得分:3)
错误出现在您的计数器模型中。
“ajax”需要是多行字符串属性。请参阅Types and Property Classes documentation。
你想做的事:
ajax = db.StringProperty(multiline=True)
另请注意,db.StringProperty只能用于500个字符或更少的字符串。