def normalize(s): def replace_char(m): char = m.group() return CHAR_MAP.get(char, char) s = to_unicode(s) #translate non-roman text s = re.sub('[^a-zA-Z0-9\\s\\-]{1}', replace_char, s) return s.lower().encode('ascii', 'ignore')
def __init__(self, name, *args, **kwargs): self.name = to_unicode(name) db.Model.__init__(self, *args, **kwargs)
def by_login(cls, login): login = to_unicode(login) return db.query(cls).filter(cls.login == login).first()
def __init__(self, login, password=None, **kwargs): self.login = to_unicode(login) self.password = password kwargs.setdefault('fullname', u'') db.Model.__init__(self, **kwargs)
def by_name(cls, name): name = to_unicode(name) return db.query(cls).filter(cls.name == name).first()
def __init__(self, name, **kwargs): self.name = to_unicode(name) db.Model.__init__(self, **kwargs)