{"action":"created","issue":{"url":"https://api.github.com/repos/nicolaiarocci/eve/issues/265","labels_url":"https://api.github.com/repos/nicolaiarocci/eve/issues/265/labels{/name}","comments_url":"https://api.github.com/repos/nicolaiarocci/eve/issues/265/comments","events_url":"https://api.github.com/repos/nicolaiarocci/eve/issues/265/events","html_url":"https://github.com/nicolaiarocci/eve/issues/265","id":28216976,"number":265,"title":"Trouble serializing list of dicts","user":{"login":"joshvillbrandt","id":3335568,"avatar_url":"https://avatars.githubusercontent.com/u/3335568?v=3","gravatar_id":"","url":"https://api.github.com/users/joshvillbrandt","html_url":"https://github.com/joshvillbrandt","followers_url":"https://api.github.com/users/joshvillbrandt/followers","following_url":"https://api.github.com/users/joshvillbrandt/following{/other_user}","gists_url":"https://api.github.com/users/joshvillbrandt/gists{/gist_id}","starred_url":"https://api.github.com/users/joshvillbrandt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshvillbrandt/subscriptions","organizations_url":"https://api.github.com/users/joshvillbrandt/orgs","repos_url":"https://api.github.com/users/joshvillbrandt/repos","events_url":"https://api.github.com/users/joshvillbrandt/events{/privacy}","received_events_url":"https://api.github.com/users/joshvillbrandt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-02-25T02:08:02Z","updated_at":"2015-08-26T01:02:47Z","closed_at":"2014-02-25T09:43:51Z","body":"I have a schema that contains the rollowing relavent pieces:\r\n\r\n```python\r\nmyresource = {\r\n    'schema': {\r\n\r\n        'roles': {\r\n            'type': 'list',\r\n            'required': True,\r\n            'schema': {\r\n                'type': 'dict',\r\n                'schema': {\r\n\r\n                    ID_FIELD: {\r\n                        'type': 'objectid',\r\n                        'required': True,\r\n                    },\r\n                    'name': {\r\n                        'type': 'string',\r\n                        'minlength': 1,\r\n                        'maxlength': 255,\r\n                        'required': True,\r\n                    }\r\n\r\n                }\r\n            }\r\n        }\r\n\r\n    }\r\n}\r\n```\r\n\r\nWhen I do a PUT request against an individual document with two `roles`, the first id will be serialized just fine, but the second id gets a message like this: `roles: {\"1\":{\"_id\":\"value '530bf8ca85f27a2007a76a18' cannot be converted to a ObjectId\"}}`.\r\n\r\nI did some digging into `serialize()` function in common.py. I can't quite understand [this chunk of code](https://github.com/nicolaiarocci/eve/blob/develop/eve/methods/common.py#L302-L316):\r\n\r\n```python\r\nif 'dict' in (field_type, field_schema.get('type', '')):\r\n    # either a dict or a list of dicts\r\n    embedded = [document[field]] if field_type == 'dict' \\\r\n        else document[field]\r\n    for subdocument in embedded:\r\n        # serialize subdocument\r\n        if 'schema' in field_schema:\r\n            serialize(subdocument,\r\n                      schema=field_schema['schema'])\r\n        # serialize fields of subdocuments\r\n        for subfield, v in subdocument.items():\r\n            subfield_type = \\\r\n                field_schema[subfield].get('type')\r\n            if subfield_type in app.data.serializers:\r\n                document[field][subfield] = \\\r\n                    app.data.serializers[subfield_type](v)\r\n```\r\n\r\nIt seems like all of the subdocuments fields are serialized once under `# serialize subdocument` and then again in `# serialize fields of subdocuments`. If I comment out the lines under `# serialize fields of subdocuments`, everything works as expected. Are these pieces of code doing the same thing?\r\n\r\nI imagine you're covering for schema scenarios that aren't presented in my resource definition, but this chunk of code is a bit convoluted, so I don't understand what's going on. Any ideas?"},"comment":{"url":"https://api.github.com/repos/nicolaiarocci/eve/issues/comments/134781903","html_url":"https://github.com/nicolaiarocci/eve/issues/265#issuecomment-134781903","issue_url":"https://api.github.com/repos/nicolaiarocci/eve/issues/265","id":134781903,"user":{"login":"Eibriel","id":172656,"avatar_url":"https://avatars.githubusercontent.com/u/172656?v=3","gravatar_id":"","url":"https://api.github.com/users/Eibriel","html_url":"https://github.com/Eibriel","followers_url":"https://api.github.com/users/Eibriel/followers","following_url":"https://api.github.com/users/Eibriel/following{/other_user}","gists_url":"https://api.github.com/users/Eibriel/gists{/gist_id}","starred_url":"https://api.github.com/users/Eibriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eibriel/subscriptions","organizations_url":"https://api.github.com/users/Eibriel/orgs","repos_url":"https://api.github.com/users/Eibriel/repos","events_url":"https://api.github.com/users/Eibriel/events{/privacy}","received_events_url":"https://api.github.com/users/Eibriel/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T01:02:47Z","updated_at":"2015-08-26T01:02:47Z","body":"Error validating a list of ObjectIDs, on Python 3.4 and EVE 0.5.4 via PIP on virtualenv (linux)\r\n\r\n### Scheme\r\n```\r\nproducts': {\r\n        'type': 'list',\r\n        'schema': {\r\n            'type': 'objectid',\r\n            'data_relation': {\r\n                'resource': 'products',\r\n                'field': '_id'\r\n            }\r\n        }\r\n    }\r\n```\r\n\r\n### Error\r\n```\r\n{\"_status\": \"ERR\", \"_issues\": {\"products\": {\"0\": \"value '5595f431d052ac00092f541d' cannot be converted to a ObjectId\"}}}\r\n```"}}