本文整理汇总了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)