Hi Matt!
db.save() doesn't returns saved document, but (_id, _rev) tuple[1]
according to saved document while db.put_attachment expected dict-like
object as first argument - your `foo` variable.
http://code.google.com/p/couchdb-python/source/browse/couchdb/client.py#386
--
,,,^..^,,,
On Thu, Feb 14, 2013 at 10:32 AM, Matt Woodward <
ma...@mattwoodward.com> wrote:
> I'm writing a script to slice and dice a bunch of XML files and save things
> to CouchDB, and I'd like to include the original XML file as an attachment
> when I save the CouchDB doc.
>
> Everything's going great except for saving the attachment. When I do this:
> doc = db.save(foo)
> f = open('/path/to/file.xml')
> db.put_attachment(doc, f)
>
> I get this error:
> File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line 635,
> in put_attachment
> resource = self.resource(doc['_id'])
> TypeError: tuple indices must be integers, not str
>
> Any ideas? I'm on Python 2.7.3 and CouchDB-Python 0.8.
>
> Happy to provide additional details.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "CouchDB-Python" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
couchdb-pytho...@googlegroups.com.
> To post to this group, send email to
couchdb...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/couchdb-python?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>