@view_config(renderer='index.html', context=resources.App)
@view_config(name='simple', context=resources.App)
def upload(context, request):
    """
    The interface for disutils upload
    """
    if request.method == 'POST':
        if not hasattr(request.POST['content'], 'file'):
            raise RuntimeError('No file attached') 

        fieldstorage = request.POST['content']
        dest = path(request.file_root) / utils.secure_filename(fieldstorage.filename)

        dest.write_bytes(fieldstorage.file.read())
        pkgdata, _ = request.index.register_archive(dest, registry=request.registry)
        request.registry.notify(event.PackageAdded(request.index,
                                               name=pkgdata['name'],
                                               version=pkgdata['version']))
        request.response.headers['X-Swalow-Status'] = 'SUCCESS'
        return request.response
    return {}
dataset/ETHPy150Open SMFOSS/CheesePrism/cheeseprism/views.py/upload/original