在 google app engine 上使用 urlfetch 时我的代码错误在哪里
这是我的代码:
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 -
所以我找不到错误,
你是吗?
谢谢
this is my code:
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('/')
and the error is :
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 -
so i cant find the error ,
did you .
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试将结果存储到 counter.ajax 中,这是一个没有 multiline=True 的 StringProperty。在“ajax”的定义中设置 multiline=True,或者将其替换为 TextProperty()。后者几乎肯定是正确的答案 - TextProperties 可以更长,并且没有索引。
You're attempting to store the result into counter.ajax, which is a StringProperty that does not have multiline=True. Either set multiline=True in the definition of 'ajax', or replace it with a TextProperty(). The latter is almost certainly the correct answer - TextProperties can be longer, and aren't indexed.
错误出在您的计数器模型中。
“ajax”需要是多行字符串属性。请参阅类型和属性类文档。
您需要执行以下操作:
另请注意,db.StringProperty 只能用于 500 个字符或更少的字符串。
The error is in your Counter model.
"ajax" needs to be a multiline string property. See the Types and Property Classes documentation.
You'll want to do:
Also note that db.StringProperty can only be used for strings of 500 characters or less.