Re: Problem with put_attachment

16 views
Skip to first unread message

Alexander Shorin

unread,
Feb 14, 2013, 3:48:47 AM2/14/13
to couchdb...@googlegroups.com
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.
>
>

Matthew Woodward

unread,
Feb 16, 2013, 12:55:55 AM2/16/13
to couchdb...@googlegroups.com
Ah-ha! Thanks for the tip. Rolling along quite well now.
--
Matthew Woodward
ma...@mattwoodward.com
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint, etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html
Reply all
Reply to author
Forward
0 new messages