예제 #1
0
파일: srschema.py 프로젝트: yeeon/sirepo
def _validate_cookie_def(c_def):
    """Validate the cookie definitions in the schema

    Validations performed:
        cannot contain delimiters we use on the client side
        values must match the valType if provided
        timeout must be numeric if provided

    Args:
        data (pkcollections.Dict): cookie definition object from the schema
    """
    c_delims = '|:;='
    c_delim_re = re.compile('[{}]'.format(c_delims))
    if c_delim_re.search(str(c_def.name) + str(c_def.value)):
        raise AssertionError(util.err(c_def, 'cookie name/value cannot include delimiters {}', c_delims))
    if 'valType' in c_def:
        if c_def.valType == 'b':
            pkconfig.parse_bool(c_def.value)
        if c_def.valType == 'n':
            float(c_def.value)
    if 'timeout' in c_def:
        float(c_def.timeout)
예제 #2
0
def _validate_cookie_def(c_def):
    """Validate the cookie definitions in the schema

    Validations performed:
        cannot contain delimiters we use on the client side
        values must match the valType if provided
        timeout must be numeric if provided

    Args:
        data (pkcollections.Dict): cookie definition object from the schema
    """
    c_delims = '|:;='
    c_delim_re = re.compile('[{}]'.format(c_delims))
    if c_delim_re.search(str(c_def.name) + str(c_def.value)):
        raise AssertionError(util.err(c_def, 'cookie name/value cannot include delimiters {}', c_delims))
    if 'valType' in c_def:
        if c_def.valType == 'b':
            pkconfig.parse_bool(c_def.value)
        if c_def.valType == 'n':
            float(c_def.value)
    if 'timeout' in c_def:
        float(c_def.timeout)