The error occurs when I use the render() function, e.g., teachers = db(
db.teacher.id>0).select().render(0)

The render() function works fine without the list:reference fields but 
fails with the list:reference fields.

On Wednesday, August 12, 2015 at 11:23:44 PM UTC-4, Massimo Di Pierro wrote:
>
> It is only when printed in CSV that it represents with the |. It is all 
> fine:
>
> In [1]:     db.define_table(
>
>    ...:         'school',
>
>    ...:         Field('Name'),
>
>    ...:         format='%(Name)s',
>
>    ...:         migrate=True
>
>    ...:     )
>
> Out[1]: <Table school (id,Name)>
>
>
> In [2]: 
>
>
> In [2]:     db.define_table(
>
>    ...:         'teacher',
>
>    ...:         Field('Name'),
>
>    ...:         Field('schools', 'list:reference school', label='School 
> Villages'),
>
>    ...:         format='%(Name)s',
>
>    ...:         migrate=True
>
>    ...:     )
>
> Out[2]: <Table teacher (id,Name,schools)>
>
>
> In [3]: 
>
>
> In [3]: db.school.insert(Name="a")
>
> Out[3]: 1L
>
>
> In [4]: db.school.insert(Name="b")
>
> Out[4]: 2L
>
>
> In [5]: db.school.insert(Name="c")
>
> Out[5]: 3L
>
>
> In [6]: db.teacher.insert(Name="xxx", schools=[1,2,3])
>
> Out[6]: 1L
>
>
> In [7]: teachers = db(db.teacher.id>0).select()
>
>
> In [8]: print teachers
>
> teacher.id,teacher.Name,teacher.schools
>
> 1,xxx,|1|2|3|
>
>
>
> In [9]: print teachers[0].schools
>
> [1L, 2L, 3L]
>
> On Wednesday, 12 August 2015 07:55:50 UTC-5, Michael Beller wrote:
>>
>>     db.define_table(
>>         'school',
>>         Field('Name'),
>>         format='%(Name)s',
>>         migrate=True
>>     )
>>
>>     db.define_table(
>>         'teacher',
>>         Field('Name'),
>>         Field('schools', 'list:reference school', label='School 
>> Villages'),
>>         format='%(Name)s',
>>         migrate=True
>>     )
>>
>>     teachers = db(db.teacher.id>0).select().render(0)
>>
>> Without the render(), it a Row with the piped school id's, e.g., 
>> 51,sally,|53|52|
>>
>> On Wednesday, August 12, 2015 at 1:50:20 AM UTC-4, Massimo Di Pierro 
>> wrote:
>>>
>>> Can you show us minimalist code to reproduce the problem?
>>>
>>> On Tuesday, 11 August 2015 23:03:24 UTC-5, Michael Beller wrote:
>>>>
>>>> I was using web2py 2.10.4 and encountered the error using 
>>>> list:reference:
>>>> <type 'exceptions.TypeError'> isinstance() arg 2 must be a class, type, 
>>>> or tuple of classes and types
>>>>
>>>> I then upgraded to 2.12.2 and applied this fix 
>>>> <https://github.com/web2py/pydal/commit/2172b776b9c41884717902e68900b41c105e0364#diff-114ce07f361177e0669ec9a374ef7d6a>
>>>>  
>>>> that others referenced in the forums having the same problem.
>>>>
>>>> Now I'm getting this error:
>>>> <type 'exceptions.AttributeError'> 'long' object has no attribute 'id'
>>>>
>>>> The error occurs in the render() function when applied to a query.
>>>>
>>>> File 
>>>> "/Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py",
>>>>  line 279, in __call__
>>>>     _fieldformat(self.ref, x.id) for x in value) or ''
>>>> File 
>>>> "/Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py",
>>>>  line 279, in <genexpr>
>>>>     _fieldformat(self.ref, x.id) for x in value) or ''
>>>> AttributeError: 'long' object has no attribute 'id'
>>>>
>>>> Does anybody else have this problem?
>>>>
>>>> Thanks.
>>>>
>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to