Changeset 740

Show
Ignore:
Timestamp:
03/28/07 16:42:51 (2 years ago)
Author:
thomase
Message:

Closes ticket #238. Name.nameAttested is now validated when populated through-the-web or via Extensions.loader.load_place. Both Greek (ancient) and Latin writing systems are supported - modern Greek accented characters are permitted too (bad?). Thorough tests for both. Adding more scripts should be straightforward without further UML changes (see ws_validation.py). Got rid of moribund dependencies on cooking.py, which is no longer used and so has been removed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PleiadesEntity/trunk/Extensions/loader.py

    r711 r740  
    3838 
    3939from Products.PleiadesEntity.Extensions.xmlutil import * 
    40 from Products.PleiadesEntity.Extensions.cooking import * 
     40from Products.PleiadesEntity.Extensions.ws_validation import validate_name 
    4141 
    4242from Products.PleiadesEntity.config import * 
     
    219219            nameAttested = '' 
    220220            nameLanguage = '' 
     221             
     222        if nameAttested and nameLanguage: 
     223            invalid = validate_name(nameLanguage, nameAttested.encode('utf-8')) 
     224            if invalid: 
     225                raise EntityLoadError, invalid.decode('utf-8').encode('ascii', 'backslashreplace') 
    221226         
    222227        d = e.findall("{%s}description" % DC) 
  • PleiadesEntity/trunk/Extensions/ws_grek.py

    r739 r740  
    311311                        pass 
    312312            if not(b): 
    313                 invalids.append((i, c, cval, 'illegal character in appropriate Unicode range')
     313                invalids.append({'position':i, 'character':c, 'reason':'illegal character in appropriate Unicode range'}
    314314        else: 
    315             invalids.append((i, c, cval, 'illegal character from outside appropriate Unicode range')
     315            invalids.append({'position':i, 'character':c, 'reason':'illegal character from outside appropriate Unicode range'}
    316316    return invalids 
    317317 
  • PleiadesEntity/trunk/content/Name.py

    r734 r740  
    3434from Products.PleiadesEntity.config import * 
    3535 
    36 # additional imports from tagged value 'import' 
    37 from Products.PleiadesEntity.Extensions.cooking import * 
    38  
    3936##code-section module-header #fill in your manual code here 
     37from Products.CMFCore.permissions import View 
     38from Products.PleiadesEntity.Extensions.ws_validation import validate_name 
    4039##/code-section module-header 
    4140 
     
    162161        return periods 
    163162 
     163    security.declareProtected(View, 'post_validate') 
     164    def post_validate(self, REQUEST=None, errors=None): 
     165        vNameLanguage = REQUEST.get('nameLanguage', None) 
     166        vNameAttested = REQUEST.get('nameAttested', None) 
     167        invalid = validate_name(vNameLanguage, vNameAttested) 
     168        if len(invalid) > 0: 
     169            errors['nameAttested'] = invalid 
     170 
    164171 
    165172registerType(Name, PROJECTNAME) 
  • PleiadesEntity/trunk/tests/NameViews.txt

    r602 r740  
    5454    '...Name as Attested...' 
    5555     
    56 #    >>> browser.contents 
    57 #    '...Language and Writing System of Attested Name...' 
    58 #     
    59 #    >>> browser.contents 
    60 #    '...Time Periods...' 
    61 #     
    62 #    >>> browser.contents 
    63 #    '...Primary References...' 
    64 #     
    65 #    >>> browser.contents 
    66 #    '...Secondary References...' 
     56    >>> browser.contents 
     57    '...Language and Writing System...' 
    6758     
     59    >>> browser.contents 
     60    '...Name type...' 
    6861     
     62    >>> browser.contents 
     63    '...Accuracy of Attestation...' 
     64     
     65    >>> browser.contents 
     66    '...Completeness of Attestation...' 
     67     
     68    >>> browser.contents 
     69    '...Temporal attestations...' 
     70     
     71    >>> browser.contents 
     72    '...Primary References...' 
     73     
     74    >>> browser.contents 
     75    '...Secondary references...' 
     76     
     77Edit the name, modify the attestation using legal characters and language to verify validation 
     78 
     79    >>> browser.getLink('Log in').click() 
     80    >>> browser.getControl('Login Name').value = 'test_user_1_' 
     81    >>> browser.getControl('Password').value = 'secret' 
     82    >>> browser.getControl('Log in').click() 
     83    >>> url = url + '/base_edit' 
     84    >>> browser.open(url) 
     85    >>> control = browser.getControl(name='nameAttested') 
     86    >>> control.value = 'Innoxium Municipium' 
     87    >>> control = browser.getControl(name='nameLanguage') 
     88    >>> control.value = ['la'] 
     89    >>> control = browser.getControl(name='title') 
     90    >>> control.value = 'Innoxium Municipium' 
     91    >>> browser.getControl(name='form_submit').click() 
     92    >>> browser.contents 
     93    '...Changes saved...' 
     94 
     95Edit the name again, modify the attestation using illegal characters and language to verify validation 
     96 
     97    >>> url = url + '/base_edit' 
     98    >>> browser.open(url) 
     99    >>> control = browser.getControl(name='nameAttested') 
     100    >>> control.value = 'Municipium Noxium Maximum' 
     101    >>> control = browser.getControl(name='nameLanguage') 
     102    >>> control.value = ['grc'] 
     103    >>> control = browser.getControl(name='title') 
     104    >>> control.value = 'Municipium Noxium Maximum' 
     105    >>> browser.getControl(name='form_submit').click() 
     106    >>> browser.contents 
     107    '...23 invalid character(s) in name Municipium Noxium Maximum...' 
  • PleiadesEntity/trunk/tests/_testing.py.template

    r605 r740  
    1414from Products.PleiadesEntity.Extensions.loader import BA_ID_MAX 
    1515from Products.PleiadesEntity.Extensions.xmlutil import purifyText 
    16 from Products.PleiadesEntity.Extensions.cooking import setGeoTitleFromNames 
    1716 
  • PleiadesEntity/trunk/version.txt

    r706 r740  
    1 0.1 build 259 
     10.1 build 260