Ignore:
Timestamp:
15/12/08 09:22:56 (11 years ago)
Author:
cbyrom
Message:

Improve error handling in the atom controllers + refactor ndgInterface
to remove code from constructor to allow dependency injection - to
improve flexibility and testability. Also, change ambiguous naming
references in classes to minimise codeword overaps/confusion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r4594 r4625  
    1414from milk_server.models.form import * 
    1515from milk_server.lib import mailer 
    16 from milk_server.lib.ndgInterface import interface  
     16from milk_server.lib.ndgInterface import ndgInterface  
    1717import milk_server.lib.htmlUtilities as utils 
    1818from milk_server.lib.atomutilities import savePageAndRender 
     
    273273        # quite a lot during editing; ensure you've always got  
    274274        # the latest updates loaded 
     275        interface = ndgInterface() 
    275276        status,x = interface.GetXML(uri, useCache=False) 
    276277 
     
    305306            c.errors = {} 
    306307 
    307         try: 
    308             # NB, can get here directly from saveAtom - if there have been errors 
    309             # - in this case keep original data 
    310             if not c.atom: 
    311                 self.prepareDataModel(uri) 
    312         except SystemError, e: 
    313             return self.__handleError(e) 
     308        # NB, can get here directly from saveAtom - if there have been errors 
     309        # - in this case keep original data 
     310        if not c.atom: 
     311            self.prepareDataModel(uri) 
    314312             
    315313        c.title='Editing [%s]' %c.atom.ndgURI 
     
    367365        ''' 
    368366        logging.info("Setting up atom edit template") 
    369         self.prepareEditForm(uri) 
    370  
    371367        try: 
     368            self.prepareEditForm(uri) 
    372369            return savePageAndRender(self.pathInfo, "atom_editor/atom_editor") 
    373370         
     
    376373            c.doc=str(x) 
    377374            logging.error("Error retrieving [%s] - XML content: %s" % (uri, e)) 
    378  
     375        except SystemError, e: 
     376            return self.__handleError(e) 
    379377        except Exception, e: 
    380378            errorMessage = traceback.format_exc() 
Note: See TracChangeset for help on using the changeset viewer.