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
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 {}
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 {}
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 {}
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 {}