Changeset 2644 for TI05-delivery


Ignore:
Timestamp:
25/06/07 10:10:21 (12 years ago)
Author:
domlowe
Message:

validates ISO 8601 time strings using regular expression

Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server.egg-info/PKG-INFO

    r2631 r2644  
    11Metadata-Version: 1.0 
    22Name: ows-server 
     3<<<<<<< .mine 
     4Version: 0.0.0dev-r2625 
     5======= 
    36Version: 0.0.0dev-r2630 
     7>>>>>>> .r2643 
    48Summary: UNKNOWN 
    59Home-page: UNKNOWN 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server.egg-info/SOURCES.txt

    r2631 r2644  
    167167ows_server/templates/csml_describe_feature.kid 
    168168ows_server/templates/exception_report.kid 
     169<<<<<<< .mine 
     170ows_server/templates/wcs_asynchronous.kid 
     171======= 
    169172ows_server/templates/ndgPage.kid 
    170173ows_server/templates/wayf.kid 
    171174ows_server/templates/wcs_asynchronous.kid 
     175>>>>>>> .r2643 
    172176ows_server/templates/ows/__init__.py 
    173177ows_server/templates/ows/get_capabilities.kid 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcs.py

    r2625 r2644  
    102102    @parameter('Identifier', required=True) 
    103103    @parameter('BoundingBox', required=True, validator=V.bbox_2d) 
    104     @parameter('TimeSequence',required=True, validator=V.iso8601_time)  #TODO, need validator to handle iso8601 time strings 
     104    @parameter('TimeSequence',required=True, validator=V.iso8601_time) 
    105105    @parameter('Format', possibleValues=['application/netcdf'], required=True) 
    106106    @parameter('Store', possibleValues=['true', 'True', 'TRUE']) 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/validators.py

    r2625 r2644  
    4747         
    4848    """ 
    49     import xml.utils.iso8601 as isoT 
     49    #validates: 
    5050    #single time value e.g. 2002-03-01T13:00:00Z 
    51      
    5251    #start and end times: e.g 2002-03-01T13:00:00Z/2003-05-11T15:30:00Z 
     52    #regex matches: 
     53    #2002-03-01T13:00:00Z 
     54    #2002-03-01T13:00:00 
     55    #2002-03-01T13:00:00.00Z 
     56    #2002-03-01T13:00:00.00 
     57    #2002-03-01T13:00:00.0Z 
     58    #2002-03-01T13:00:00.0 
    5359     
    5460    def _checkTime(timestring): 
    55         try:  
    56             isoT.parse(timestring) 
    57             return timestring[:-1]  #return without the Z 
    58         except ValueError: 
    59             timestring=timestring + 'Z'   #maybe the Z has just been missed off 
    60             try: 
    61                 isoT.parse(timestring) 
    62                 return timestring[:-1]#return without the Z 
    63             except ValueError:                
    64                 raise InvalidParameterValue("Incorrect TimeSequence specification %s" % timestring, 'timeSequence') 
     61        import re 
     62        stringtotest=timestring 
     63        regex=re.compile('^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])T(?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?[.]?[0-5]?[0-9]?[Zz]?$') 
     64 
     65        if regex.match(timestring) !=None: 
     66            #time string is ok, return it without any trailing Z  
     67            if timestring[-1] in ['Z','z']: 
     68                return timestring[:-1] 
     69            else: 
     70                return stringtotest 
     71        else:  
     72            #timestring is not ok. 
     73            raise InvalidParameterValue("Incorrect TimeSequence specification %s" % timestring, 'timesequence') 
    6574             
     75    #split the timesequence request in to individual timestrings and test each one 
    6676    if timestring.find(',') == -1: 
    6777        timelist=timestring.split('/') 
Note: See TracChangeset for help on using the changeset viewer.