I have been working with django and appengine-python frameworks. But I still can't understand its model implementation.
For example:
In Django
class user(models.Model):
name = models.CharField()
age = models.IntegerField()
after this for saving the model
u = user(name="foo",age=23)
u.save()
On Appengine python
class user(ndb.Model):
name = ndb.StringProperty()
age = ndb.IntegerProperty()
after this is done for saving to datastore
u =user()
u.name = "foo"
u.age = 23
u.put()
I know this kind of implementation is achieved through inheritance but the thing that i can't understand is how are they getting value of the properties for saving through put or save method.
what my question is.
suppose i have base class b with which i derive a class c and class b already has a method put which gets the attribute information from c to does some specific process. how can i implement this kind of design in python ?
Kindly help me out.
Aucun commentaire:
Enregistrer un commentaire