Beispiel #1
0
 def save(self, userfile):
     forbidden_files = [".js", ".htm", ".html", ".mp3"]
     for forbidden_file in forbidden_files:
         if userfile.filename.find(forbidden_file) != -1:
             return redirect("/")
     filecontent = userfile.file.read()
     new_file = UserFile(filename=userfile.filename, filecontent=filecontent)
     DBSession.add(new_file)
     DBSession.flush()
     redirect("/view/"+str(new_file.id))
 def setup(self):
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise