Ejemplo n.º 1
0
def addHeaders(headers,response):
    HEADS=['COUNT-SOURCES',
           'COUNT-ATOMS',
           'COUNT-MOLECULES',
           'COUNT-SPECIES',
           'COUNT-STATES',
           'COUNT-COLLISIONS',
           'COUNT-RADIATIVE',
           'COUNT-NONRADIATIVE',
           'TRUNCATED',
           'APPROX-SIZE']

    headers = CaselessDict(headers)

    try:
        response['Last-Modified'] = getFormatLastModified(headers['LAST-MODIFIED'])
    except:
        pass

    for h in HEADS:
        if headers.has_key(h):
            response['VAMDC-'+h] = '%s'%headers[h]

    if headers.has_key('LAST-MODIFIED'):
        response['Last-Modified'] = '%s'%headers['LAST-MODIFIED']

    return response
Ejemplo n.º 2
0
def addHeaders(headers,request,response):
    HEADS=['COUNT-SOURCES',
           'COUNT-ATOMS',
           'COUNT-MOLECULES',
           'COUNT-SPECIES',
           'COUNT-STATES',
           'COUNT-COLLISIONS',
           'COUNT-RADIATIVE',
           'COUNT-NONRADIATIVE',
           'TRUNCATED',
           'APPROX-SIZE']

    headers = CaselessDict(headers)

    headlist_asString=''
    for h in HEADS:
        if headers.has_key(h):
            response['VAMDC-'+h] = '%s'%headers[h]
            headlist_asString += 'VAMDC-'+h+', '

    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Expose-Headers'] = headlist_asString[:-2]

    lastmod = headers.get('LAST-MODIFIED')
    if not lastmod and hasattr(settings,'LAST_MODIFIED'):
        lastmod=settings.LAST_MODIFIED

    if isinstance(lastmod,datetime.date):
        response['Last-Modified'] = getFormatLastModified(lastmod)
    elif isinstance(lastmod,str):
        response['Last-Modified'] = lastmod
    else:
        pass

    return response
Ejemplo n.º 3
0
def addHeaders(headers,response):
    HEADS=['COUNT-SOURCES',
           'COUNT-ATOMS',
           'COUNT-MOLECULES',
           'COUNT-SPECIES',
           'COUNT-STATES',
           'COUNT-COLLISIONS',
           'COUNT-RADIATIVE',
           'COUNT-NONRADIATIVE',
           'TRUNCATED',
           'APPROX-SIZE']

    headers = CaselessDict(headers)

    for h in HEADS:
        if headers.has_key(h):
            response['VAMDC-'+h] = '%s'%headers[h]

    lastmod = headers.get('LAST-MODIFIED')
    if not lastmod and hasattr(settings,'LAST_MODIFIED'):
        lastmod=settings.LAST_MODIFIED

    if isinstance(lastmod,datetime.date):
        response['Last-Modified'] = getFormatLastModified(lastmod)
    elif isinstance(lastmod,str):
        response['Last-Modified'] = lastmod
    else:
        pass

    return response
Ejemplo n.º 4
0
def addHeaders(headers, request, response):
    HEADS = [
        'COUNT-SOURCES', 'COUNT-ATOMS', 'COUNT-MOLECULES', 'COUNT-SPECIES',
        'COUNT-STATES', 'COUNT-COLLISIONS', 'COUNT-RADIATIVE',
        'COUNT-NONRADIATIVE', 'TRUNCATED', 'APPROX-SIZE'
    ]

    headers = CaselessDict(headers)

    headlist_asString = ''
    for h in HEADS:
        if headers.has_key(h):
            response['VAMDC-' + h] = '%s' % headers[h]
            headlist_asString += 'VAMDC-' + h + ', '

    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Expose-Headers'] = headlist_asString[:-2]

    lastmod = headers.get('LAST-MODIFIED')
    if not lastmod and hasattr(settings, 'LAST_MODIFIED'):
        lastmod = settings.LAST_MODIFIED

    if isinstance(lastmod, datetime.date):
        response['Last-Modified'] = getFormatLastModified(lastmod)
    elif isinstance(lastmod, str):
        response['Last-Modified'] = lastmod
    else:
        pass

    return response
Ejemplo n.º 5
0
def addHeaders(headers, response):
    HEADS = [
        'COUNT-SOURCES', 'COUNT-ATOMS', 'COUNT-MOLECULES', 'COUNT-SPECIES',
        'COUNT-STATES', 'COUNT-COLLISIONS', 'COUNT-RADIATIVE',
        'COUNT-NONRADIATIVE', 'TRUNCATED', 'APPROX-SIZE'
    ]

    headers = CaselessDict(headers)

    for h in HEADS:
        if headers.has_key(h):
            response['VAMDC-' + h] = '%s' % headers[h]

    lastmod = headers.get('LAST-MODIFIED')
    if not lastmod and hasattr(settings, 'LAST_MODIFIED'):
        lastmod = settings.LAST_MODIFIED

    if isinstance(lastmod, datetime.date):
        response['Last-Modified'] = getFormatLastModified(lastmod)
    elif isinstance(lastmod, str):
        response['Last-Modified'] = lastmod
    else:
        pass

    return response
Ejemplo n.º 6
0
def addHeaders(headers,response):
    HEADS=['COUNT-SOURCES',
           'COUNT-ATOMS',
           'COUNT-MOLECULES',
           'COUNT-SPECIES',
           'COUNT-STATES',
           'COUNT-COLLISIONS',
           'COUNT-RADIATIVE',
           'COUNT-NONRADIATIVE',
           'TRUNCATED',
           'APPROX-SIZE']

    headers = CaselessDict(headers)

    for h in HEADS:
        if headers.has_key(h):
            if headers[h]: response['VAMDC-'+h] = '%s'%headers[h]
    return response