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


Python XMLdata.get方法代码示例

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


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

示例1: test_delete_result

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
 def test_delete_result(self):
     id = self.createXMLData()
     self.assertIsNotNone(XMLdata.get(id))
     url = '/dashboard/delete_result'
     data = {'result_id': str(id)}
     r = self.doRequestGetAdminClientLogged(url=url, data=data)
     self.assertIsNone(XMLdata.get(id))
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:9,代码来源:tests_ajax.py

示例2: test_update_unpublish

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
 def test_update_unpublish(self):
     id = self.createXMLData(ispublished=True)
     self.assertEquals(True, XMLdata.get(id)['ispublished'])
     url = '/dashboard/update_unpublish'
     data = {'result_id': str(id)}
     r = self.doRequestGetAdminClientLogged(url=url, data=data)
     self.assertEquals(False, XMLdata.get(id)['ispublished'])
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:9,代码来源:tests_ajax.py

示例3: test_update_publish_draft

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
 def test_update_publish_draft(self):
     status = Status.ACTIVE
     new_xml = "<Resource localid='' status='"+status+"'><identity>" \
            "<title>My new software</title></identity><curation><publisher>PF</publisher><contact><name></name>" \
            "</contact></curation><content><description>This is a new record</description><subject></subject>" \
            "<referenceURL></referenceURL></content></Resource>"
     id = self.createXMLData(ispublished=True)
     xmlData = XMLdata.get(id)
     self.assertNotEquals(new_xml, XMLdata.unparse(xmlData['content']))
     adminId = self.getAdmin().id
     template = self.createTemplate()
     elements = SchemaElement.objects().all()
     self.assertEqual(len(elements), 0)
     elementsForm = FormData.objects().all()
     self.assertEqual(len(elementsForm), 0)
     formData = self.createFormData(user=adminId, name='name', template=str(template.id), xml_data=new_xml,
                                    xml_data_id=str(id))
     url = '/dashboard/update_publish_draft'
     data = {'draft_id': str(formData.id)}
     r = self.doRequestGetAdminClientLogged(url=url, data=data)
     xmlDataInDatabase = XMLdata.get(id)
     elements = SchemaElement.objects().all()
     self.assertEqual(len(elements), 0)
     elementsForm = FormData.objects().all()
     self.assertEqual(len(elementsForm), 0)
     self.assertEquals(etree.XML(new_xml).text, etree.XML(str(XMLdata.unparse(xmlDataInDatabase['content']))).text)
     self.assertEquals(True, xmlDataInDatabase.get('ispublished'))
     self.assertEquals(str(adminId), xmlDataInDatabase.get('iduser'))
     self.assertNotEquals(xmlData.get('lastmodificationdate'), xmlDataInDatabase.get('lastmodificationdate'))
     self.assertNotEquals(xmlData.get('publicationdate'), xmlDataInDatabase.get('publicationdate'))
     self.assertEquals(status, xmlDataInDatabase.get('status'))
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:33,代码来源:tests_ajax.py

示例4: test_change_owner_record

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
 def test_change_owner_record(self):
     userId = self.getUser().id
     adminId = self.getAdmin().id
     template = self.createTemplate()
     xmldataid = self.createXMLData(iduser=userId, schemaID=template.id)
     self.assertEquals(str(userId), str(XMLdata.get(xmldataid)['iduser']))
     url = '/dashboard/change-owner-record'
     data = {'recordID': str(xmldataid), 'userID': str(adminId)}
     r = self.doRequestPostUserClientLogged(url=url, data=data)
     self.assertEquals(str(adminId), str(XMLdata.get(xmldataid)['iduser']))
     self.isStatusOK(r.status_code)
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:13,代码来源:tests_views.py

示例5: explore_detail_result_process

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def explore_detail_result_process(request) :
    result_id = request.GET['id']
    xmlString = XMLdata.get(result_id)
    schemaId = xmlString['schema']
    if 'title' in request.GET:
        title = request.GET['title']
    else:
        title = xmlString['title']
    xmlString = xmltodict.unparse(xmlString['content']).encode('utf-8')
    xsltPath = os.path.join(settings.SITE_ROOT, 'static', 'resources', 'xsl', 'xml2html.xsl')
    xslt = etree.parse(xsltPath)
    transform = etree.XSLT(xslt)

    #Check if a custom detailed result XSLT has to be used
    try:
        if (xmlString != ""):
            dom = etree.fromstring(str(xmlString))
            schema = Template.objects.get(pk=schemaId)
            if schema.ResultXsltDetailed:
                shortXslt = etree.parse(BytesIO(schema.ResultXsltDetailed.content.encode('utf-8')))
                shortTransform = etree.XSLT(shortXslt)
                newdom = shortTransform(dom)
            else:
                newdom = transform(dom)
    except Exception, e:
        #We use the default one
        newdom = transform(dom)
开发者ID:hzhao1230,项目名称:nanomine,代码行数:29,代码来源:views.py

示例6: curate_enter_data

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def curate_enter_data(request):
    print "BEGIN curate_enter_data(request)"

    try:
        context = RequestContext(request, {})
        if 'id' in request.GET:
            xml_data_id = request.GET['id']
            xml_data = XMLdata.get(xml_data_id)
            template = Template.objects().get(pk=ObjectId(xml_data['schema']))
            context = RequestContext(request, {'edit': True, 'template_name': template.title})
            curate_edit_data(request)
        elif 'template' in request.GET:
            context = RequestContext(request, {'template_name': request.GET['template']})
            curate_from_schema(request)
        elif 'templateid' in request.GET:
            pass

        template = loader.get_template('curate/curate_enter_data.html')

        return HttpResponse(template.render(context))
    except MDCSError, e:
        template = loader.get_template('curate/errors.html')
        context = RequestContext(request, {
            'errors': e.message,
        })
        return HttpResponse(template.render(context))
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:28,代码来源:views.py

