hmarr/mongoengine — Issue #380: indexes in Abstract document
Author: koblas
Created: 2011-12-02 19:26:57+00:00
State: open

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).

class UserModelMixin(Document):
meta = {
'abstract' : True,
'index' : ['user_guid'],
}

user_guid = StringField(required=True)

def __init__(self, user=None, *args, **kwargs):
super(UserModelMixin, self).__init__(*args, **kwargs)

if user:
self.user_guid = user.guid
self._user_cache = user

@property
def user(self):
if not hasattr(self, '_user_cache'):
self._user_cache = User.objects.get(guid=self.user_guid)
return self._user_cache