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


Python ExistDB.removeDocument方法代码示例

本文整理汇总了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
开发者ID:emory-libraries,项目名称:eulexistdb,代码行数:12,代码来源:testutil.py

示例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')
开发者ID:emory-libraries,项目名称:findingaids,代码行数:24,代码来源:utils.py

示例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:
开发者ID:emory-libraries,项目名称:findingaids,代码行数:52,代码来源:views.py


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