Home Ask Login Register

Developers Planet

Your answer is one click away!

CraigH February 2016

How to model schema for list of embedded dictionaires in python eve

I have a Document where a user has 2 addresses such as below. How would I create a schema for this in python-eve?

Also, How would I create an API request to allow a user to update only the zipcode. Do they have to repost the entire document?

   _id: "joe",
   name: "Joe Bookreader",
   addresses: [
                  street: "123 Fake Street",
                  city: "Faketon",
                  state: "MA",
                  zip: "12345"
                  street: "1 Some Other Street",
                  city: "Boston",
                  state: "MA",
                  zip: "12345"


Nicola Iarocci February 2016

As far as the schema goes, this should do the trick (docs):

'addresses': {
    'type': 'list',
    'schema' {
        'type': 'dict',
        'schema': {
            'street': {'type': 'string'},
            'city': {'type': 'string'},
            'state': {'type': 'string'},
            'zip': {'type': 'string'}

Dot notation is supported for PATCH (update) requests, but not on lists of documents. They are trickier, and hard to do in a RESTful way. There's an open ticket for that right now, but not direct solution yet, I am afraid.

Post Status

Asked in February 2016
Viewed 2,705 times
Voted 7
Answered 1 times


Leave an answer

Quote of the day: live life