Import idna library and move code a bit upwards

master
Stefan Auditor 7 years ago
parent 5a7272ff12
commit d9ea64fac7

@ -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
""" """

Loading…
Cancel
Save