Skip to content

Instantly share code, notes, and snippets.

@kevpie
Created April 27, 2011 16:25
Show Gist options
  • Save kevpie/944602 to your computer and use it in GitHub Desktop.
Save kevpie/944602 to your computer and use it in GitHub Desktop.
Simple Model to Domain object creation
def update_object(model, obj):
for name, property in model.properties().iteritems():
setattr(obj, name, property.get_value_for_datastore(model))
def to_object(model):
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __cmp__(self, other):
return cmp(self.__dict__, other.__dict__)
DomainType = type(model.kind(), (object,), dict(__eq__=__eq__, __cmp__=__cmp__))
obj = DomainType()
update_object(model, obj)
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment