Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem updating doc
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mandel  
View profile  
 More options Jul 17 2009, 1:52 am
From: Mandel <eti...@gmail.com>
Date: Thu, 16 Jul 2009 22:52:15 -0700 (PDT)
Local: Fri, Jul 17 2009 1:52 am
Subject: Problem updating doc
Hello there,

I have been doing some work with the API and I have found the
following problem:

Currently I have my objects that returns a dictionary(get_object_data
method) in order to easily serialize it in to a JSON object. This work
perfectly when creating a new doc. The problem I found is when I want
to update a doc in the database doing the following:

# add object
person.id = db.create(person.get_object_data())
person.name = "test"
doc = db[person.id]
# I get all the data because although in the example I just changed
name, thee are cases where more is changed.
doc = person.get_object_data()

Bare in mind that the dict returned bey )get)object_data is usually
like this:

{
    'surname': 'de la Pena',
    'addresses': [
        {
            'city': 'Brussels',
            'country': 'Belgium',
            'state': 'Brussels',
            'street': 'Rue du Prevot',
            'postcode': '1050',
            'address_type': 'Work',
            'type': 'Address',
            'location': 'Local'
        }, {
            'city': 'Madrid',
            'country': 'Spain',
            'state': 'Madrid',
            'street': 'C/Caracas 19 6 drch',
            'postcode': '28010',
            'address_type': 'Work',
            'type': 'Address',
            'location': 'Local'}],
      'social_accounts': [],
      'middleName': '',
      'title': 'Mr.',
      'comments': '',
      'id': u'49e43cf1bb70d65f7235c1ee1809d707',
      'webs': [],
      'ims': [],
      'preferred_address':
      {
          'city': 'Madrid',
          'country': 'Spain',
          'state': 'Madrid',
          'street': 'C/Caracas 19 6 drch',
          'postcode': '28010',
          'address_type': 'Work',
          'type': 'Address',
           'location': 'Local'
       },
       'numbers': [
            {
                  'regional_code': '',
                  'international_code': '',
                  'type': 'TelephoneNumber',
                  'number': '22333',
                  'number_type': 'Work'
            },
            {
                  'regional_code': '',
                  'international_code': '',
                  'type': 'TelephoneNumber',
                  'number': '9231933',
                  'number_type':
                  'Work'
             }],
             'printMode': 0,
             'logo': '',
             'type': 'Person',
             'emails': [
                  {
                        'email_type': 'Home',
                        'type': 'EmailAddress',
                        'email': 'eti...@gmail.com',
                        'format': 'Internet'
                  },
                  {
                        'email_type': 'Home',
                        'type': 'EmailAddress',
                        'email': 'man...@themacaque.com',
                        'format': 'Internet'
                  }],
     'name': 'Manuel'

}

When executing the above code I get the following exception:

File "/var/lib/python-support/python2.6/couchdb/client.py", line 527,
in update
    raise TypeError('expected dict, got %s' % type(doc))
TypeError: expected dict, got <type 'str'>

Which I find very odd,
 can anyone give me a hand with this.

Kr,

Mandel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Goodall  
View profile  
 More options Jul 17 2009, 4:20 am
From: Matt Goodall <matt.good...@gmail.com>
Date: Fri, 17 Jul 2009 09:20:15 +0100
Local: Fri, Jul 17 2009 4:20 am
Subject: Re: Problem updating doc
2009/7/17 Mandel <eti...@gmail.com>:

It's quite difficult to help because your example doesn't actually
call Database.update(docs) anywhere.

However, from the exception, it looks like one of the documents you
passed to update is a string (a str instance). Each document must be
either a dict (or subclass) instance or something with a dict-like
items() method.

- Matt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »