Hi Dave,

Great find, yes it seems that the Documents API design is somewhat App
Engine un-friendly. I've filed a bug to remedy this.

http://code.google.com/p/gdata-python-client/issues/detail?id=278

My proposed solution, not yet tested, to replace the _DownloadFile method in
gdata.docs.service to something like the following

  def _GetFile(self, uri, file_handle):
    server_response = self.request('GET', uri)
    if server_response.status != 200:
      raise gdata.service.RequestError, {'status': server_response.status,
                                         'reason': server_response.reason,
                                         'body': server_response.read()}
    file_handle.write(server_response.read())

  def _DownloadFile(self, uri, file_path):
    """Downloads a file.

    Args:
      uri: string The full Export URL to download the file from.
      file_path: string The full path to save the file to.

    Raises:
      RequestError: on error response from server.
    """
    f = open(file_path, 'wb')
    try:
      self._GetFile(uri, f)
    except gdata.service.RequestError, e:
      f.close()
      raise e
    f.flush()
    f.close()


I haven't tested this yet but if you are feeling brave feel free to try it
out. You could then call _GetFile directly and pass in a StringIO object for
your file handle.

Happy coding,

Jeff

On Thu, Aug 20, 2009 at 6:12 AM, Dave <dabo...@gmail.com> wrote:

>
> I'm using gdata.docs.service to download a list of a user's
> spreadsheets using GetDocumentListFeed. I want to now let the user
> select a specific spreadsheet so my app can download its contents, do
> some manipulation, and then save a copy of the modified spreadsheet
> back to their Google Docs account (with a new filename).
>
> To grab the contents of their spreadsheet, I thought I could use the
> "Download" method on the results of GetDocumentListFeed.
> Unfortunately, this method requires a location to write the downloaded
> file to, and AppEngine doesn't let its apps write files to disk (or so
> I've read). So what is the recommended way to do this? I'd be happy
> getting the contents of the file as a data structure in memory,
> containing something like csv data. I don't need to deal with XML. Any
> suggestions, or pointers to documentation, would be appreciated.
>
> Thanks,
> Dave
> >
>

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

Reply via email to