How to write data by dynamic parameter name
- by Maxim Welikobratov
I need to be able to write data to datastore of google-app-engine for some known entity. But I don't want write assignment code for each parameter of the entity. I meen, I don't want do like this
val_1 = self.request.get('prop_1')
val_2 = self.request.get('prop_2')
...
val_N = self.request.get('prop_N')
item.prop_1 = val_1
item.prop_2 = val_2
...
item.prop_N = val_N
item.put()
instead, I want to do something like this
args = self.request.arguments()
for prop_name in args:
item.set(prop_name, self.request.get(prop_name))
item.put()
dose anybody know how to do this trick?