Changeset 4964 for MILK


Ignore:
Timestamp:
12/02/09 17:32:22 (11 years ago)
Author:
cbyrom
Message:

Adjust granulite to ensure that granule atoms are validated before
they are created - and add code to properly deal with validation errors.

Location:
MILK/trunk/milk_server/milk_server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/config/milkMiddleware.py

    r4958 r4964  
    6969        localDbHostName = cf.get('NDG_EXIST','local') 
    7070        # set up the validator for atoms - to allow re-use across the app 
    71         self.globals.validator = AtomValidator(None, self.globals.pwFile,  
     71        self.globals.validator = AtomValidator(None,  
     72                                               dbConfigFile = self.globals.pwFile,  
    7273                                               dbHostName = localDbHostName, 
    7374                                               newLineChar="<br/>", 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/atomeditorcontroller.py

    r4959 r4964  
    104104        in templates 
    105105        @param e: Exception to add 
     106        @return errors: dict of errors 
    106107        ''' 
    107108        if not c.errors: 
     
    122123            # and is of no real interest - and will just confuse viewers 
    123124            c.errors['Unexpected error'] = e.faultString.split(':')[-1]  
     125 
    124126        if hasattr(e, 'unpack_errors'): 
    125127            c.errors.update(e.unpack_errors()) 
     
    135137                    newErrors.append(escapeSpecialCharacters(err)) 
    136138            c.errors[key] = newErrors 
     139         
     140        return c.errors 
    137141 
    138142 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r4959 r4964  
    150150            logging.info(" - inputs invalid") 
    151151            c.errors = e.unpack_errors() 
     152        except ValidationError, e: 
     153            logging.info(e) 
     154            self._unpackErrors(e) 
     155             
    152156        except Exception, e: 
    153157            c.errors['WARNING'] = ['Error loading data: the displayed data will not be saved - please fix problem and retry'] 
     
    640644        logging.info("Setting up new atom from granulite template") 
    641645        c.title='Create new data granule atom - from a granulite file' 
    642         c.errors = {} 
     646 
     647        if not hasattr(c, 'errors'): 
     648            c.errors = {} 
    643649        try: 
    644650            return self.savePageAndRender('atom_editor/atom_granulator', **inputs) 
Note: See TracChangeset for help on using the changeset viewer.