You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-07-13 01:20:28 +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 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
|
||||
"""
|
||||
|
Reference in New Issue
Block a user