CreateDatabase经常在google data api上失败

时间:2009-05-21 20:11:44

标签: python gdata-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='jmv@gmail.com',password=password)
database = client.CreateDatabase('My Test Database')
table = database.CreateTable('addresses', ['name','email',
    'phonenumber', 'mailingaddress'])
record = table.AddRecord({'name':'Bob', 'email':'bob@example.com', 
    'phonenumber':'555-555-1234', 'mailingaddress':'900 Imaginary St.'})

# Edit a record
record.content['email'] = 'bob2@example.com'
record.Push()

它确实如此,但只有大约每5次运行中的1次。在其他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调用成功的机会?

1 个答案:

答案 0 :(得分:1)

有人告诉我,这是gdata中的known bug