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


Python EntityData.create方法代码示例

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


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

示例1: _create_testentity

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def _create_testentity(self):
     testentity = EntityData.create(self.testdata, "testentity",
         { "annal:type":         "test:testtype"
         , "test:repeat_fields": []
         })
     self.assertTrue(testentity is not None)
     return testentity
开发者ID:juandesant,项目名称:annalist,代码行数:9,代码来源:test_render_repeatgroup.py

示例2: setUp

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     self.testtype  = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype"))
     self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2"))
     self.testdata  = RecordTypeData.create(self.testcoll, "testtype", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.type_ids = get_site_types_linked("testcoll")
     self.type_ids.append(FieldChoice("_type/testtype", 
             label="RecordType testcoll/_type/testtype",
             link=recordtype_url("testcoll", "testtype")
         ))
     self.type_ids.append(FieldChoice("_type/testtype2", 
             label="RecordType testcoll/_type/testtype2",
             link=recordtype_url("testcoll", "testtype2")
         ))
     self.list_ids = get_site_lists_linked("testcoll")
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="testuser", password="testpassword")
     self.assertTrue(loggedin)
     return
开发者ID:gklyne,项目名称:annalist,代码行数:32,代码来源:test_entitydefaultlist.py

示例3: test_entitydata_create_load

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def test_entitydata_create_load(self):
     e  = EntityData.create(self.testdata, "entitydata1", entitydata_create_values("entitydata1"))
     self.assertEqual(e._entitydir, entitydata_dir(entity_id="entitydata1"))
     self.assertTrue(os.path.exists(e._entitydir))
     ed = EntityData.load(self.testdata, "entitydata1").get_values()
     v  = entitydata_values("entitydata1")
     self.assertKeysMatch(ed, v)
     self.assertDictionaryMatch(ed, v)
     return
开发者ID:juandesant,项目名称:annalist,代码行数:11,代码来源:test_entitydata.py

示例4: create_subproperty_field_view_entity

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def create_subproperty_field_view_entity(self):
     # Create test field using superproperty
     self.test_sup_field = RecordField.create(self.testcoll, "Test_sup_field",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "Field using superproperty URI"
         , RDFS.CURIE.comment:               "Field using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Text"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sup_field)"
         , ANNAL.CURIE.property_uri:         "test:superprop_uri"
         , ANNAL.CURIE.field_placement:      "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sup_field is not None)
     # Create test field using subproperty and declaring superproperty
     self.test_sub_field = RecordField.create(self.testcoll, "Test_sub_field",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "Field using superproperty URI"
         , RDFS.CURIE.comment:               "Field using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Text"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sub_field)"
         , ANNAL.CURIE.property_uri:         "test:subprop_uri"
         , ANNAL.CURIE.superproperty_uri:    [{"@id": "test:superprop_uri"}]
         , ANNAL.CURIE.field_placement:      "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sub_field is not None)
     # Create test view using superproperty
     self.test_view = RecordView.create(self.testcoll, "testview",
         { ANNAL.CURIE.type:             "annal:View"
         , ANNAL.CURIE.uri:              "test:view"
         , RDFS.CURIE.label:             "Test view label"
         , RDFS.CURIE.comment:           "Test view comment"
         , ANNAL.CURIE.view_entity_type: "test:testtype"
         , ANNAL.CURIE.view_fields:
           [ { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Entity_id"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           , { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Test_sup_field"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           ]
         })
     self.assertTrue(self.test_view is not None)
     # Create test entity using subproperty
     self.testentity_data = EntityData.create(self.testdata, "testentity", 
         entitydata_create_values(
             "testentity", type_id="testtype",
             type_uri="test:testtype",
             extra_fields={"test:subprop_uri": "Test field value"} 
             )
         )
     self.assertTrue(self.testentity_data is not None)
     return
开发者ID:gklyne,项目名称:annalist,代码行数:57,代码来源:test_field_subproperty.py

示例5: _create_entity_data

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def _create_entity_data(self, 
     entity_id, type_id="testtype", update="Entity", 
     comment2="Comment field 2",
     comment3="Comment field 3"
     ):
     "Helper function creates entity data with supplied entity_id"
     v = entitydata_create_values(entity_id, type_id=type_id, update=update)
     v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2)
     v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3)
     e = EntityData.create(self.testdata, entity_id, v)
     return e    
开发者ID:juandesant,项目名称:annalist,代码行数:13,代码来源:test_entityeditdupfield.py

示例6: test_post_confirmed_remove_entity

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def test_post_confirmed_remove_entity(self):
     t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
     self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
     # Submit positive confirmation
     u = entitydata_delete_confirm_url("testcoll", "testtype")
     f = entitydata_delete_confirm_form_data("deleteentity")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,    302)
     self.assertEqual(r.reason_phrase,  "Found")
     self.assertEqual(r.content,        b"")
     v  = entitydata_list_all_url("testcoll")
     self.assertIn(v, r['location'])
     self.assertIn("info_head=",         r['location'])
     self.assertIn("info_message=",      r['location'])
     self.assertNotIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
