Changeset 655
- Timestamp:
- 02/28/07 17:43:11 (2 years ago)
- Files:
-
- PleiadesEntity/trunk/Extensions/loader.py (modified) (1 diff)
- PleiadesEntity/trunk/tests/LoadEntity.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesEntity/trunk/Extensions/loader.py
r648 r655 395 395 396 396 for lid in lids: 397 for i, nid in enumerate(nids): 398 # Get association certainty from XML 399 certainty = association_certainties[i] 400 397 # Handle the unnamed case 398 if len(nids) == 0: 401 399 aid = p.invokeFactory('PlacefulAssociation', 402 id=" %s-%s" % (nid,lid),400 id="unnamed-%s" % lid, 403 401 placeType=placeType, 404 certainty= certainty,402 certainty='certain', 405 403 ) 406 404 a = getattr(p, aid) 407 405 a.addReference(getattr(locations, lid), 'hasLocation') 408 a.addReference(getattr(names, nid), 'hasName')409 406 410 407 # Secondary references for the place 411 408 parse_secondary_references(root, a, ptool) 412 409 a.reindexObject() 410 411 else: 412 for i, nid in enumerate(nids): 413 # Get association certainty from XML 414 certainty = association_certainties[i] 415 416 aid = p.invokeFactory('PlacefulAssociation', 417 id="%s-%s" % (nid,lid), 418 placeType=placeType, 419 certainty=certainty, 420 ) 421 a = getattr(p, aid) 422 a.addReference(getattr(locations, lid), 'hasLocation') 423 a.addReference(getattr(names, nid), 'hasName') 424 425 # Secondary references for the place 426 parse_secondary_references(root, a, ptool) 427 a.reindexObject() 413 428 414 429 return {'place_id': pid, 'location_ids': lids, 'name_ids': nids} PleiadesEntity/trunk/tests/LoadEntity.txt
r651 r655 35 35 >>> _ = folder.invokeFactory('PlaceContainer', id='places') 36 36 37 Utility tests38 -------------39 40 >>> format_listofstrings([])41 u''42 >>> format_listofstrings(['x'])43 u'x'44 >>> format_listofstrings(['x', 'y'])45 u'x and y'46 >>> format_listofstrings(['x', 'y', 'z'])47 u'x, y and z'48 49 >>> purifyText(u'aaa') == u'aaa'50 True51 >>> purifyText(u'abab') == u'abab'52 True53 >>> purifyText(u'Magie\U000000A01950,\U000000A0989') == u'Magie 1950, 989'54 True55 56 37 Load one entity 57 38 --------------- … … 59 40 >>> r = load_place(folder, "%s/batlas-65-2-24-grc.xml" % TEST_DATA) 60 41 >>> pid = r['place_id'] 61 >>> pid > folder.places._v_nextid42 >>> int(pid) <= BA_ID_MAX 62 43 True 63 44 >>> r['name_ids'] … … 264 245 [{'description': 'An ancient settlement, attested during the Classical, Roman and Late Antique periods (modern location: Geyre). It was known in antiquity by the names: Aphrodisias and Ninoe.', 'spatialCoordinates': '37.71446 28.72886 0.0', 'url': 'http://nohost/plone/Members/test_user_1_/places/638753', 'title': 'Aphrodisias/Ninoe/Aphrodisieus', 'srs': 'EPSG:4326', 'geometryType': 'point', 'id': '638753'}] 265 246 247 Load one nameless entity 248 ------------------------ 249 250 >>> r = load_place(folder, "%s/batlas-65-2-101.xml" % TEST_DATA) 251 >>> pid = r['place_id'] 252 >>> int(pid) <= BA_ID_MAX 253 True 254 >>> r['name_ids'] 255 [] 256 257 Test associations 258 259 >>> p = getattr(folder.places, pid) 260 >>> contents = p.listFolderContents() 261 >>> len(contents) 262 1 263 264 >>> a = contents[0] 265 >>> a.getRefs('hasName') 266 [] 267 >>> a.getPlaceType() 268 'fort' 269 >>> a.getCertainty() 270 'certain' 271 272 >>> g = IGeoItemSimple(p) 273 >>> g.isGeoreferenced() 274 True 275 >>> g.getInfo() 276 {'description': 'An ancient fort, attested during the Roman period (modern location: Emeriye). Its ancient name is not known.', 'spatialCoordinates': '37.1751 31.7324 0.0', 'url': 'http://nohost/plone/Members/test_user_1_/places/638830', 'title': '638830', 'srs': 'EPSG:4326', 'geometryType': 'point', 'id': '638830'} 277
