ceelian/Flatty — Issue #2: Problem with subclassed list types
Author: mluethi
Created: 2012-01-12 22:51:00+00:00
State: open

Given the following code

```python
#!/usr/bin/env python
# encoding: utf-8

from flatty import Schema, TypedList

class X(Schema):
x = int

class Y(Schema):
y = int

class Top(Schema):
t1 = TypedList.set_type(X)
t2 = TypedList.set_type(Y)

a = X(x=1)
b = Y(y=2)
t = Top(t1=[a], t2=[b])

print t.flatit()
```

I get this error here:

```python
*** Python 2.6.6 (r266:84292, Jan 7 2011, 13:16:36) [MSC v.1500 32 bit (Intel)] on win32. ***
>>>
Traceback (most recent call last):
File "", line 248, in run_nodebug
File "C:\_Temp\flatty_test\flatty_bug3.py", line 20, in
print t.flatit()
File "C:\_Temp\flatty_test\flatty\flatty.py", line 128, in flatit
return flatit(self)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 503, in flatit
return ConvertManager.to_flat(obj_type, obj)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 401, in to_flat
return cls._convert_dict[type]['conv'].to_flat(val_type,obj)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 269, in to_flat
attr_value = flatit(attr_value, attr_type)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 503, in flatit
return ConvertManager.to_flat(obj_type, obj)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 397, in to_flat
return cls._convert_dict[type]['conv'].to_flat(val_type, obj)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 320, in to_flat
check_type(obj_type.ftype,item)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 491, in check_type
ConvertManager.check_type(attr_type, attr_value)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 446, in check_type
cls._convert_dict[type]['conv'].check_type(attr_type,attr_value)
File "C:\_Temp\flatty_test\flatty\flatty.py", line 249, in check_type
raise TypeError(repr(type(attr_value)) +'!=' + repr(attr_type))
TypeError: !=
>>>
```

Maybe I'm doing something wrong?
But in my application I need this feature...

Thank you very much for fixing this great package!
Marcel