This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.58 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import config
  2. import models
  3.  
  4. def GET(request):
  5.     return config.template_plugin.render("import.html")
  6.  
  7. def POST(request):
  8.     import_file = request.form['import_file']
  9.     if import_file.filename.strip():
  10.         content = import_file.file.read().strip()
  11.         groups = (i for i in content.split('\n\n') if i.strip())
  12.         for group in groups:
  13.             detail = group.strip().split('\n')
  14.             task = models.Task(description=detail[0].strip())
  15.             for s in datail[1:]:
  16.                 models.SubTask(description=s.strip(), task=task)
  17.         request.redirect('/task/')
  18.     else:
  19.         return "No file to upload"
clone this paste RAW Paste Data