# HG changeset patch # User Jeff Hammel # Date 1330624951 28800 # Node ID ee29001674af62ed39f92e179a00a2dad13c5bef # Parent 1bdece293671c83e4d31ad7f6197fa057eef66b5 begin to make a temporary copy (though itd be better to work in memory, ideally) diff -r 1bdece293671 -r ee29001674af simpypi/wsgi.py --- a/simpypi/wsgi.py Thu Mar 01 09:30:41 2012 -0800 +++ b/simpypi/wsgi.py Thu Mar 01 10:02:31 2012 -0800 @@ -4,7 +4,9 @@ """ import os -#from handlers import Index +import pkginfo +import shutil +import tempfile from webob import Request, Response, exc here = os.path.dirname(os.path.abspath(__file__)) @@ -47,15 +49,31 @@ """handle posting a package""" # get the package - package = request.POST.get('package') + try: + package = request.POST['package'] + except KeyError: + # sanity check: does the field exist? + return exc.HTTPBadRequest() + + # sanity check: is it a file? (TODO) + if not hasattr(package, 'file') or not hastattr(package, 'filename'): + return exc.HTTPBadRequest() + + # successful response + response = exc.HTTPSeeOther(add_slash=True) - # sanity check: - # - does the field exist? - # - is it a file? - # TODO - + # make a temporary copy for pkginfo + # (or PaInt?) + tmpdir = tempfile.mkdtemp() + try: + path = os.path.join(tmpdir, filename) + f = file(path, 'w') + import pdb; pdb.set_trace() + f.close() # put the package in the right place + finally: + # cleanup + shutil.rmtree(tmpdir) # redirect to the main page - return exc.HTTPSeeOther(add_slash=True) - + return response