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)
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 column.type.length and \ column.type.length < len(str(v)): #if signing.token_format == 'PKI', the id will #store it's public key which is very long. if config.CONF.signing.token_format == 'PKI' and \ self.__tablename__ == 'token' and \ k == 'id': continue raise exception.StringLengthExceeded( string=v, type=k, length=column.type.length) init(self, *args, **kwargs)