GAE博客程序micolog上传出现400错误解决方法
站长在上传micolog时遇到403号错误,通过修改app.yaml文件的第一行的application后面的内容为自己在GAE的Application Identifier后重新上传。果然没有再报Error403。良好的开端是成功的一半。真的是一半,只成功了一半。命令行窗口反馈信息如下:
D:\Program Files\Google\google_appengine>appcfg.py update micolog
Email: [email protected]
Password for [email protected]:
Scanning files on local disk.
Initiating update.
Could not guess mimetype for static/images/favicon.ico. Using application/octet-stream.
Cloning 20 static files.
Cloning 94 application files.
Uploading 12 files.
Closing update.
Uploading index definitions.
Error 400: --- begin server output ---
Creating a composite index failed: This index:
entity_type: "Archive"
ancestor: false
Property {
name: "date"
direction: 2
}
is not necessary, since single-property indices are built in. Please remove it from your index file and upgrade to the latest version of the SDK, if you haven't already.
--- end server output ---
一气之下,直接把index.yaml删除了。上传,一切OK;但在IE中输入网址http://emmune.appspot.com ,结果却返回HTTP 500 错误,信息如下:
无法显示网页
您要访问的网页有问题,无法显示。
--------------------------------------------------------------------------------
请尝试以下操作:
打开 emmune.appspot.com 主页,然后查找指向您感兴趣信息的链接。
单击刷新按钮,或以后再试。
单击搜索,寻找 Internet 上的信息。
也可查看相关站点列表。
HTTP 500 - 内部服务器错误
Internet Explorer
换Google的Chrome浏览器,返回如下信息:
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 501, in __call__
handler.get(*groups)
File "/base/data/home/apps/emmune/1.333551759727376286/base.py", line 68, in _wrapper
method(*args, **kwargs)
File "/base/data/home/apps/emmune/1.333551759727376286/blog.py", line 91, in get
entries,links=Pager(query=entries).fetch(page_index)
File "/base/data/home/apps/emmune/1.333551759727376286/base.py", line 111, in fetch
max_offset = self.query.count()
File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1401, in count
return self._get_query().Count(limit=limit)
File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line 986, in Count
raise _ToDatastoreError(err)
File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line 2020, in _ToDatastoreError
raise errors[err.application_error](err.error_detail)
NeedIndexError: no matching index found.
咦,Chrome浏览器会泄露后台的一些信息?
其实,命令行反馈信息已经说明了问题所在及解决办法,现再强调如下
Property {
name: "date"
direction: 2
}
is not necessary, since single-property indices are built in. Please remove it from your index file
可是当时情急中想到的仍是Google大法。在网上搜索,发现华南理工大学刘锦高同学的博客上有相应处理办法:直接把index.yaml中自动产生的些单属性索引信息删除再上传。但是,什么是单属性索引呢? 联系锦高同学,得到了耐心的答复。比如说,下面这一段有entry_parent、entrytype、published、menu_order等多个属性,是多属性索引。
# Used 6 times in query history.
- kind: Entry
properties:
- name: entry_parent
- name: entrytype
- name: published
- name: menu_order
而以下这段就只有date一个属性,是单属性索引。
# Used 6 times in query history.
- kind: Comment
properties:
- name: date
direction: desc
注意:不能把那些用到的两个以上属性的索引删除了,可能会出现上传成功,但浏览站点时得到的是500错误信息。