def save(self, id = None): if id is None: abort(404) ser = self.mc.get(id.encode('ascii')) if ser is None: abort(404) u = jsonpickle.Unpickler() phone = u.restore(ser) if not isinstance(phone, model.Phone): abort(404) for k, v in self.form_result.items(): if getattr(phone, k) != v: setattr(phone, k, v) p = jsonpickle.Pickler() self.mc.set(phone.id, p.flatten(phone)) response.status_int = 302 response.headers['location'] = h.url_for(controller = 'phone', action = 'view', id = id) return "Moved temporarily"
def create(self): phone = model.Phone() for k, v in self.form_result.items(): setattr(phone, k, v) p = jsonpickle.Pickler() self.mc.set(phone.id, p.flatten(phone)) response.status_int = 302 response.headers['location'] = h.url_for(controller = 'phone', action = 'view', id = phone.id) return "Moved temporarily"