value = getattr(model_instance, property_name) or
setattr(model_instance, property_name, value) 2009/6/6 Ethan Post <[email protected]>: > I want a method which takes a model object and a dictionary and adds a new > record to the model using the the dictionary. The problem is I don't know > how to refer to model.property using a variable. model(property) does not > work. > > MyTable (db.model): > location ... > > def Foo (p_model, p_dict): > for i in p_dict: > # Here is the tricky part, this does not work but you get the idea. > p_model(i) = p_dict[i] > > p_model.put() > > def CallFoo: > m = MyTable() > d = {"key_name":"some_key_123", > "location":"someplace"} > Foo(m, d) > > > > -- It is better to be wrong than to be vague. — Freeman Dyson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
