I'd like to create a Model Class for an User. The data of the user are stored in an document based database like couchdb or mongodb. The class User should have an decorator and the fields ind the db are accessible over not really existing class attributes. For example
@DocumentDB()
class User(object):
def doSomething(self):
pass
def doSomethingElse(self):
pass
u = User('thisIsAUniqUserId')
print u.emailAddress
print u.lastName
I've played around with python decorators. Manipulating existing functions is not a big thing but how can i catch the call for not existing getters/setters to create transparent access to db values trough the instance of the object?