I'm trying to assemble a basic login system using Flask, Flask-Login, and Flask-MongoKit.
Here's my User
class:
class User(Document):
__collection__ = 'users'
structure = {
'username': basestring,
'password': basestring,
'date_created': datetime
}
required_fields = ['username', 'password']
default_values = {
'date_created': datetime.utcnow
}
When I connect the Document model to the database (db.register([User])
), querying against the document (db.User.one({'username': form.username})
) gives me this lovely error:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
I don't understand this error at all, and I have no idea how to fix it. What's going wrong?
NOTE: I understand what a metaclass conflict is. What I don't see is how I've caused one: it seems to be triggered somewhere inside MongoKit.
The problem turned out to be that I was importing the class wrong (I was feeding the parent module to db.register
instead of the class.