本文整理匯總了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)