示例7: curate_edit_data

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def curate_edit_data(request):
    try:
        if 'useForm' in request.GET and request.GET['useForm'] == 'true':
            pass
        else:
            xml_data_id = request.GET['id']
            xml_data = XMLdata.get(xml_data_id)
            json_content = xml_data['content']
            xml_content = xmltodict.unparse(json_content)
            request.session['curate_edit_data'] = xml_content
            request.session['curate_edit'] = True
            request.session['currentTemplateID'] = xml_data['schema']
            # remove previously created forms when editing a new one
            previous_forms = FormData.objects(user=str(request.user.id), xml_data_id__exists=True)
            for previous_form in previous_forms:
                # TODO: check if need to delete all SchemaElements
                previous_form.delete()
            form_data = FormData(
                user=str(request.user.id),
                template=xml_data['schema'],
                name=xml_data['title'],
                xml_data=xml_content,
                xml_data_id=xml_data_id
            )
            form_data.save()
            request.session['curateFormData'] = str(form_data.id)

            if 'form_id' in request.session:
                del request.session['form_id']
            if 'formString' in request.session:
                del request.session['formString']
            if 'xmlDocTree' in request.session:
                del request.session['xmlDocTree']
    except:
        raise MDCSError("The document you are looking for doesn't exist.")
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:37,代码来源:views.py

示例8: update_publish

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def update_publish(request):
    XMLdata.update_publish(request.GET['result_id'])
    resource = XMLdata.get(request.GET['result_id'])

    # Send mail to the user and the admin
    context = {'URI': MDCS_URI,
               'title': resource['title'],
               'publicationdate': resource['publicationdate'],
               'user': request.user.username}

    send_mail_to_managers(subject='Resource Published',
                                pathToTemplate='dashboard/email/resource_published.html',
                                context=context)
    return HttpResponse(json.dumps({}), content_type='application/javascript')
开发者ID:usnistgov,项目名称:MaterialsResourceRegistry,代码行数:16,代码来源:ajax.py

示例9: dashboard_detail_resource

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def dashboard_detail_resource(request) :
    template = loader.get_template('dashboard/my_dashboard_detail_resource.html')
    result_id = request.GET['id']
    type = request.GET['type']

    if type=='form':
        form_data = FormData.objects.get(pk=ObjectId(result_id))
        xmlString = form_data.xml_data
        title = form_data.name
        schemaId = form_data.template
    elif type=='record':
        xmlString = XMLdata.get(result_id)
        title = xmlString['title']
        schemaId = xmlString['schema']
        xmlString = xmltodict.unparse(xmlString['content']).encode('utf-8')


    xsltPath = os.path.join(settings.SITE_ROOT, 'static', 'resources', 'xsl', 'xml2html.xsl')
    xslt = etree.parse(xsltPath)
    transform = etree.XSLT(xslt)

    #Check if a custom detailed result XSLT has to be used
    try:
        if (xmlString != ""):
            dom = etree.fromstring(str(xmlString))
            schema = Template.objects.get(pk=schemaId)
            if schema.ResultXsltDetailed:
                shortXslt = etree.parse(BytesIO(schema.ResultXsltDetailed.content.encode('utf-8')))
                shortTransform = etree.XSLT(shortXslt)
                newdom = shortTransform(dom)
            else:
                newdom = transform(dom)
        else:
            newdom = "No data to display"
    except Exception, e:
        #We use the default one
        newdom = transform(dom)
开发者ID:pdessauw,项目名称:MaterialsResourceRegistry,代码行数:39,代码来源:views.py

示例10: curate_edit_data

# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import get [as 别名]
def curate_edit_data(request):
    try:
        xml_data_id = request.GET['id']
        xml_data = XMLdata.get(xml_data_id)
        json_content = xml_data['content']
        xml_content = xmltodict.unparse(json_content)
        request.session['curate_edit_data'] = xml_content
        request.session['curate_edit'] = True
        request.session['currentTemplateID'] = xml_data['schema']
        # remove previously created forms when editing a new one
        previous_forms = FormData.objects(user=str(request.user.id), xml_data_id__exists=True)
        for previous_form in previous_forms:
            # cascade delete references
            for form_element_id in previous_form.elements.values():
                try:
                    form_element = FormElement.objects().get(pk=form_element_id)
                    if form_element.xml_element is not None:
                        try:
                            xml_element = XMLElement.objects().get(pk=str(form_element.xml_element.id))
                            xml_element.delete()
                        except:
                            # raise an exception when element not found
                            pass
                    form_element.delete()
                except:
                    # raise an exception when element not found
                    pass
            previous_form.delete()
        form_data = FormData(user=str(request.user.id), template=xml_data['schema'], name=xml_data['title'], xml_data=xml_content, xml_data_id=xml_data_id).save()
        request.session['curateFormData'] = str(form_data.id)
        if 'formString' in request.session:
            del request.session['formString']
        if 'xmlDocTree' in request.session:
            del request.session['xmlDocTree']
    except:
        raise MDCSError("The document you are looking for doesn't exist.")
开发者ID:hzhao1230,项目名称:nanomine,代码行数:38,代码来源:views.py


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