def POST(self): i = web.input() form = forms.writerep() if form.validates(i): print i try: dists = zip2rep.zip2dist(i.zipcode, i.addr1+i.addr2) except zip2rep.BadAddress: dists = [] #print dists if len(dists) != 1: form = add_zip4(form) return self.GET(form) dist = dists[0] captcha = ('captcha' not in i) and writerep.get_captcha_src(dist) if captcha: form = add_captcha(form, captcha) return self.GET(form) msg_sent = writerep.writerep(district=dist, **i) if msg_sent: helpers.set_msg('Your message has been sent.') raise web.seeother('/writerep') else: return self.GET(form)
def GET(self, form=None): form = form or forms.writerep() msg, msg_type = helpers.get_delete_msg() return render.writerep(form, msg=msg)