CreateDatabase 在 google data api 上经常失败
下面的测试程序应该创建一个新的电子表格:
#!/usr/bin/python
import gdata.spreadsheet.text_db
import getpass
import atom
import gdata.contacts
import gdata.contacts.service
import smtplib
import time
password = getpass.getpass()
client = gdata.spreadsheet.text_db.DatabaseClient(username='[email protected]',password=password)
database = client.CreateDatabase('My Test Database')
table = database.CreateTable('addresses', ['name','email',
'phonenumber', 'mailingaddress'])
record = table.AddRecord({'name':'Bob', 'email':'[email protected]',
'phonenumber':'555-555-1234', 'mailingaddress':'900 Imaginary St.'})
# Edit a record
record.content['email'] = '[email protected]'
record.Push()
它确实做到了,但仅在大约每 5 次运行中进行 1 次。 在 5 次运行中的其他 4 次中,我得到:
Password:
Traceback (most recent call last):
File "./test.py", line 13, in <module>
database = client.CreateDatabase('My Test Database')
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/spreadsheet/text_db.py", line 146, in CreateDatabase
db_entry = self.__docs_client.UploadSpreadsheet(virtual_media_source, name)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/docs/service.py", line 304, in UploadSpreadsheet
return self._UploadFile(media_source, title, category, folder_or_uri)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/docs/service.py", line 144, in _UploadFile
converter=gdata.docs.DocumentListEntryFromString)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/service.py", line 1151, in Post
media_source=media_source, converter=converter)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/service.py", line 1271, in PostOrPut
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 404, 'body': '<HTML>\n<HEAD>\n<TITLE>Not Found</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Found</H1>\n<H2>Error 404</H2>\n</BODY>\n</HTML>\n', 'reason': 'Not Found'}
当我在 appengine 上运行类似的代码时,会发生同样的事情,所以我不认为这个问题是由于连接速度慢造成的(另外,我有一个电缆调制解调器,它的工作原理是约1Mbps)。
那么,为什么是 404? 而且,更重要的是,是否有办法提高 CreateDatabase 调用成功的机会?
The following test program is suppossed to create a new spreadsheet:
#!/usr/bin/python
import gdata.spreadsheet.text_db
import getpass
import atom
import gdata.contacts
import gdata.contacts.service
import smtplib
import time
password = getpass.getpass()
client = gdata.spreadsheet.text_db.DatabaseClient(username='[email protected]',password=password)
database = client.CreateDatabase('My Test Database')
table = database.CreateTable('addresses', ['name','email',
'phonenumber', 'mailingaddress'])
record = table.AddRecord({'name':'Bob', 'email':'[email protected]',
'phonenumber':'555-555-1234', 'mailingaddress':'900 Imaginary St.'})
# Edit a record
record.content['email'] = '[email protected]'
record.Push()
which it does, but only on about every 1 out of 5 runs. On the other 4 out of 5 runs I get:
Password:
Traceback (most recent call last):
File "./test.py", line 13, in <module>
database = client.CreateDatabase('My Test Database')
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/spreadsheet/text_db.py", line 146, in CreateDatabase
db_entry = self.__docs_client.UploadSpreadsheet(virtual_media_source, name)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/docs/service.py", line 304, in UploadSpreadsheet
return self._UploadFile(media_source, title, category, folder_or_uri)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/docs/service.py", line 144, in _UploadFile
converter=gdata.docs.DocumentListEntryFromString)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/service.py", line 1151, in Post
media_source=media_source, converter=converter)
File "/home/jmvidal/share/progs/googleapps/google_appengine/glassboard/gdata/service.py", line 1271, in PostOrPut
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 404, 'body': '<HTML>\n<HEAD>\n<TITLE>Not Found</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Found</H1>\n<H2>Error 404</H2>\n</BODY>\n</HTML>\n', 'reason': 'Not Found'}
The same thing happens when I run similar code on the appengine, so I don't think this problem is due to a slow connection (also, I have a cable modem, which works at about 1Mbps).
So, why a 404? and, more importantly, is there anyway to improve the chances that my CreateDatabase call will succeed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有人告诉我这是一个已知错误在gdata中。
Someone clued me in that this is a known bug in gdata.