0

这是我的代码:

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 -

所以我找不到错误,

你是否 。

谢谢

4

2 回答 2

5

您正在尝试将结果存储到 counter.ajax 中,这是一个没有 multiline=True 的 StringProperty。在 'ajax' 的定义中设置 multiline=True,或者用 TextProperty() 替换它。后者几乎可以肯定是正确的答案 - TextProperties 可以更长,并且没有索引。

于 2010-11-04T09:16:15.087 回答
3

错误在您的 Counter 模型中。

“ajax”需要是一个多行字符串属性。请参阅类型和属性类文档

你会想做:

ajax = db.StringProperty(multiline=True)

另请注意,db.StringProperty 只能用于 500 个字符或更少的字符串。

于 2010-11-04T09:15:36.160 回答