I'm looking at this page as a guide:
http://code.google.com/apis/documents/docs/1.0/developers_guide_python.html#UpdatingReplaceContent


I am able to create new empty document:

new_entry = gdata.GDataEntry()
new_entry.title = gdata.atom.Title(text='MyGDataCreatedDocument02')
category = gdata.atom.Category
(scheme=gdata.docs.service.DATA_KIND_SCHEME,
term=gdata.docs.service.DOCUMENT_KIND_TERM)
new_entry.category.append(category)

created_entry = client.Post(new_entry, '/feeds/documents/private/
full')
print 'Document now accessible online at:',
created_entry.GetAlternateLink().href

Questions:
1) Is there a simple way to set the content of the file from a string
at the same time it is created?
Something simple like this:
   new_entry.setContent( "<h1>hello world</h1>")

2) I also was trying to understand the section called "Replacing a
document's content".
But it seems to show only how to update a word.doc from a local
computer.  I wish to set the
contents of the GoogleDoc from a string that I generate in my Python
code.  So I tried the "append" example as follows:

new_entry = gdata.GDataEntry()
new_entry.title = gdata.atom.Title(text='MyGDataCreatedDocument04')
category = gdata.atom.Category
(scheme=gdata.docs.service.DATA_KIND_SCHEME,
term=gdata.docs.service.DOCUMENT_KIND_TERM)
new_entry.category.append(category)

created_entry = client.Post(new_entry, '/feeds/documents/private/
full')
print 'Document now accessible online at:',
created_entry.GetAlternateLink().href

myContent = "<h1>hello world</h1>"

import StringIO

ms = gdata.MediaSource(file_handle=StringIO.StringIO(myContent),
content_type='text/plain', content_length=len(myContent))
updated_entry = client.Put(ms, new_entry.GetEditMediaLink().href + '?
append=true')

and I get error:
AttributeError: 'NoneType' object has no attribute 'href'.

Thanks,
Neal Walters









--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Docs Data APIs" group.
To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com
To unsubscribe from this group, send email to 
google-docs-data-apis+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to