blockstack_zones/record_processors.py
def process_soa(data, template):
    """
    Replace {SOA} in template with a set of serialized SOA records
    """
    record = template[:]

    if data is not None:
    
        assert len(data) == 1, "Only support one SOA RR at this time"
        data = data[0]

        soadat = []
        domain_fields = ['mname', 'rname']
        param_fields = ['serial', 'refresh', 'retry', 'expire', 'minimum']

        for f in domain_fields + param_fields:
            assert f in data.keys(), "Missing '%s' (%s)" % (f, data)

        data_name = str(data.get('name', '@'))
        soadat.append(data_name)

        if data.get('ttl') is not None:
            soadat.append( str(data['ttl']) )
  
        soadat.append("IN")
        soadat.append("SOA")

        for key in domain_fields:
            value = str(data[key])
            soadat.append(value)

        soadat.append("(")

        for key in param_fields:
            value = str(data[key])
            soadat.append(value)

        soadat.append(")")

        soa_txt = " ".join(soadat)
        record = record.replace("{soa}", soa_txt)

    else:
        # clear all SOA fields 
        record = record.replace("{soa}", "")

    return record
def process_soa(data, template):
    """
    Replace {SOA} in template with a set of serialized SOA records
    """
    record = template[:]

    if data is not None:
    
        assert len(data) == 1, "Only support one SOA RR at this time"
        data = data[0]

        soadat = []
        domain_fields = ['mname', 'rname']
        param_fields = ['serial', 'refresh', 'retry', 'expire', 'minimum']

        for f in domain_fields + param_fields:
            assert f in data.keys(), "Missing '%s' (%s)" % (f, data)

        data_name = str(data.get('name', '@'))
        soadat.append(data_name)

        if data.get('ttl') is not None:
            soadat.append( str(data['ttl']) )
  
        soadat.append("IN")
        soadat.append("SOA")

        for key in domain_fields:
            value = str(data[key])
            soadat.append(value)

        soadat.append("(")

        for key in param_fields:
            value = str(data[key])
            soadat.append(value)

        soadat.append(")")

        soa_txt = " ".join(soadat)
        record = record.replace("{soa}", soa_txt)

    else:
        # clear all SOA fields 
        record = record.replace("{soa}", "")

    return record
def process_soa ( data , template ) : record = template [ : ] if data is not None : assert len ( data ) == 1 , "Only support one SOA RR at this time" data = data [ 0 ] soadat = [ ] domain_fields = [ 'mname' , 'rname' ] param_fields = [ 'serial' , 'refresh' , 'retry' , 'expire' , 'minimum' ] for f in domain_fields + param_fields : assert f in data . keys ( ) , "Missing '%s' (%s)" % ( f , data ) data_name = str ( data . get ( 'name' , '@' ) ) soadat . append ( data_name ) if data . get ( 'ttl' ) is not None : soadat . append ( str ( data [ 'ttl' ] ) ) soadat . append ( "IN" ) soadat . append ( "SOA" ) for key in domain_fields : value = str ( data [ key ] ) soadat . append ( value ) soadat . append ( "(" ) for key in param_fields : value = str ( data [ key ] ) soadat . append ( value ) soadat . append ( ")" ) soa_txt = " " . join ( soadat ) record = record . replace ( "{soa}" , soa_txt ) else : # clear all SOA fields  record = record . replace ( "{soa}" , "" ) return record
Replace {SOA} in template with a set of serialized SOA records
Replace { SOA } in template with a set of serialized SOA records