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. 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.
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:
ajax = db.StringProperty(multiline=True)
Also note that db.StringProperty can only be used for strings of 500 characters or less.
精彩评论