本文整理汇总了Python中core.document_processor.DocumentProcessor.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentProcessor.delete方法的具体用法?Python DocumentProcessor.delete怎么用?Python DocumentProcessor.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.document_processor.DocumentProcessor
的用法示例。
在下文中一共展示了DocumentProcessor.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_file_delete
# 需要导入模块: from core.document_processor import DocumentProcessor [as 别名]
# 或者: from core.document_processor.DocumentProcessor import delete [as 别名]
def edit_file_delete(request, code):
"""Deletes specified code or revision from system (Marks deleted)
@param request: is a Django request object
@param code is a DMS Object() code for view interactions"""
# Decision of where to go back after or instead of removal
return_url = reverse('mdtui-home')
if 'edit_return' in request.session:
return_url = request.session['edit_return']
if request.method == 'POST':
revision = request.POST.get('revision', False)
if revision:
return_url = reverse('mdtui-edit-revisions', kwargs={'code': code})
processor = DocumentProcessor()
processor.read(code, {'user': request.user, 'only_metadata': True})
if not processor.errors:
# Selecting to delete (Mark deleted) revision or whole document
options = {'user': request.user}
if revision:
options['mark_revision_deleted'] = revision
else:
options['mark_deleted'] = True
processor.delete(code, options)
if not processor.errors:
request.session['cleanup_caches'] = True
return HttpResponseRedirect(return_url)
return HttpResponseRedirect(return_url)
示例2: delete
# 需要导入模块: from core.document_processor import DocumentProcessor [as 别名]
# 或者: from core.document_processor.DocumentProcessor import delete [as 别名]
def delete(self, request, code, suggested_format=None):
# FIXME: should return 404 if file not found, 400 if no docrule exists.
revision, hashcode, extra = self._get_info(request)
processor = DocumentProcessor()
options = {
'revision': revision,
'extension': suggested_format,
'user': request.user,
}
log.debug('FileHandler.delete attempt with %s' % options)
processor.delete(code, options)
if len(processor.errors) > 0:
log.error('Manager Errors encountered %s' % processor.errors)
return rc.BAD_REQUEST
log.info('FileHandler.delete request fulfilled for code: %s, format: %s, rev: %s, hash: %s.' % (code, suggested_format, revision, hashcode))
return rc.DELETED