{"action":"closed","issue":{"url":"https://api.github.com/repos/heynemann/motorengine/issues/123","repository_url":"https://api.github.com/repos/heynemann/motorengine","labels_url":"https://api.github.com/repos/heynemann/motorengine/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/heynemann/motorengine/issues/123/comments","events_url":"https://api.github.com/repos/heynemann/motorengine/issues/123/events","html_url":"https://github.com/heynemann/motorengine/issues/123","id":167216229,"number":123,"title":"When attribute has underscore, pulling self._values returns a keyerror on 2nd hit.","user":{"login":"davidchua","id":68039,"avatar_url":"https://avatars2.githubusercontent.com/u/68039?v=4","gravatar_id":"","url":"https://api.github.com/users/davidchua","html_url":"https://github.com/davidchua","followers_url":"https://api.github.com/users/davidchua/followers","following_url":"https://api.github.com/users/davidchua/following{/other_user}","gists_url":"https://api.github.com/users/davidchua/gists{/gist_id}","starred_url":"https://api.github.com/users/davidchua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidchua/subscriptions","organizations_url":"https://api.github.com/users/davidchua/orgs","repos_url":"https://api.github.com/users/davidchua/repos","events_url":"https://api.github.com/users/davidchua/events{/privacy}","received_events_url":"https://api.github.com/users/davidchua/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-24T04:16:37Z","updated_at":"2018-02-21T20:52:47Z","closed_at":"2018-02-21T20:52:47Z","author_association":"NONE","body":"Version: 0.9.0\n\nWhen attempting to output a Document's fields, if there is an attribute with an underscore (ie. **_aasm_state**), it will return an error on the 2nd time a self._values is called.\n\n```\n      File \"/home/davidc/.virtualenvs/tgb_tornado/lib/python3.5/site-packages/motor/__init__.py\", line 627, in _callback\n        callback(result, None)\n      File \"/home/davidc/.virtualenvs/tgb_tornado/lib/python3.5/site-packages/motorengine/queryset.py\", line 469, in handle\n        obj = self.__klass__.from_son(doc)\n      File \"/home/davidc/.virtualenvs/tgb_tornado/lib/python3.5/site-packages/motorengine/document.py\", line 60, in from_son\n        field_values[field.name] = cls._fields[field.name].from_son(value)\n    KeyError: 'aasm_state'\n```\n\nMy Model:\n\n``` python\nclass Trip(MongoDocument):\n  # fields definition\n\n  def output(self):\n      return self._values\n```\n\nExample Object\n\n```\n    {\n      \"_aasm_state\": \"traveller_requested\",\n      \"updated_at\": \"2016-07-24T10:44:30.275000\",\n      \"created_at\": \"2016-07-24T00:51:44.103000\",\n    }\n```\n\nWhen I remove the attribute **_aasm_state**, calls made to `trip.output()` repeatedly returns no errors.\n\nAlso, if I were to add a debugger in\n\n```\ndef output(self):\n    import ipdb;ipdb.set_trace();\n    return self._values\n```\n\nAnd make a single call, the debugger will hit the breakpoint twice instead of once.\n"}}
{"actor":{"display_login":"danielkiedrowski"}}