# HG changeset patch # User Jeff Hammel # Date 1310487509 25200 # Node ID 1ee374416987eb07f72b968ed165588f3a406ee7 # Parent 916d45d4f9218cb8fab17c2841f765c484a69c84 handle more gracefully when no file is uploaded diff -r 916d45d4f921 -r 1ee374416987 uploader/handlers.py --- a/uploader/handlers.py Tue Jul 12 09:08:18 2011 -0700 +++ b/uploader/handlers.py Tue Jul 12 09:18:29 2011 -0700 @@ -53,7 +53,10 @@ def __call__(self): fin = self.request.POST['file'] - _path = fin.filename.replace('..', '_') + try: + _path = fin.filename.replace('..', '_') + except AttributeError: # no file uploaded + return self.redirect(self.link('/')) _path = _path.replace(os.path.sep, '_') _path = os.path.join(self.app.directory, _path) self.write(fin, _path)