Changeset 1354
- Timestamp:
- 08/08/08 00:45:52 (4 months ago)
- Files:
-
- PleiadesEntity/trunk/Extensions/loader.py (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesEntity/trunk/Extensions/loader.py
r1312 r1354 105 105 106 106 107 def loaden(s elf, sourcedir):107 def loaden(site, sourcedir): 108 108 """Attempt to load all XML files in the specified source directory. 109 109 Files which can not be loaded are reported.""" … … 112 112 for xml in glob.glob("%s/*.xml" % sourcedir): 113 113 try: 114 load_place(s elf, xml)114 load_place(site, xml) 115 115 count += 1 116 116 except Exception, e: … … 156 156 appropriate temporalAttestation children of the object at 157 157 portalcontext.""" 158 159 #wftool = getToolByName(portalcontext, 'portal_workflow')160 158 161 159 for tp in xmlcontext.findall("{%s}timePeriod" % ADLGAZ): … … 190 188 raise EntityLoadError, "There is already a TemporalAttestation with id=%s in portal context = %s" % (id, portalcontext.Title()) 191 189 192 #wftool.doActionFor(getattr(portalcontext, id), "publish")193 194 190 def getalltext(elem): 195 191 text = elem.text or "" … … 200 196 def parse_secondary_references(xmlcontext, portalcontext, ptool, wftool=None): 201 197 srs = xmlcontext.find("{%s}secondaryReferences" % AWMC) 202 if srs :198 if srs is not None: 203 199 bibls = srs.xpath('tei:bibl', namespaces={'tei': TEI}) 204 200 if not bibls: … … 221 217 except: 222 218 raise 223 #raise EntityLoadError, "There is already a SecondaryReference with id=%s in portal context" % id224 225 #wftool.doActionFor(getattr(portalcontext, id), "publish")226 227 import sys228 219 229 220 def parse_attrib_rights(xmlcontext): … … 336 327 description=description 337 328 ) 338 name = getattr(names, nid)329 name = names[nid] 339 330 except: 340 331 nid = names.duplicates.invokeFactory("Name", … … 352 343 description=description 353 344 ) 354 name = getattr(names.duplicates, nid) 355 356 #wftool.doActionFor(name, "publish") 357 345 name = names.duplicates[nid] 346 358 347 nids.append(nid) 359 348 association_certainties.append(certainty) … … 361 350 # Time Periods associated with the name 362 351 parse_periods(e, name) 363 364 352 # SecondaryReferences associated with the name 365 353 parse_secondary_references(e, name, ptool) #, wftool) 366 #name.reindexObject()367 354 368 355 return (nids, association_certainties) … … 377 364 for e in root.findall("{%s}spatialLocation" % ADLGAZ): 378 365 coords = e.findall("{%s}point" % GEORSS)[0].text.split() 379 380 366 lid = portalcontext.invokeFactory('Location', 381 367 geometry='Point:[%s,%s]' % (coords[1], coords[0]), … … 384 370 rights=rights 385 371 ) 386 387 #wftool.doActionFor(getattr(portalcontext, lid), "publish")388 372 lids.append(lid) 389 390 373 # Time Periods associated with the location 391 parse_periods(root, getattr(portalcontext, lid)) 392 393 #getattr(locations, lid).reindexObject() 374 parse_periods(root, portalcontext[lid]) 394 375 395 376 return lids … … 400 381 401 382 ptool = getToolByName(site, 'plone_utils') 402 #wftool = getToolByName(site, 'portal_workflow')403 383 404 384 places = site['places'] … … 410 390 try: 411 391 root = etree.parse(file).getroot() 412 413 392 creators, contributors, rights = parse_attrib_rights(root) 414 415 393 # Names 416 nids, association_certainties = parse_names(root, names, ptool) #, wftool) 417 394 nids, association_certainties = parse_names(root, names, ptool) 418 395 # Locations 419 lids = parse_locations(root, locations, ptool) #, wftool) 420 396 lids = parse_locations(root, locations, ptool) 421 397 # Place 422 398 e = root.findall("{%s}modernLocation" % AWMC) … … 455 431 id = None 456 432 457 placeNames = [ getattr(names, nid)for nid in nids]433 placeNames = [names[nid] for nid in nids] 458 434 computedTitle = '/'.join([n.Title() for n in placeNames]) 459 435 … … 467 443 description=description 468 444 ) 469 p = getattr(places, pid) 470 #wftool.doActionFor(p, "publish") 471 #p.reindexObject() 472 445 p = places[pid] 446 473 447 # Iterate over locations 474 448 for lid in lids: … … 480 454 associationCertainty='certain', 481 455 ) 482 a = getattr(p, aid) 483 a.addReference(getattr(locations, lid), 'hasLocation') 484 #wftool.doActionFor(a, "publish") 485 456 a = p[aid] 457 a.addReference(locations[lid], 'hasLocation') 486 458 # Secondary references for the place 487 459 parse_secondary_references(root, a, ptool) #, wftool) 488 #a.reindexObject() 489 460 490 461 else: 491 462 for i, nid in enumerate(nids): … … 498 469 associationCertainty=certainty, 499 470 ) 500 a = getattr(p, aid) 501 a.addReference(getattr(locations, lid), 'hasLocation') 502 a.addReference(getattr(names, nid), 'hasName') 503 #wftool.doActionFor(a, "publish") 504 471 a = p[aid] 472 a.addReference(locations[lid], 'hasLocation') 473 a.addReference(names[nid], 'hasName') 505 474 # Secondary references for the place 506 475 parse_secondary_references(root, a, ptool) #, wftool) 507 #a.reindexObject()508 476 509 477 # If there are no locations, iterate over the names … … 515 483 associationCertainty='certain', 516 484 ) 517 a = getattr(p, aid) 518 a.addReference(getattr(names, nid), 'hasName') 519 #wftool.doActionFor(a, "publish") 485 a = p[aid] 486 a.addReference(names[nid], 'hasName') 520 487 # Secondary references for the place 521 488 parse_secondary_references(root, a, ptool) #, wftool) 522 #a.reindexObject()523 489 524 490 except:
