Beispiel #1
0
    def post(self): 
        request = self.request
        report = Report()
       #try:
        name = urllib.unquote(self.request.get('name')) 
        water = urllib.unquote(self.request.get('water')) 
        road = urllib.unquote(self.request.get('road')) 
        text = urllib.unquote(self.request.get('text')) 
        lat = urllib.unquote(self.request.get('lat')) 
        lng = urllib.unquote(self.request.get('lng')) 
        
        report.title = title
        report.name = name
        report.lat = float(lat)
        report.lng = float(lng)
        report.water = int(water)
        report.text = text
        report.road = bool(road)
        report.put()

#        except Exception, e:
            #self.redirect('/ThaiFlood2011/?error=Error, %s'%e)
        error = urllib.unquote(self.request.get('error'))
        startDate = get_startDay()
        
        reports = Report().all().filter('title', title)
        reports.order('-date')
        reports.filter('date >' ,startDate)
            
        template_values = {
                'title' : title,
				'e_msg':error,
                'reports': simplejson.dumps([r.to_dict() for r in reports]),
                'startDate':startDate

        }
        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))