Thanks, I will give this a try. It seems though that I shouldn't have to use a new, untested method for this. Isn't there an established way to do this? Should I instead be using the Spreadsheets API perhaps? If so, can I access it using the same auth session token that my program already obtains for http://docs.google.com/feeds? (2 questions, really)
Thanks, Dave On Aug 21, 2:56 pm, "Jeff S (Google)" <[email protected]> wrote: > 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 <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
