I tried the following code and it didn’t work:
class SourceUpdate(webapp.RequestHandler):
def post(self):
id = int(self.request.get('id'))
source = Source.get_by_id(id)
for property in self.request.arguments():
if property != 'id':
source.__dict__[property] = self.request.get(property)
source.put()
self.redirect('/source')
I am posting all the necessary properties but the entry isn’t updated, and no error is shown. How to fix it?
BTW
class Source(db.Model):
#some string properties
You’re bypassing the
__setattr__-like functionality that the models’ metaclass (type(type(source))) is normally using to deal with attribute-setting properly. Change your inner loop to:and everything should work (if all the types of properties can be properly set from a string, since that’s what you’ll get from
request.get).