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


Python XMLdata.find方法代码示例

本文整理汇总了Python中mgi.models.XMLdata.find方法的典型用法代码示例。如果您正苦于以下问题:Python XMLdata.find方法的具体用法?Python XMLdata.find怎么用?Python XMLdata.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mgi.models.XMLdata的用法示例。


在下文中一共展示了XMLdata.find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: my_profile_resources

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
def my_profile_resources(request):
    template = loader.get_template('profile/my_profile_resources.html')
    if 'template' in request.GET:
        template_name = request.GET['template']
        if template_name == 'all':
            context = RequestContext(request, {
                'XMLdatas': XMLdata.find({'iduser' : str(request.user.id)}),
            })
        else :
            if template_name == 'datacollection':
                templateNamesQuery = list(chain(Template.objects.filter(title=template_name).values_list('id'), Template.objects.filter(title='repository').values_list('id'), Template.objects.filter(title='database').values_list('id'), Template.objects.filter(title='projectarchive').values_list('id')))
            else :
                templateNamesQuery = Template.objects.filter(title=template_name).values_list('id')
            templateNames = []
            for templateQuery in templateNamesQuery:
                templateNames.append(str(templateQuery))

            context = RequestContext(request, {
                'XMLdatas': XMLdata.find({'iduser' : str(request.user.id), 'schema':{"$in" : templateNames}}), 'template': template_name
            })
    else :
        context = RequestContext(request, {
                'XMLdatas': XMLdata.find({'iduser' : str(request.user.id)}),
        })
    return HttpResponse(template.render(context))
开发者ID:hzhao1230,项目名称:nanomine,代码行数:27,代码来源:views.py

示例2: dashboard_resources

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
def dashboard_resources(request):
    template = loader.get_template('dashboard/my_dashboard_my_records.html')
    query = {}
    context = RequestContext(request, {})
    ispublished = request.GET.get('ispublished', None)
    template_name = request.GET.get('template', None)
    query['iduser'] = str(request.user.id)
    #If ispublished not None, check if we want publish or unpublish records
    if ispublished:
        ispublished = ispublished == 'true'
        query['ispublished'] = ispublished
    if template_name:
        context.update({'template': template_name})
        if template_name == 'datacollection':
            templateNamesQuery = list(chain(Template.objects.filter(title=template_name).values_list('id'),
                                            Template.objects.filter(title='repository').values_list('id'),
                                            Template.objects.filter(title='database').values_list('id'),
                                            Template.objects.filter(title='projectarchive').values_list('id')))
        else :
            templateNamesQuery = Template.objects.filter(title=template_name).values_list('id')
        templateNames = []
        for templateQuery in templateNamesQuery:
            templateNames.append(str(templateQuery))

        query['schema'] = {"$in" : templateNames}

    userXmlData = sorted(XMLdata.find(query), key=lambda data: data['lastmodificationdate'], reverse=True)
    #Add user_form for change owner
    user_form = UserForm(request.user)
    context.update({'XMLdatas': userXmlData, 'ispublished': ispublished, 'user_form': user_form})

    #If the user is an admin, we get records for other users
    if request.user.is_staff:
        #Get user name for admin
        usernames = dict((str(x.id), x.username) for x in User.objects.all())
        query['iduser'] = {"$ne": str(request.user.id)}
        otherUsersXmlData = sorted(XMLdata.find(query), key=lambda data: data['lastmodificationdate'], reverse=True)
        context.update({'OtherUsersXMLdatas': otherUsersXmlData, 'usernames': usernames})

    #Get new version of records
    listIds = [str(x['_id']) for x in userXmlData]
    if request.user.is_staff:
        listIdsOtherUsers = [str(x['_id']) for x in otherUsersXmlData]
        listIds = list(set(listIds).union(set(listIdsOtherUsers)))

    drafts = FormData.objects(xml_data_id__in=listIds, isNewVersionOfRecord=True).all()
    XMLdatasDrafts = dict()
    for draft in drafts:
        XMLdatasDrafts[draft.xml_data_id] = draft.id
    context.update({'XMLdatasDrafts': XMLdatasDrafts})

    #Add Status enum
    context.update({'Status': Status})

    return HttpResponse(template.render(context))
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:57,代码来源:views.py

