Changeset 5232


Ignore:
Timestamp:
27/04/09 17:02:51 (10 years ago)
Author:
cbyrom
Message:

Adjust code to keep track of original provider name - to allow valid
updating of records should this name change.

Location:
TI01-discovery/trunk/OAIInfoEditor/oai_info_editor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/edit.py

    r5229 r5232  
    146146 
    147147        pi = PI.createProviderInfoWithData(self.providerName, self.repositoryInfos) 
    148          
     148        pi.oldName = providerName 
     149             
    149150        # update to ensure that the records are returned 
    150151        pi = g.dao.updateProviderInfo(pi) 
    151152 
    152153        # now, return to the view page 
    153         h.redirect_to('viewProviderInfo', providerName = providerName) 
    154  
    155          
    156         c.title = const.EDIT_PAGE_TITLE %providerName 
    157         logging.debug(" - provider info saved - returning to view mode") 
    158         return self._renderTemplate('genshi', 'view_provider_infos') 
     154        h.redirect_to('viewProviderInfo', providerName = pi.name) 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/model/providerinfo.py

    r5226 r5232  
    3131     
    3232    # define the expected object attributes 
    33     __slots__ = [NAME_ATT_NAME, 'repositoryInfos'] 
     33    # NB, 'oldName' is used when the provider name is being updated - so the 
     34    # old record can be effectively updated 
     35    __slots__ = [NAME_ATT_NAME, 'repositoryInfos', 'oldName'] 
    3436 
    3537    def __init__(self, et = None): 
     
    5759        logging.debug("Setting data on ProviderInfo document object") 
    5860        self.name = providerName 
     61        self.oldName = self.name 
    5962        self.repositoryInfos = repositoryInfos 
    6063        logging.debug("ProviderInfo data set") 
     
    7578 
    7679        self.name = et.attrib.get(NAME_ATT_NAME) 
     80        self.oldName = self.name 
    7781         
    7882        repositoryInfos = et.findall(RI_ROOT_ELEMENT_NAME) 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/model/providerinfocollection.py

    r5226 r5232  
    137137        pis = [] 
    138138        isNew = True 
    139         for pi in self.providerInfos: 
    140             if pi.name == providerInfo.name: 
     139        piName = providerInfo.name 
     140        if providerInfo.oldName != piName: 
     141            piName = providerInfo.oldName 
     142             
     143        for pi in self.providerInfos: 
     144            if pi.name == piName: 
    141145                logging.debug("- updating existing provider info") 
    142146                 
  • TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/dal/testeditorfileclient.py

    r5226 r5232  
    7272        self.assertEquals(1, len(self.client.pic.providerInfos)) 
    7373        self.assertEquals('2', self.client.pic.version) 
     74         
     75         
     76    def testUpdateProviderInfoChangeName(self): 
     77        pi, fileName = self.client.createProviderInfo(PROVIDER_INFO_1) 
     78        self.files.append(fileName) 
     79        self.assertEquals(1, len(self.client.pic.providerInfos)) 
     80        self.assertEquals('1', self.client.pic.version) 
     81        self.assertEquals(VALID_PROVIDER_NAME_1, pi.name) 
     82         
     83        pi.name = VALID_PROVIDER_NAME_2 
     84        pi = self.client.updateProviderInfo(pi) 
     85        self.files.append(self.client.pic.backupFile) 
     86        self.assertEquals(1, len(self.client.pic.providerInfos)) 
     87        self.assertEquals('2', self.client.pic.version) 
     88        self.assertEquals(VALID_PROVIDER_NAME_2, pi.name) 
     89        pi.name = VALID_PROVIDER_NAME_1 
    7490         
    7591         
Note: See TracChangeset for help on using the changeset viewer.