Example #1
0
 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.')
Example #2
0
 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.')
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 def __response_create__(self, data, columns, keys):
     """data=(response,result,code,msg) 
     columns=('domain','renew','renData')
     keys=('name','exDate')"""
     if self.__code_isnot_1000__(data, '%s:%s'%columns[:2]): return
     objData = self.get_value_from_dict(('response','resData','%s:%s'%(columns[0],columns[2])),self._dict_answer)
     if objData:
         for key in keys:
             scope = '%s:%s'%(columns[0],key)
             self._dct_answer['data'][scope] = eppdoc.get_dct_value(objData, scope)
Example #6
0
 def __response_create__(self, data, columns, keys):
     """data=(response,result,code,msg)
     columns=('domain','renew','renData')
     keys=('name','exDate')"""
     if self.__code_isnot_1000__(data, '%s:%s' % columns[:2]): return
     objData = self.get_value_from_dict(('response', 'resData', '%s:%s' % (columns[0], columns[2])), self._dict_answer)
     if objData:
         for key in keys:
             scope = '%s:%s' % (columns[0], key)
             self._dct_answer['data'][scope] = eppdoc.get_dct_value(objData, scope)
Example #7
0
 def answer_greeting(self):
     "Part of process answer - parse greeting node."
     dct = self._dct_answer['data']
     greeting = self._dict_answer['greeting']
     for key in ('svID', 'svDate'):
         dct[key] = eppdoc.get_dct_value(greeting, key)
     svcMenu = greeting.get('svcMenu', {})
     for key in ('lang', 'version', 'objURI'):
         dct[key] = eppdoc.get_dct_value(svcMenu, key)
     self.defs[LANGS] = dct['lang'] = dct['lang'].split('\n')
     if type(self.defs[LANGS]) in (str, unicode):
         self.defs[LANGS] = (self.defs[LANGS], )
     # list of protocol versions:
     if dct.has_key('version') and type(dct['version']) in (unicode, str):
         dct['version'] = dct['version'].split('\n')
     # check objURI and extURI
     msg_invalid_schema_version = []
     dct['objURI'] = dct.get('objURI', '').split('\n')
     if dct['objURI']:
         self.check_schemas('objURI', self.defs[objURI], dct['objURI'])
     dct['extURI'] = eppdoc.get_dct_values(svcMenu,
                                           ('svcExtension', 'extURI'))
     if self.defs[extURI]:
         self.check_schemas('extURI', self.defs[extURI], dct['extURI'])
     #
     adjust_dct_keys(dct, ('lang', 'objURI', 'extURI'))
     # data collection policy, access
     dcp = greeting.get('dcp', {})
     dcp_access = dcp.get(
         'access',
         {}).keys()  # all, none, null, personal, personalAndOther, other
     if 'all' in dcp_access:
         access = 1
         msg = _T('All data are disclosed.')
     else:
         access = 0
         msg = _T('All data are hidden.')
     # Server Disclose Policy
     self._epp_cmd.server_disclose_policy = access
     dct['dcp'] = msg
Example #8
0
 def answer_greeting(self):
     "Part of process answer - parse greeting node."
     dct = self._dct_answer['data']
     greeting = self._dict_answer['greeting']
     for key in ('svID','svDate'):
         dct[key] = eppdoc.get_dct_value(greeting, key)
     svcMenu = greeting.get('svcMenu',{})
     for key in ('lang','version','objURI'):
         dct[key] = eppdoc.get_dct_value(svcMenu, key)
     self.defs[LANGS] = dct['lang'] = dct['lang'].split('\n')
     if type(self.defs[LANGS]) in (str,unicode):
         self.defs[LANGS] = (self.defs[LANGS],)
     # list of protocol versions:
     if dct.has_key('version') and type(dct['version']) in (unicode, str):
         dct['version'] = dct['version'].split('\n')
     # check objURI and extURI
     msg_invalid_schema_version = []
     dct['objURI'] = dct.get('objURI','').split('\n')
     if dct['objURI']:
         self.check_schemas('objURI', self.defs[objURI], dct['objURI'])
     dct['extURI'] = eppdoc.get_dct_values(svcMenu, ('svcExtension','extURI'))
     if self.defs[extURI]:
         self.check_schemas('extURI', self.defs[extURI], dct['extURI'])
     #
     adjust_dct_keys(dct,('lang','objURI','extURI'))
     # data collection policy, access
     dcp = greeting.get('dcp',{})
     dcp_access = dcp.get('access',{}).keys() # all, none, null, personal, personalAndOther, other
     if 'all' in dcp_access:
         access = 1
         msg = _T('All data are disclosed.')
     else:
         access = 0
         msg = _T('All data are hidden.')
     # Server Disclose Policy
     self._epp_cmd.server_disclose_policy = access
     dct['dcp'] = msg
Example #9
0
    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.'))
Example #10
0
    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.'))
Example #11
0
            if contact_addr:
                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,
Example #12
0
                    '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']