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?