def save(self): customer_id = self.request.POST.get('customer_id', None) apt = Appointment.load(self.request.POST.get('appointment_id')) if not apt: apt = Appointment() apt.user_created = self.request.ctx.user.user_id apt.bind(self.request.POST, False) if customer_id != '': apt.customer_id = customer_id apt.save() apt.flush() self.flash('Successfully saved "%s".' % apt.title) if customer_id: return HTTPFound('/crm/appointment/edit_for_customer/%s/%s' % (customer_id, apt.appointment_id)) else: return HTTPFound('/crm/appointment/edit/%s' % apt.appointment_id)