コード例 #1
0
ファイル: views.py プロジェクト: 19emtuck/CheesePrism
def upload(context, request):
    """
    The interface for disutils upload
    """
    if not (request.method == 'POST' and 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())
    request.index.update_by_request(request)
    request.response.headers['X-Swalow-Status'] = 'SUCCESS'
    return request.response
コード例 #2
0
ファイル: views.py プロジェクト: SMFOSS/CheesePrism
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 {}
コード例 #3
0
ファイル: views.py プロジェクト: bbinet/CheesePrism
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']
        filename = fieldstorage.filename
        dest = path(request.file_root) / utils.secure_filename(filename)

        dest.write_bytes(fieldstorage.file.read())
        try:
            request.registry.notify(event.PackageAdded(request.index, path=dest))
            request.response.headers['X-Swalow-Status'] = 'SUCCESS'
            return request.response
        except :
            logger.exception("Processing of %s failed", filename)
            raise
    return {}
コード例 #4
0
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']
        filename = fieldstorage.filename
        dest = path(request.file_root) / utils.secure_filename(filename)

        dest.write_bytes(fieldstorage.file.read())
        try:
            request.registry.notify(
                event.PackageAdded(request.index, path=dest))
            request.response.headers['X-Swalow-Status'] = 'SUCCESS'
            return request.response
        except:
            logger.exception("Processing of %s failed", filename)
            raise
    return {}
コード例 #5
0
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 {}