当前位置: 首页>>代码示例>>Python>>正文


Python DocumentProcessor.errors方法代码示例

本文整理汇总了Python中core.document_processor.DocumentProcessor.errors方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentProcessor.errors方法的具体用法?Python DocumentProcessor.errors怎么用?Python DocumentProcessor.errors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.document_processor.DocumentProcessor的用法示例。


在下文中一共展示了DocumentProcessor.errors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload

# 需要导入模块: from core.document_processor import DocumentProcessor [as 别名]
# 或者: from core.document_processor.DocumentProcessor import errors [as 别名]
def upload(request, template_name='browser/upload.html', extra_context=None):
    """Upload file processing.

    Uploaded file will be check against available rules to
    determine storage, validator, and security plugins.
    """
    extra_context = extra_context or {}

    form = UploadForm(request.POST or None, request.FILES or None)
    if request.method == 'POST':
        if form.is_valid():
            processor = DocumentProcessor()
            upl_file = form.files['file']
            # finding file in system. Updating if found and storing new if not or uncategorized.
            dms_file = processor.read(upl_file.name, {'user': request.user, 'only_metadata': True})
            if not processor.errors and not dms_file.get_docrule().uncategorized:
                processor.update(upl_file.name, {'user': request.user, 'update_file': upl_file})
            else:
                processor.errors = []
                processor.create(upl_file, {'user': request.user})
            # Handling processor errors in interactions.
            if not processor.errors:
                if dms_file.get_docrule().uncategorized:
                    messages.success(request, 'File has been uploaded into uncategorized.')
                else:
                    messages.success(request, 'File has been uploaded.')
                log.info('browser.upload file: %s sucess' % form.files['file'].name)
            else:
                error_string = "; ".join([unicode(x) for x in processor.errors])
                messages.error(request, error_string)
                log.error('browser.upload errror: %s' % error_string)

    extra_context['form'] = form
    return render(request, template_name, extra_context)
开发者ID:acrooo,项目名称:Adlibre-DMS,代码行数:36,代码来源:views.py


注:本文中的core.document_processor.DocumentProcessor.errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。