mvantellingen/localshop

Locashop returns 404 when uploading packages.

canassa opened this issue · 1 comments

This is the setup.py output:

python setup.py sdist upload -r titansgroup
running sdist
running egg_info
writing requirements to mock_party.egg-info/requires.txt
writing mock_party.egg-info/PKG-INFO
writing top-level names to mock_party.egg-info/top_level.txt
writing dependency_links to mock_party.egg-info/dependency_links.txt
reading manifest file 'mock_party.egg-info/SOURCES.txt'
writing manifest file 'mock_party.egg-info/SOURCES.txt'
running check
creating mock-party-0.0.1
creating mock-party-0.0.1/mock_party
creating mock-party-0.0.1/mock_party.egg-info
creating mock-party-0.0.1/mock_party/bin
making hard links in mock-party-0.0.1...
hard linking README.rst -> mock-party-0.0.1
hard linking setup.cfg -> mock-party-0.0.1
hard linking setup.py -> mock-party-0.0.1
hard linking mock_party/__init__.py -> mock-party-0.0.1/mock_party
hard linking mock_party/helpers.py -> mock-party-0.0.1/mock_party
hard linking mock_party.egg-info/PKG-INFO -> mock-party-0.0.1/mock_party.egg-info
hard linking mock_party.egg-info/SOURCES.txt -> mock-party-0.0.1/mock_party.egg-info
hard linking mock_party.egg-info/dependency_links.txt -> mock-party-0.0.1/mock_party.egg-info
hard linking mock_party.egg-info/requires.txt -> mock-party-0.0.1/mock_party.egg-info
hard linking mock_party.egg-info/top_level.txt -> mock-party-0.0.1/mock_party.egg-info
hard linking mock_party/bin/mockparty -> mock-party-0.0.1/mock_party/bin
copying setup.cfg -> mock-party-0.0.1
Writing mock-party-0.0.1/setup.cfg
Creating tar archive
removing 'mock-party-0.0.1' (and everything under it)
running upload
Submitting dist/mock-party-0.0.1.tar.gz to http://pypi.titansgroup.net:8000/simple/
Upload failed (404): NOT FOUND
error: Upload failed (404): NOT FOUND

The problem seens in this line:

https://github.com/mvantellingen/localshop/blob/develop/localshop/apps/packages/views.py#L64

        actions = {
            'submit': handle_register_or_upload,
            'file_upload': handle_register_or_upload,
        }

        handler = actions.get(request.POST.get(':action'))
        if not handler:
            raise Http404('Unknown action')

I checked the :action key with ipdb and it contains some blank characters:

ipdb> request.POST.get(':action')
u'\r\nfile_upload\r'

Therefore the actions.get returns None which will cause a 404. I think a simple .strip() call should solve the problem, If you prefer I can send you a PR.

I have no idea why the :action key contains blank characters 😞 It seems I am the first one to stumble into this problem.

I did some further investigation I found that the culprit is the parse_distutils_request function. The bug in distutils that required that custom request body parsing was fixed recently:

http://bugs.python.org/issue10510

I am using Python 2.7.8 and this fix is already applied (and that's weird because that fix was supposed to arrive only with the 2.7.9 release)