本文整理汇总了Python中eulexistdb.db.ExistDB.removeDocument方法的典型用法代码示例。如果您正苦于以下问题:Python ExistDB.removeDocument方法的具体用法?Python ExistDB.removeDocument怎么用?Python ExistDB.removeDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulexistdb.db.ExistDB
的用法示例。
在下文中一共展示了ExistDB.removeDocument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _remove_file_from_exist
# 需要导入模块: from eulexistdb.db import ExistDB [as 别名]
# 或者: from eulexistdb.db.ExistDB import removeDocument [as 别名]
def _remove_file_from_exist(self, filename):
db = ExistDB()
fname = path.split(filename)[-1]
exist_path = path.join(settings.EXISTDB_ROOT_COLLECTION, fname)
# tests could remove fixtures, so an exception here is not a problem
try:
db.removeDocument(exist_path)
except ExistDBException:
# any way to determine if error ever needs to be reported?
pass
示例2: test_ead_lastmodified
# 需要导入模块: from eulexistdb.db import ExistDB [as 别名]
# 或者: from eulexistdb.db.ExistDB import removeDocument [as 别名]
def test_ead_lastmodified(self):
modified = ead_lastmodified('rqst', 'abbey244')
self.assert_(isinstance(modified, datetime),
"ead_lastmodified should return a datetime object")
date_format = '%Y-%m-%d'
expected = datetime.now().strftime(date_format)
value = modified.strftime(date_format)
self.assertEqual(expected, value,
'ead lastmodified should be today, expected %s, got %s' % (expected, value))
# invalid eadid
self.assertRaises(Http404, ead_lastmodified, 'rqst', 'bogusid')
db = ExistDB()
# preview document - load fixture to preview collection
fullpath = path.join(exist_fixture_path, 'raoul548.xml')
db.load(open(fullpath, 'r'), settings.EXISTDB_PREVIEW_COLLECTION + '/raoul548.xml')
preview_modified = ead_lastmodified('rqst', 'raoul548', preview=True)
self.assert_(isinstance(preview_modified, datetime),
"ead_lastmodified should return a datetime object")
# clean up
db.removeDocument(settings.EXISTDB_PREVIEW_COLLECTION + '/raoul548.xml')
示例3: delete_ead
# 需要导入模块: from eulexistdb.db import ExistDB [as 别名]
# 或者: from eulexistdb.db.ExistDB import removeDocument [as 别名]
def delete_ead(request, id, archive=None):
""" Delete a published EAD.
On GET, display a form with information about the document to be removed.
On POST, actually remove the specified EAD document from eXist and create (or
update) a deleted record for that document in the relational DB.
"""
# retrieve the finding aid to be deleted with fields needed for
# form display or actual deletion
if archive is not None:
arch = get_object_or_404(Archive, slug=archive)
filter = {'repository__fulltext_terms': '"%s"' % arch.name}
else:
filter = {}
try:
fa = FindingAid.objects.only('eadid', 'unittitle',
'document_name', 'collection_name').filter(**filter).get(eadid=id)
# if this record has been deleted before, get that record and update it
deleted_info, created = Deleted.objects.get_or_create(eadid=fa.eadid)
deleted_info.title = unicode(fa.unittitle) # update with title from current document
render_form = False
# on GET, display delete form
if request.method == 'GET':
# pre-populate the form with info from the finding aid to be removed
delete_form = DeleteForm(instance=deleted_info)
render_form = True
else: # POST : actually delete the document
delete_form = DeleteForm(request.POST, instance=deleted_info)
if delete_form.is_valid():
delete_form.save()
db = ExistDB()
try:
success = db.removeDocument(fa.collection_name + '/' + fa.document_name)
if success:
DeleteForm(request.POST, instance=deleted_info).save()
messages.success(request, 'Successfully removed <b>%s</b>.' % id)
else:
# remove exited normally but was not successful
messages.error(request, 'Error: failed to removed <b>%s</b>.' % id)
except ExistDBException, e:
messages.error(request, "Error: failed to remove <b>%s</b> - %s." \
% (id, e.message()))
else: