{"issue":{"created_at":"2011-12-02T19:26:57Z","state":"open","updated_at":"2011-12-05T23:41:09Z","user":{"gravatar_id":"24a895bcec11df8f488a259f518063fc","id":219934,"url":"https://api.github.com/users/koblas","login":"koblas","avatar_url":"https://secure.gravatar.com/avatar/24a895bcec11df8f488a259f518063fc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":2,"body":"When the following base class is used on a subsequent document there is an error tha tthe user_guid is not a approprate field dictionary (in the indexes).  Everything works fine if I change it to to index_background (which isn't present in the subclass).  Makes me belive there is an bug somewhere (I couldn't find it).  \r\n\r\n    class UserModelMixin(Document):\r\n        meta = {\r\n                'abstract' : True,\r\n                'index'  : ['user_guid'],\r\n        }\r\n\r\n        user_guid  = StringField(required=True)\r\n\r\n        def __init__(self, user=None, *args, **kwargs):\r\n            super(UserModelMixin, self).__init__(*args, **kwargs)\r\n\r\n            if user:\r\n                self.user_guid = user.guid\r\n                self._user_cache = user\r\n\r\n        @property\r\n        def user(self):\r\n            if not hasattr(self, '_user_cache'):\r\n                self._user_cache = User.objects.get(guid=self.user_guid)\r\n            return self._user_cache\r\n","assignee":null,"id":2432040,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":380,"labels":[{"name":"pending response","color":"e102d8","url":"https://api.github.com/repos/hmarr/mongoengine/labels/pending+response"}],"title":"indexes in Abstract document","html_url":"https://github.com/hmarr/mongoengine/issues/380","closed_at":null,"url":"https://api.github.com/repos/hmarr/mongoengine/issues/380","milestone":null},"action":"created","comment":{"created_at":"2011-12-05T23:41:09Z","updated_at":"2011-12-05T23:41:09Z","user":{"gravatar_id":"24a895bcec11df8f488a259f518063fc","id":219934,"url":"https://api.github.com/users/koblas","login":"koblas","avatar_url":"https://secure.gravatar.com/avatar/24a895bcec11df8f488a259f518063fc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Two things:\r\n\r\nShouldn't that be ``indexes`` not ``index``\r\n\r\nHere's a simple unittest that fails:\r\n\r\n    import unittest\r\n    from mongoengine import connect, Document, StringField\r\n\r\n    connect('unittest')\r\n\r\n    class Test(unittest.TestCase):\r\n        def test_index_inheritance(self):\r\n            class UserModelMixin(Document):\r\n                meta = {\r\n                        'abstract' : True,\r\n                        'indexes'  : ['user_guid'],\r\n                }\r\n\r\n                user_guid  = StringField(required=True)\r\n\r\n\r\n            class Person(UserModelMixin):\r\n                meta = {\r\n                        'indexes'  : ['name'],\r\n                }\r\n\r\n                name = StringField()\r\n\r\n            Person.drop_collection()\r\n\r\n            test = Person(name=\"test\", user_guid='123')\r\n            test.save()\r\n\r\n            self.assertEquals(1, Person.objects.count())\r\n\r\n    if __name__ == '__main__':\r\n        unittest.main()","id":3025625,"url":"https://api.github.com/repos/hmarr/mongoengine/issues/comments/3025625"}}