#NEWLINE# def create_record( self , name , zone , type , data , extra = None ) : #NEWLINE# #INDENT# "\n        Create a new record.\n\n        :param name: Record name without the domain name (e.g. www).\n                     Note: If you want to create a record for a base domain\n                     name, you should specify empty string ('') for this\n                     argument.\n        :type  name: ``str``\n\n        :param zone: Zone where the requested record is created.\n        :type  zone: :class:`Zone`\n\n        :param type: DNS record type (A, MX, TXT).\n        :type  type: :class:`RecordType`\n\n        :param data: Data for the record (depends on the record type).\n        :type  data: ``str``\n\n        :param extra: Extra attributes (driver specific, e.g. 'ttl').\n                      (optional)\n        :type extra: ``dict``\n\n        :rtype: :class:`Record`\n        " #NEWLINE# action = ( '/dns/%s/addRR' % zone . domain ) #NEWLINE# payload = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'data' : data , #NEWLINE# 'type' : type , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( extra is not None ) and ( extra . get ( 'ttl' , None ) is not None ) ) : #NEWLINE# #INDENT# payload [ 'ttl' ] = extra [ 'ttl' ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . connection . request ( action = action , data = payload , method = 'POST' ) #NEWLINE# #UNINDENT# except BaseHTTPError : #NEWLINE# #INDENT# e = sys . exc_info ( ) [ 1 ] #NEWLINE# exists_re = re . compile ( 'That RR already exists on the domain' ) #NEWLINE# if ( ( e . code == httplib . BAD_REQUEST ) and ( re . search ( exists_re , e . message ) is not None ) ) : #NEWLINE# #INDENT# value = ( '"%s" already exists in %s' % ( name , zone . domain ) ) #NEWLINE# raise RecordAlreadyExistsError ( value = value , driver = self , record_id = None ) #NEWLINE# #UNINDENT# raise e #NEWLINE# #UNINDENT# return self . ex_get_records_by ( zone = zone , name = name , type = zone ) [ 0 ]