示例3: change_status_case_active

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
 def change_status_case_active(self, ispublished):
     id = self.createXMLData(ispublished=ispublished)
     XMLdata.change_status(id, Status.INACTIVE)
     list_xmldata = XMLdata.find({'_id': ObjectId(id)})
     self.assertEquals(Status.INACTIVE, list_xmldata[0]['status'])
     self.assertEquals(Status.INACTIVE, list_xmldata[0]['content']['Resource']['@status'])
     XMLdata.change_status(id, Status.ACTIVE, ispublished)
     list_xmldata = XMLdata.find({'_id': ObjectId(id)})
     self.assertEquals(Status.ACTIVE, list_xmldata[0]['status'])
     self.assertEquals(Status.ACTIVE, list_xmldata[0]['content']['Resource']['@status'])
     if ispublished:
         self.assertNotEquals(None, list_xmldata[0].get('oai_datestamp', None))
     else:
         self.assertEquals(None, list_xmldata[0].get('oai_datestamp', None))
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:16,代码来源:tests_model.py

示例4: test_get_record_no_templ_xslt

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
 def test_get_record_no_templ_xslt(self):
     self.dump_oai_my_set()
     self.dump_xmldata()
     self.dump_oai_my_metadata_format()
     idXMLdata = str(XMLdata.find({'title': 'MGI Code Catalog.xml'})[0]['_id'])
     identifier = '%s:%s:id/%s' % (OAI_SCHEME, OAI_REPO_IDENTIFIER, idXMLdata)
     data = {'verb': 'GetRecord', 'identifier': identifier, 'metadataPrefix': 'oai_dc'}
     r = self.doRequestServer(data=data)
     self.isStatusOK(r.status_code)
     self.checkTagErrorCode(r.text, DISSEMINATE_FORMAT)
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:12,代码来源:tests.py

示例5: test_list_metadataformat_with_identifier

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
 def test_list_metadataformat_with_identifier(self):
     self.dump_xmldata()
     self.dump_oai_templ_mf_xslt()
     self.dump_oai_my_metadata_format()
     idXMLdata = str(XMLdata.find({'title':'MPInterfaces.xml'})[0]['_id'])
     identifier = '%s:%s:id/%s' % (OAI_SCHEME, OAI_REPO_IDENTIFIER, idXMLdata)
     data = {'verb': 'ListMetadataFormats', 'identifier': identifier}
     r = self.doRequestServer(data=data)
     self.isStatusOK(r.status_code)
     self.checkTagExist(r.text, 'ListMetadataFormats')
     self.checkTagExist(r.text, 'metadataFormat')
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:13,代码来源:tests.py

