class SomeType(ComplexModel): __namespace__ = "zo" anything = AnyXml(schema_tag='{%s}any' % NS_XSD, namespace='##other', process_contents='lax')
def _get_spyne_type(v): """Map sqlalchemy types to spyne types.""" cust = {} if v.primary_key: cust['primary_key'] = True if not v.nullable: cust['nullable'] = False cust['min_occurs'] = 1 if isinstance(v.type, sqlalchemy.Enum): if v.type.convert_unicode: return Unicode(values=v.type.enums, **cust) else: cust['type_name'] = v.type.name return Enum(*v.type.enums, **cust) if isinstance(v.type, (sqlalchemy.UnicodeText, sqlalchemy.Text)): return Unicode(**cust) if isinstance(v.type, (sqlalchemy.Unicode, sqlalchemy.String, sqlalchemy.VARCHAR)): return Unicode(v.type.length, **cust) if isinstance(v.type, sqlalchemy.Numeric): return Decimal(v.type.precision, v.type.scale, **cust) if isinstance(v.type, PGXml): if len(cust) > 0: return AnyXml(**cust) else: return AnyXml if isinstance(v.type, PGHtml): if len(cust) > 0: return AnyHtml(**cust) else: return AnyHtml if type(v.type) in _sq2sp_type_map: retval = _sq2sp_type_map[type(v.type)] if len(cust) > 0: return retval.customize(**cust) else: return retval if isinstance(v.type, (PGObjectJson, PGObjectXml)): retval = v.type.cls if len(cust) > 0: return retval.customize(**cust) else: return retval if isinstance(v.type, PGFileJson): retval = v.FileData if len(cust) > 0: return v.FileData.customize(**cust) else: return retval raise Exception("Spyne type was not found. Probably _sq2sp_type_map " "needs a new entry. %r" % v)