开发者ID:gklyne,项目名称:annalist,代码行数:20,代码来源:test_entitydelete.py

示例7: coll123_create_data

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
def coll123_create_data(site):
    coll1 = Collection.create(site, "coll1", collection_create_values("coll1"))
    coll2 = Collection.create(site, "coll2", collection_create_values("coll2"))
    coll3 = Collection.create(site, "coll3", collection_create_values("coll3"))
    #
    for coll in [coll1, coll2, coll3]:
        type1 = RecordType.create(coll, "type1", recordtype_create_values(coll._entityid, "type1"))
        view1 = RecordView.create(coll, "view1", recordview_create_values(coll._entityid, "view1"))
        list1 = RecordList.create(coll, "list1", recordlist_create_values(coll._entityid, "list1"))
        data1 = RecordTypeData.create(coll, "type1", {})
        type2 = RecordType.create(coll, "type2", recordtype_create_values(coll._entityid, "type2"))
        view2 = RecordView.create(coll, "view2", recordview_create_values(coll._entityid, "view2"))
        list2 = RecordList.create(coll, "list2", recordlist_create_values(coll._entityid, "list2"))
        data2 = RecordTypeData.create(coll, "type2", {})
        #
        for t,d in [(type1,data1),(type2,data2)]:
            for eid in ["entity1", "entity2", "entity3"]:
                e = EntityData.create(d, eid, entitydata_create_values(coll,t,eid))
    return
开发者ID:gklyne,项目名称:annalist,代码行数:21,代码来源:test_createsitedata.py

示例8: init_annalist_test_coll

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
def init_annalist_test_coll(coll_id="testcoll", type_id="testtype"):
    log.debug("init_annalist_test_coll")
    testsite = Site(TestBaseUri, TestBaseDir)
    testcoll = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testtype = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata = RecordTypeData.create(testcoll, type_id, {})
    teste    = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll,testtype,"entity1")
        )
    testcoll.generate_coll_jsonld_context()
    # Reset id generator counters
    EntityData._last_id   = 0
    RecordType._last_id   = 0
    RecordView._last_id   = 0
    RecordList._last_id   = 0
    RecordField._last_id  = 0
    AnnalistUser._last_id = 0
    return testcoll
开发者ID:juandesant,项目名称:annalist,代码行数:21,代码来源:init_tests.py

示例9: setUp

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_named_test_coll(layout.BIBDATA_ID)
     self.testdata  = RecordTypeData.load(self.testcoll, "testtype")
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")
         )
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="testuser", password="testpassword")
     self.assertTrue(loggedin)
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.list_ids = get_site_bib_lists_linked("testcoll")
     return
开发者ID:gklyne,项目名称:annalist,代码行数:22,代码来源:test_entityinheritlist.py

示例10: setUp

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     self.testtype  = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype"))
     self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2"))
     self.testdata  = RecordTypeData.create(self.testcoll, "testtype", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     # self.user = User.objects.create_user('testuser', '[email protected]', 'testpassword')
     # self.user.save()
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="testuser", password="testpassword")
     self.assertTrue(loggedin)
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.list_ids = get_site_lists_linked("testcoll")
     return
开发者ID:juandesant,项目名称:annalist,代码行数:24,代码来源:test_entitygenericlist.py

示例11: setUp

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_named_test_coll(layout.BIBDATA_ID)
     # Create BibEntry record (BibEntry_type defines field alias)
     self.testdata   = RecordTypeData.create(self.testcoll, "BibEntry_type", {})
     self.bibentity1_data = (
         { "@type": 
             [ "bib:BibEntry"
             , ANNAL.CURIE.EntityData
             ]
         , ANNAL.CURIE.type:    "bib:BibEntry"
         , ANNAL.CURIE.type_id: "BibEntry_type"
         , "bib:type": "article"
         , "bib:title": "bib:title for bibentity1"
         , "bib:note": "Sample bibliographic entry with field aliasing"
         , "bib:month": "09"
         , "bib:year": "2014"
         , "bib:author": [
             { "bib:id": "author_id"
             , "bib:name": "Author, J. H."
             , "bib:alternate": "Joe H. Author"
             , "bib:firstname": "Joe"
             , "bib:lastname": "Author"
             }]
         , "bib:identifier": []
         , "bib:journal": []
         , "bib:editor": []
         , "bib:publication_details": []
         , "bib:license": []
         , "bib:bookentry": []
         })
     self.testbib1   = EntityData.create(self.testdata, "bibentity1", self.bibentity1_data)
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="testuser", password="testpassword")
     self.assertTrue(loggedin)
     return
