@ -39,6 +39,8 @@ class IdnaDomain(db.TypeDecorator):
"""
"""
impl = db . String ( 80 )
impl = db . String ( 80 )
cache_ok = True
python_type = str
def process_bind_param ( self , value , dialect ) :
def process_bind_param ( self , value , dialect ) :
""" encode unicode domain name to punycode """
""" encode unicode domain name to punycode """
@ -48,13 +50,13 @@ class IdnaDomain(db.TypeDecorator):
""" decode punycode domain name to unicode """
""" decode punycode domain name to unicode """
return idna . decode ( value )
return idna . decode ( value )
python_type = str
class IdnaEmail ( db . TypeDecorator ) :
class IdnaEmail ( db . TypeDecorator ) :
""" Stores a Unicode string in it ' s IDNA representation (ASCII only)
""" Stores a Unicode string in it ' s IDNA representation (ASCII only)
"""
"""
impl = db . String ( 255 )
impl = db . String ( 255 )
cache_ok = True
python_type = str
def process_bind_param ( self , value , dialect ) :
def process_bind_param ( self , value , dialect ) :
""" encode unicode domain part of email address to punycode """
""" encode unicode domain part of email address to punycode """
@ -70,13 +72,13 @@ class IdnaEmail(db.TypeDecorator):
localpart , domain_name = value . rsplit ( ' @ ' , 1 )
localpart , domain_name = value . rsplit ( ' @ ' , 1 )
return f ' { localpart } @ { idna . decode ( domain_name ) } '
return f ' { localpart } @ { idna . decode ( domain_name ) } '
python_type = str
class CommaSeparatedList ( db . TypeDecorator ) :
class CommaSeparatedList ( db . TypeDecorator ) :
""" Stores a list as a comma-separated string, compatible with Postfix.
""" Stores a list as a comma-separated string, compatible with Postfix.
"""
"""
impl = db . String
impl = db . String
cache_ok = True
python_type = list
def process_bind_param ( self , value , dialect ) :
def process_bind_param ( self , value , dialect ) :
""" join list of items to comma separated string """
""" join list of items to comma separated string """
@ -91,13 +93,13 @@ class CommaSeparatedList(db.TypeDecorator):
""" split comma separated string to list """
""" split comma separated string to list """
return list ( filter ( bool , ( item . strip ( ) for item in value . split ( ' , ' ) ) ) ) if value else [ ]
return list ( filter ( bool , ( item . strip ( ) for item in value . split ( ' , ' ) ) ) ) if value else [ ]
python_type = list
class JSONEncoded ( db . TypeDecorator ) :
class JSONEncoded ( db . TypeDecorator ) :
""" Represents an immutable structure as a json-encoded string.
""" Represents an immutable structure as a json-encoded string.
"""
"""
impl = db . String
impl = db . String
cache_ok = True
python_type = str
def process_bind_param ( self , value , dialect ) :
def process_bind_param ( self , value , dialect ) :
""" encode data as json """
""" encode data as json """
@ -107,8 +109,6 @@ class JSONEncoded(db.TypeDecorator):
""" decode json to data """
""" decode json to data """
return json . loads ( value ) if value else None
return json . loads ( value ) if value else None
python_type = str
class Base ( db . Model ) :
class Base ( db . Model ) :
""" Base class for all models
""" Base class for all models
"""
"""