[英]where is my code error using urlfetch on google app engine
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 谢谢
You're attempting to store the result into counter.ajax, which is a StringProperty that does not have multiline=True. 您正在尝试将结果存储到counter.ajax中,这是一个没有multiline = True的StringProperty。 Either set multiline=True in the definition of 'ajax', or replace it with a TextProperty().
在'ajax'的定义中设置multiline = True,或将其替换为TextProperty()。 The latter is almost certainly the correct answer - TextProperties can be longer, and aren't indexed.
后者几乎可以肯定是正确的答案-TextProperties可以更长,并且不被索引。
The error is in your Counter model. 该错误在您的Counter模型中。
"ajax" needs to be a multiline string property. “ ajax”必须是多行字符串属性。 See the Types and Property Classes documentation .
请参阅“ 类型和属性类”文档 。
You'll want to do: 您需要执行以下操作:
ajax = db.StringProperty(multiline=True)
Also note that db.StringProperty can only be used for strings of 500 characters or less. 另请注意,db.StringProperty仅可用于500个字符或更少的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.