Changeset 4491 for MILK


Ignore:
Timestamp:
26/11/08 10:06:40 (11 years ago)
Author:
cbyrom
Message:

Create new class, AtomValidator?, to act as a utility class for the Atom class - allowing validation of the following data:
i) External links

ii) Vocab data
iii) Schema compliance
iv) unicode compliance - with utf-8 encoding
v) data consistency within the atom data model


Store an instance in a global MILK variable for easy re-use by the atom-editor. Also, remove redundant geoUtilities class.

Location:
MILK/trunk/milk_server/milk_server
Files:
1 deleted
4 edited

Legend:

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

    r4485 r4491  
    44from paste.deploy import CONFIG 
    55from ndgUtils.models.myconfig import myConfig 
     6from ndgUtils.lib.atomvalidator import AtomValidator 
    67 
    78class NDGConfigError(Exception):   
     
    6061        if cf.config.has_option('DISCOVERY', 'discoveryServiceURL'): 
    6162            self.globals.discoveryServiceURL = \ 
    62                 cf.config.get('DISCOVERY', 'discoveryServiceURL')        
     63                cf.config.get('DISCOVERY', 'discoveryServiceURL') 
     64                 
     65        self.globals.pwFile = cf.get('NDG_EXIST','passwordFile') 
     66        # set up the validator for atoms - to allow re-use across the app 
     67        self.globals.validator = AtomValidator(None, dbConfigFile = self.globals.pwFile, \ 
     68                                       raiseException = True, newLineChar="<br/>") 
    6369 
    64          
    6570        # Security Related 
    6671 
  • MILK/trunk/milk_server/milk_server/controllers/atom_editor/editatom.py

    r4486 r4491  
    1818from milk_server.lib.atomutilities import savePageAndRender 
    1919from ndgUtils import ndgObject 
    20 from ndgUtils.models.Atom import Atom, Person, Link, Category, ValidationError 
     20from ndgUtils.models.Atom import Atom, Person, Link, Category 
     21from ndgUtils.lib.atomvalidator import ValidationError 
    2122import ndgUtils.models.existdbclient as edc 
    2223from ndgUtils.models.MolesEntity import MolesEntity as ME 
    23 from ndgUtils.models.utilities import escapeSpecialCharacters 
     24from ndgUtils.lib.utilities import escapeSpecialCharacters 
    2425from ndgUtils.vocabtermdata import VocabTermData as VTD 
    2526from granulatorTool.granulite import granulite as granulite 
     
    197198        #    validator = AtomFormSchema() 
    198199        #    validator.to_python(inputs) 
    199             c.atom.validate() 
     200            g.validator.setAtom(c.atom) 
     201            g.validator.validateAtom() 
     202            #c.atom.validate() 
    200203            logging.info("- input valid") 
    201204        except ValidationError, e: 
    202         #    c.error = e.message 
    203205            c.errors = e.unpack_errors() 
     206            logging.info("- input invalid") 
    204207            return self.edit(uri) 
    205208 
     
    329332         
    330333        response.status_code = 400 
    331         return render('atom_editor/error') 
     334        return render("genshi", 'atom_editor/error') 
    332335 
    333336 
  • MILK/trunk/milk_server/milk_server/controllers/browse/discovery.py

    r4487 r4491  
    2626        self.cf=request.environ['ndgConfig'] 
    2727        self.exist=(self.cf.get('NDG_EXIST','local'),\ 
    28                     self.cf.get('NDG_EXIST','passwordFile')) 
     28                    g.pwFile) 
    2929        self.inputs=dict(parse_querystring(request.environ)) 
    3030        self.message='' 
  • MILK/trunk/milk_server/milk_server/templates/atom_editor/atom_functions.html

    r4472 r4491  
    1010        <h3>Input error</h3> 
    1111        <table align="center"> 
    12         <tr py:for="error in c.errors"> 
    13                 <!-- td>Input - '${error}'</td--> 
    14                 <td align="left">'${c.errors[error]}'</td> 
    15         </tr> 
     12        <span py:for="key, errors in c.errors.items()" py:strip=""> 
     13                <tr py:for="error in errors"> 
     14                        <td align="left">${Markup(error)}</td> 
     15                </tr> 
     16        </span> 
    1617        </table> 
    1718    </div> 
Note: See TracChangeset for help on using the changeset viewer.