Ejemplo n.º 1
0
 def get(self):
   rows = Row.all()
   logging.info('Found %d rows',rows.count())
 
   template_vars = {
     'rows': rows,
     'rowcount': rows.count(),
     'sep': cgi.escape(self.request.get("sep")) or ','
   }
   path = os.path.join(os.path.dirname(__file__),"index.html")
   self.response.out.write(template.render(path,template_vars))
Ejemplo n.º 2
0
 def get(self):
   rows = Row.all()
   logging.info('CSV requested. Found %d rows',rows.count())
   if rows.count() > 0:
     self.response.headers['Content-Type'] = "application/csv"
     writer = encoding.UnicodeWriter(self.response.out,delimiter=cgi.escape(self.request.get("sep").__str__()),quotechar='"')
     for row in rows:
       writer.writerow(row.cols)
   else:
     print "Content-Type: text/html"
     print
     print "<h1>No data to display ...</h1>"
Ejemplo n.º 3
0
  def post(self):
    text = self.request.get('lines')
    sep = self.request.get('sep') or ','
    
    logging.info("line %s - sep %s",text,sep)
    
    rows = rows_from_string(text,sep)
    db.put(rows)
    
    all_rows = Row.all()

    template_vars = {
      'rows': all_rows,
      'rowcount': all_rows.count(),
      'sep': cgi.escape(sep)
    }
      
    path = os.path.join(os.path.dirname(__file__),"index.html")
    self.response.out.write(template.render(path,template_vars))