Changeset 4582 for exist


Ignore:
Timestamp:
09/12/08 16:59:38 (11 years ago)
Author:
cbyrom
Message:

Add logic to cope with changes to the Atom structure - to allow granulite files and logos data to be stored + improve error handling.

Location:
exist/trunk/python/ndgUtils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/lib/granulite.py

    r4580 r4582  
    105105         
    106106        # override CSML/CDML data specified in the granulite file with data input directly 
     107        self.ingestGranuliteFiles = True 
    107108        if csmlOrCdmlFile is not None: 
    108109            if not isinstance(csmlOrCdmlFile, cgi.FieldStorage): 
    109110                raise ValueError("Specified CSML/CDML file is not a cgi.FieldStorage object") 
    110111            self.__addCSMLOrCDMLData(csmlOrCdmlFile.filename, csmlOrCdmlFile.value) 
     112            self.ingestGranuliteFiles = False 
    111113 
    112114        if granuleAtom: 
     
    253255        if self.PARAMETERS_SECTION in granulite_data: 
    254256            self._atom.addParameters(granulite_data[self.PARAMETERS_SECTION]) 
    255              
    256         # check for CSML/CDML file input - these data are changed before adding to the granule 
    257         # - since the file will be stored and referenced in eXist by then 
    258         if not self._csmlFileName: 
    259             if self.CSML_SECTION in granulite_data: 
    260                 self.__addCSMLOrCDMLData(granulite_data[self.CSML_SECTION][0], None) 
    261  
    262         if not self._cdmlFileName: 
    263             if self.CDML_SECTION in granulite_data: 
    264                 if self._csmlFileName: 
    265                     raise ValueError("Cannot specify both CDML and CSML file in granulite config file" + \ 
    266                                      "\nNB, CSML file is generated from the specified CDML file") 
    267              
    268                 data = utilities.getTripleData(granulite_data[self.CDML_SECTION][0]) 
    269                 self.__addCSMLOrCDMLData(data[0], None) 
    270                 self._datasetID = data[1] 
    271                 self._cdmlTimeAxis = data[2] 
     257 
     258        # NB, if running from the web, ignore the CSML/CDML files specified in the granulite 
     259        if self.ingestGranuliteFiles: 
     260            # check for CSML/CDML file input - these data are changed before adding to the granule 
     261            # - since the file will be stored and referenced in eXist by then 
     262            if not self._csmlFileName: 
     263                if self.CSML_SECTION in granulite_data: 
     264                    self.__addCSMLOrCDMLData(granulite_data[self.CSML_SECTION][0], None) 
     265     
     266            if not self._cdmlFileName: 
     267                if self.CDML_SECTION in granulite_data: 
     268                    if self._csmlFileName: 
     269                        raise ValueError("Cannot specify both CDML and CSML file in granulite config file" + \ 
     270                                         "\nNB, CSML file is generated from the specified CDML file") 
     271                 
     272                    data = utilities.getTripleData(granulite_data[self.CDML_SECTION][0]) 
     273                    self.__addCSMLOrCDMLData(data[0], None) 
     274                    self._datasetID = data[1] 
     275                    self._cdmlTimeAxis = data[2] 
    272276             
    273277        if self.DATA_ENTITY_SECTION in granulite_data: 
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4571 r4582  
    939939            else: 
    940940                self.ME.responsibleParties.append(attributeValue) 
     941        elif attributeName == "files": 
     942            self.addUniqueRelatedLinks(attributeValue) 
    941943        else: 
    942944            setattr(self, attributeName, attributeValue) 
     
    962964                authorType= Person.CONTRIBUTOR_TYPE 
    963965            obj = Person(personType = authorType) 
     966        elif attributeName == 'files': 
     967            obj = Link() 
     968            objectVals = '%s|%s|%s' \ 
     969                %(self.VTD.getTermCurrentVocabURL(VTD.METADATA_SOURCE_TERM), objectVals, VTD.METADATA_SOURCE_TERM) 
    964970 
    965971        if obj: 
Note: See TracChangeset for help on using the changeset viewer.