def initialize_decorator(init):
 def initialize(self, *args, **kwargs):
  cls = type(self)
  for (k, v) in kwargs.items():
   if hasattr(cls, k):
    attr = getattr(cls, k)
    if isinstance(attr, InstrumentedAttribute):
     column = attr.property.columns[0]
     if isinstance(column.type, String):
      if (not isinstance(v, six.text_type)):
       v = six.text_type(v)
      if (column.type.length and (column.type.length < len(v))):
       raise exception.StringLengthExceeded(string=v, type=k, length=column.type.length)
  init(self, *args, **kwargs)
 return initialize

def initialize_decorator ( init ) : def initialize ( self , * args , ** kwargs ) : cls = type ( self ) for ( k , v ) in kwargs . items ( ) : if hasattr ( cls , k ) : attr = getattr ( cls , k ) if isinstance ( attr , InstrumentedAttribute ) : column = attr . property . columns [ 0 ] if isinstance ( column . type , String ) : if ( not isinstance ( v , six . text_type ) ) : v = six . text_type ( v ) if ( column . type . length and ( column . type . length < len ( v ) ) ) : raise exception . StringLengthExceeded ( string = v , type = k , length = column . type . length ) init ( self , * args , ** kwargs ) return initialize
ensure that the length of string field do not exceed the limit .