You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-07-15 01:24:34 +02:00
Import idna library and move code a bit upwards
This commit is contained in:
@ -11,6 +11,20 @@ import time
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import smtplib
|
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
|
# Many-to-many association table for domain managers
|
||||||
@ -38,19 +52,6 @@ class CommaSeparatedList(db.TypeDecorator):
|
|||||||
return filter(bool, value.split(","))
|
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):
|
class Base(db.Model):
|
||||||
""" Base class for all models
|
""" Base class for all models
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user