def __check_available__(self, dct_answer, dict_data, names, attr_name): """Assign available names for check_...() functions. names=('domain','name') """ column_name = '%s:%s' % names value = eppdoc.get_dct_value(dict_data, column_name) code = eppdoc.get_dct_attr(dict_data, column_name, attr_name) reason_key = '%s:reason' % value dct_answer['data'][value] = code in ('1', 'true') and 1 or 0 dct_answer['data'][reason_key] = eppdoc.get_dct_value(dict_data, '%s:reason' % names[0]) if dct_answer['data'][value] == 1 and dct_answer['data'][reason_key] == '': dct_answer['data'][reason_key] = _T('Not in registry: Object is available.')
def __check_available__(self, dct_answer, dict_data, names, attr_name): """Assign available names for check_...() functions. names=('domain','name') """ column_name = '%s:%s'%names value = eppdoc.get_dct_value(dict_data, column_name) code = eppdoc.get_dct_attr(dict_data, column_name, attr_name) reason_key = '%s:reason'%value dct_answer['data'][value] = code in ('1','true') and 1 or 0 dct_answer['data'][reason_key] = eppdoc.get_dct_value(dict_data, '%s:reason'%names[0]) if dct_answer['data'][value] == 1 and dct_answer['data'][reason_key] == '': dct_answer['data'][reason_key] = _T('Not in registry: Object is available.')
def __append_note_from_dct__(self,dict_data,cols): """Append columns values from dict to note stack. cols = ('column-name','column-name','column-name attr-name attr-name','node') TODO: prijde zrusit """ dct = self._dct_answer['data'] for column_name in cols: lcol = column_name.split(' ') # node_name, atributess if len(lcol)>1: value = eppdoc.get_dct_value(dict_data, lcol[0]) node_name = lcol[0] for a in lcol[1:]: val = eppdoc.get_dct_attr(dict_data, lcol[0], a) if val: append_dct(dct,'%s.%s'%(node_name,a),val) # attributes else: value = eppdoc.get_dct_value(dict_data, column_name) if value: append_dct(dct,column_name,value)
def __append_note_from_dct__(self, dict_data, cols): """Append columns values from dict to note stack. cols = ('column-name','column-name','column-name attr-name attr-name','node') TODO: prijde zrusit """ dct = self._dct_answer['data'] for column_name in cols: lcol = column_name.split(' ') # node_name, atributess if len(lcol) > 1: value = eppdoc.get_dct_value(dict_data, lcol[0]) node_name = lcol[0] for a in lcol[1:]: val = eppdoc.get_dct_attr(dict_data, lcol[0], a) if val: append_dct(dct, '%s.%s' % (node_name, a), val) # attributes else: value = eppdoc.get_dct_value(dict_data, column_name) if value: append_dct(dct, column_name, value)
def answer_response(self): "Part of process answer - parse response node." # Here we are fooking for particular function to parse answer. # If it doesn't exist we display whole answer by default method display_src = 1 # Dislapy whole answer? 1 - yes, 0 - no response = self._dict_answer.get('response', None) if response: result = response.get('result', None) if result: try: code = int(eppdoc.get_dct_attr(result, (), 'code')) except ValueError, msg: self._dct_answer['code'].append( '%s: %s' % (_T('Invalid response code'), msg)) code = 0 ## if code == 2502: ## # Message: Session limit exceeded; server closing connection ## self.send_logout() # and close connection reason = eppdoc.get_dct_value(result, 'msg') self._dct_answer['code'] = code self._dct_answer['reason'] = reason self._dct_answer['command'] = self._command_sent fnc_name = 'answer_response_%s' % self._command_sent.replace( ':', '_') # 'command:',self._command_sent,'fnc_name:',fnc_name #TEST # Name of command is very important. It is key for choose function dispatching answer: # delete_(contact|nsset|domain) fnc_name: answer_response_contact_delete # sendauthinfo_(contact|nsset|domain) fnc_name: answer_response_fred_sendauthinfo #print 'HANDLE:', fnc_name # TEST display HANDLE +++ #print 'COMMAND:', self._command_sent # +++ if hasattr(self, fnc_name): getattr(self, fnc_name)((result, code, reason)) display_src = 0 # Answer has been catch, we haven't display it again. else: self.__code_isnot_1000__( (result, code, reason), self._command_sent) # 'info:contact' else: self._dct_answer['errors'].append( _T('Missing result in the response message.'))
def answer_response(self): "Part of process answer - parse response node." # Here we are fooking for particular function to parse answer. # If it doesn't exist we display whole answer by default method display_src = 1 # Dislapy whole answer? 1 - yes, 0 - no response = self._dict_answer.get('response',None) if response: result = response.get('result',None) if result: try: code = int(eppdoc.get_dct_attr(result,(),'code')) except ValueError, msg: self._dct_answer['code'].append('%s: %s'%(_T('Invalid response code'),msg)) code = 0 ## if code == 2502: ## # Message: Session limit exceeded; server closing connection ## self.send_logout() # and close connection reason = eppdoc.get_dct_value(result,'msg') self._dct_answer['code'] = code self._dct_answer['reason'] = reason self._dct_answer['command'] = self._command_sent fnc_name = 'answer_response_%s'%self._command_sent.replace(':','_') # 'command:',self._command_sent,'fnc_name:',fnc_name #TEST # Name of command is very important. It is key for choose function dispatching answer: # delete_(contact|nsset|domain) fnc_name: answer_response_contact_delete # sendauthinfo_(contact|nsset|domain) fnc_name: answer_response_fred_sendauthinfo #print 'HANDLE:', fnc_name # TEST display HANDLE +++ #print 'COMMAND:', self._command_sent # +++ if hasattr(self,fnc_name): getattr(self,fnc_name)((result, code, reason)) display_src = 0 # Answer has been catch, we haven't display it again. else: self.__code_isnot_1000__((result, code, reason), self._command_sent) # 'info:contact' else: self._dct_answer['errors'].append(_T('Missing result in the response message.'))
self.__append_note_from_dct__(contact_addr,('contact:sp','contact:cc', 'contact:city','contact:street','contact:pc',)) disclosed = list(DISCLOSES) + ['addr'] not_disclosed = [] condis = contact_infData.get('contact:disclose',None) if condis: for k,v in condis.items(): # decamell: replace notifyEmail -> notify_email if v == {}: not_disclosed.append(decamell(k[8:])) for name in not_disclosed: if name in disclosed: disclosed.pop(disclosed.index(name)) dct['contact:disclose'] = disclosed dct['contact:hide'] = not_disclosed dct['contact:authInfo'] = eppdoc.get_dct_value(contact_infData, 'contact:authInfo') dct['contact:ident.type'] = eppdoc.get_dct_attr(contact_infData, 'contact:ident', 'type') dct['contact:ident'] = eppdoc.get_dct_value(contact_infData, 'contact:ident') dct['contact:notifyEmail'] = eppdoc.get_dct_value(contact_infData, 'contact:notifyEmail') dct['contact:vat'] = eppdoc.get_dct_value(contact_infData, 'contact:vat') def answer_response_domain_info(self, data): "data=(response,result,code,msg)" if self.__code_isnot_1000__(data, 'info:domain'): return try: resData = self._dict_answer['response']['resData'] domain_infData = resData['domain:infData'] except KeyError, msg: self.append_error('answer_response_domain_info KeyError: %s'%msg) else: self.__append_note_from_dct__(domain_infData, ('domain:name','domain:roid','domain:status s','domain:status',
)) disclosed = list(DISCLOSES) + ['addr'] not_disclosed = [] condis = contact_infData.get('contact:disclose', None) if condis: for k, v in condis.items(): # decamell: replace notifyEmail -> notify_email if v == {}: not_disclosed.append(decamell(k[8:])) for name in not_disclosed: if name in disclosed: disclosed.pop(disclosed.index(name)) dct['contact:disclose'] = disclosed dct['contact:hide'] = not_disclosed dct['contact:authInfo'] = eppdoc.get_dct_value( contact_infData, 'contact:authInfo') dct['contact:ident.type'] = eppdoc.get_dct_attr( contact_infData, 'contact:ident', 'type') dct['contact:ident'] = eppdoc.get_dct_value( contact_infData, 'contact:ident') dct['contact:notifyEmail'] = eppdoc.get_dct_value( contact_infData, 'contact:notifyEmail') dct['contact:vat'] = eppdoc.get_dct_value(contact_infData, 'contact:vat') def answer_response_domain_info(self, data): "data=(response,result,code,msg)" if self.__code_isnot_1000__(data, 'info:domain'): return try: resData = self._dict_answer['response']['resData'] domain_infData = resData['domain:infData'] except KeyError, msg: self.append_error('answer_response_domain_info KeyError: %s' % msg)