示例6: dashboard_resources

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
def dashboard_resources(request):
    template = loader.get_template('dashboard/my_dashboard_my_resources.html')
    if 'template' in request.GET:
        template_name = request.GET['template']

        if template_name == 'datacollection':
            templateNamesQuery = list(chain(Template.objects.filter(title=template_name).values_list('id'), Template.objects.filter(title='repository').values_list('id'), Template.objects.filter(title='database').values_list('id'), Template.objects.filter(title='projectarchive').values_list('id')))
        else :
            templateNamesQuery = Template.objects.filter(title=template_name).values_list('id')
        templateNames = []
        for templateQuery in templateNamesQuery:
            templateNames.append(str(templateQuery))


        if 'ispublished' in request.GET:
            ispublished = request.GET['ispublished']
            context = RequestContext(request, {
                'XMLdatas': sorted(XMLdata.find({'iduser' : str(request.user.id), 'schema':{"$in" : templateNames}, 'ispublished': ispublished=='true'}), key=lambda data: data['lastmodificationdate'], reverse=True),
                'template': template_name,
                'ispublished': ispublished,
             })
        else:
            context = RequestContext(request, {
                'XMLdatas': sorted(XMLdata.find({'iduser' : str(request.user.id), 'schema':{"$in" : templateNames}}), key=lambda data: data['lastmodificationdate'], reverse=True),
                'template': template_name,
            })
    else:
        if 'ispublished' in request.GET:
            ispublished = request.GET['ispublished']
            context = RequestContext(request, {
                    'XMLdatas': sorted(XMLdata.find({'iduser' : str(request.user.id), 'ispublished': ispublished=='true'}), key=lambda data: data['lastmodificationdate'], reverse=True),
                    'ispublished': ispublished,
            })
        else:
            context = RequestContext(request, {
                    'XMLdatas': sorted(XMLdata.find({'iduser' : str(request.user.id)}), key=lambda data: data['lastmodificationdate'], reverse=True),
            })
    return HttpResponse(template.render(context))
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:40,代码来源:views.py

示例7: list_test_deleted

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
 def list_test_deleted(self, verb):
     self.dump_oai_templ_mf_xslt()
     self.dump_oai_my_metadata_format()
     self.dump_oai_my_set()
     self.dump_xmldata()
     data = {'verb': verb, 'metadataPrefix': 'oai_soft'}
     r = self.doRequestServer(data=data)
     self.isStatusOK(r.status_code)
     #Check attribute status='deleted' of header doesn't exist
     self.checkTagExist(r.text, verb)
     #Delete one record
     template = Template.objects(filename='Software.xsd').get()
     dataSoft = XMLdata.find({'schema': str(template.id), 'status': {'$ne': Status.DELETED}})
     if len(dataSoft) > 0:
         XMLdata.update(dataSoft[0]['_id'], {'status': Status.DELETED})
         r = self.doRequestServer(data=data)
         self.isStatusOK(r.status_code)
         self.checkTagExist(r.text, verb)
         #Check attribute status='deleted' of header does exist
         self.checkTagWithParamExist(r.text, 'header', 'status="deleted"')
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:22,代码来源:tests.py

示例8: test_get_record_deleted

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
 def test_get_record_deleted(self):
     self.dump_oai_templ_mf_xslt()
     self.dump_oai_my_metadata_format()
     self.dump_oai_my_set()
     self.dump_xmldata()
     template = Template.objects(filename='Software.xsd').get()
     dataSoft = XMLdata.find({'schema': str(template.id), 'status': {'$ne': Status.DELETED}})
     if len(dataSoft) > 0:
         xmlDataId = dataSoft[0]['_id']
         identifier = '%s:%s:id/%s' % (OAI_SCHEME, OAI_REPO_IDENTIFIER, xmlDataId)
         data = {'verb': 'GetRecord', 'identifier': identifier, 'metadataPrefix': 'oai_soft'}
         r = self.doRequestServer(data=data)
         self.isStatusOK(r.status_code)
         #Check attribute status='deleted' of header doesn't exist
         self.checkTagExist(r.text, 'GetRecord')
         self.checkTagExist(r.text, 'record')
         #Delete one record
         XMLdata.update(xmlDataId, {'status': Status.DELETED})
         r = self.doRequestServer(data=data)
         self.isStatusOK(r.status_code)
         #Check attribute status='deleted' of header does exist
         self.checkTagExist(r.text, 'GetRecord')
         # Only for NMRR
         self.checkTagWithParamExist(r.text, 'header', 'status="deleted"')
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:26,代码来源:tests.py

示例9: getListTemplateDependenciesRecord

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import find [as 别名]
def getListTemplateDependenciesRecord(object_id):
    from mgi.models import XMLdata
    return XMLdata.find({'schema': str(object_id)})
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:5,代码来源:mgiutils.py


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