def normilizeID(self, strid): try: m1 = unicode(strid).split('/') result = None if len(m1) > 1: result = '' m2 = unicode(m1[1]).split(',') for m in m2: if result: result += ',' m3 = m.split(':') if len(m3) > 1: result += self.normID(m3[0]) + ':' + self.normID(m3[1]) else: result += self.normID(m3[0]) return (int(self.normID(m1[0])), result) except TypeError: log.warning( '%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value)) return None except: log.error( '%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value)) raise dmbErrorUnknown
def numCoding(self, x, code_index = 'en'): try: if not self.code_tables.has_key(code_index): return x code_table = self.code_tables[code_index] result = '' while x != None: if 9 < x % 100 < len(code_table): result += code_table[(x % 100)] x /= 100 else: result += code_table[(x % 10)] x /= 10 if x == 0: x = None return result[::-1] except: log.error('%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value))
def addToQueueSend(self, user, post, comment = None, tag = [], id_recommend = None): try: self.db.addToSendHistory(login = user, post = post, comment = comment) subs = self.db.getSubscribers(post = post, user = user, comment = comment, tag = tag) if subs: old_locale = self.def_locale for rec in subs: self.def_locale = self.getUserParams(rec)['locale'] try: message = self.show(login = rec, post = post, comment = comment, id_recommend = id_recommend, show_high_mesg = 1, error_mesg = None) except dmbError as exc: log.error(self.getText(exc.getText(), 'en')) if message: self.queue_to_send.append({'jid': self.getJid(rec), 'message': message, 'login': rec, 'post': post, 'comment': comment, 'id_recommend': id_recommend}) self.db.addToSendHistory(login = rec, post = post, comment = comment) self.def_locale = old_locale except: log.error('%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value))
def addToQueueSend(self, user, post, comment=None, tag=[], id_recommend=None): try: self.db.addToSendHistory(login=user, post=post, comment=comment) subs = self.db.getSubscribers(post=post, user=user, comment=comment, tag=tag) if subs: old_locale = self.def_locale for rec in subs: self.def_locale = self.getUserParams(rec)['locale'] try: message = self.show(login=rec, post=post, comment=comment, id_recommend=id_recommend, show_high_mesg=1, error_mesg=None) except dmbError as exc: log.error(self.getText(exc.getText(), 'en')) if message: self.queue_to_send.append({ 'jid': self.getJid(rec), 'message': message, 'login': rec, 'post': post, 'comment': comment, 'id_recommend': id_recommend }) self.db.addToSendHistory(login=rec, post=post, comment=comment) self.def_locale = old_locale except: log.error( '%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value))
def numCoding(self, x, code_index='en'): try: if not self.code_tables.has_key(code_index): return x code_table = self.code_tables[code_index] result = '' while x != None: if 9 < x % 100 < len(code_table): result += code_table[(x % 100)] x /= 100 else: result += code_table[(x % 10)] x /= 10 if x == 0: x = None return result[::-1] except: log.error( '%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value))
def normilizeID(self, strid): try: m1 = unicode(strid).split('/') result = None if len(m1) > 1: result = '' m2 = unicode(m1[1]).split(',') for m in m2: if result: result += ',' m3 = m.split(':') if len(m3) > 1: result += self.normID(m3[0]) + ':' + self.normID(m3[1]) else: result += self.normID(m3[0]) return (int(self.normID(m1[0])), result) except TypeError: log.warning('%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value)) return None except: log.error('%d %s %s' % (sys.exc_traceback.tb_lineno, sys.exc_type, sys.exc_value)) raise dmbErrorUnknown