开发者ID:gklyne,项目名称:annalist,代码行数:40,代码来源:test_field_alias.py

示例12: init_annalist_named_test_coll

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
def init_annalist_named_test_coll(
        base_coll_id=None, coll_id="testcoll", type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also installs and 
    inherits from named collection definitions.

    """
    # @@TODO: DRY: use create_test_coll_inheriting
    # @@TODO: rename: install_create_test_coll_inheriting
    log.debug("init_annalist_named_test_coll")
    testsite  = Site(TestBaseUri, TestBaseDir)
    namedcoll = install_annalist_named_coll(base_coll_id)
    testcoll  = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testcoll.set_alt_entities(namedcoll)
    testcoll._save()
    testtype  = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata  = RecordTypeData.create(testcoll, type_id, {})
    teste     = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll, testtype, "entity1")
        )
    testcoll.generate_coll_jsonld_context()
    return testcoll
开发者ID:juandesant,项目名称:annalist,代码行数:25,代码来源:init_tests.py

示例13: create_test_coll_inheriting

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
def create_test_coll_inheriting(
        base_coll_id=None, coll_id="testcoll", type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also
    inherits from named collection.
    """
    testsite  = Site(TestBaseUri, TestBaseDir)
    basecoll  = Collection.load(testsite, base_coll_id)
    if not basecoll:
        msg = "Base collection %s not found"%base_coll_id
        log.warning(msg)
        assert False, msg
    testcoll  = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testcoll.set_alt_entities(basecoll)
    testcoll._save()
    testtype  = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata  = RecordTypeData.create(testcoll, type_id, {})
    teste     = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll, testtype, "entity1")
        )
    testcoll.generate_coll_jsonld_context()
    return testcoll
开发者ID:juandesant,项目名称:annalist,代码行数:25,代码来源:init_tests.py

示例14: test_post_confirmed_remove_entity_from_search

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def test_post_confirmed_remove_entity_from_search(self):
     t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
     self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
     # Submit positive confirmation
     u = entitydata_delete_confirm_url("testcoll", "testtype")
     f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,     302)
     self.assertEqual(r.reason_phrase,   "FOUND")
     self.assertEqual(r.content,         "")
     self.assertMatch(r['location'],    
         "^"+TestHostUri+
         entitydata_list_all_url("testcoll")
         )
     self.assertMatch(r['location'],    
         r"info_head=.*$"
         )
     self.assertMatch(r['location'],    
         r"info_message=.*deleteentity.*testcoll.*$"
         )
     self.assertIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
开发者ID:juandesant,项目名称:annalist,代码行数:26,代码来源:test_entitydelete.py

示例15: setUp

# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import create [as 别名]
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(
         self.testsite, "testcoll", collection_create_values("testcoll")
         )
     # Create test types
     self.testtypes = RecordType.create(
         self.testcoll, "testtypes", 
         recordtype_create_values(
             coll_id="testcoll", type_id="testtypes", type_uri="test:testtypes",
             supertype_uris=[]
             )
         )
     self.testtype1 = RecordType.create(
         self.testcoll, "testtype1",
         recordtype_create_values(
             coll_id="testcoll", type_id="testtype1", type_uri="test:testtype1", 
             supertype_uris=["test:testtypes"]
             )
         )
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2",
         recordtype_create_values(
             coll_id="testcoll", type_id="testtype2", type_uri="test:testtype2", 
             supertype_uris=["test:testtypes"]
             )
         )
     self.ref_type  = RecordType.create(
         self.testcoll, "ref_type", 
         recordtype_create_values(
             coll_id="testcoll", type_id="ref_type", type_uri="test:ref_type",
             supertype_uris=[]
             )
         )
     # Create test type data parents
     self.testdatas = RecordTypeData.create(self.testcoll, "testtypes", {})
     self.testdata1 = RecordTypeData.create(self.testcoll, "testtype1", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     self.ref_data  = RecordTypeData.create(self.testcoll, "ref_type",  {})
     # Create test type data
     es = EntityData.create(self.testdatas, "entitys", 
         entitydata_create_values(
             "entitys", type_id="testtypes", extra_fields={"test:turi": "test:testtypes"} 
             )
         )
     e1 = EntityData.create(self.testdata1, "entity1", 
         entitydata_create_values(
             "entity1", type_id="testtype1", extra_fields={"test:turi": "test:testtype1"} 
             )
         )
     e2 = EntityData.create(self.testdata2, "entity2", 
         entitydata_create_values(
             "entity2", type_id="testtype2", extra_fields={"test:turi": "test:testtype2"} 
             )
         )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="testuser", password="testpassword")
     self.assertTrue(loggedin)
     return
开发者ID:juandesant,项目名称:annalist,代码行数:64,代码来源:test_entity_subtype_selection.py


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