1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-03-17 20:57:54 +02:00

Import idna library and move code a bit upwards

This commit is contained in:
Stefan Auditor 2018-04-12 21:35:38 +02:00
parent 5a7272ff12
commit d9ea64fac7

View File

@ -11,6 +11,20 @@ import time
import os
import glob
import smtplib
import idna
class Idna(db.TypeDecorator):
""" Stores a Unicode string in it's IDNA representation (ASCII only)
"""
impl = db.String
def process_bind_param(self, value, dialect):
return idna.encode(value)
def process_result_value(self, value, dialect):
return idna.decode(value)
# Many-to-many association table for domain managers
@ -38,19 +52,6 @@ class CommaSeparatedList(db.TypeDecorator):
return filter(bool, value.split(","))
class Idna(db.TypeDecorator):
""" Stores a Unicode string in it's IDNA representation (ASCII only)
"""
impl = db.String
def process_bind_param(self, value, dialect):
return value.encode("idna")
def process_result_value(self, value, dialect):
return value.decode("idna")
class Base(db.Model):
""" Base class for all models
"""