by default a Field('something', db.othertable) has attached an options 
widget that is generated by a requires=IS_IN_DB(db, 'othertable.id', format)

If you don't want that select widget and you are fine with a normal 
"string" input, better to do something like

Field('something', 'reference othertable', requires=[IS_IN_DB(db, 
'othertable.id')])

i.e. if you use a requires=IS_IN_DB() the widget is a SELECT, if you use a 
requires=[IS_IN_DB()] the widget is an INPUT

On Tuesday, December 4, 2012 8:03:39 AM UTC+1, onetwomany wrote:
>
> I have a table A  that is referenced by another B using the standard 
> reference type in web2py.
>
> db.define_table('A',
> ...
>    field('name')
> ...
> )
>
> db.define_table('B',
> ...
>    field('A', db.A)
> ...
> )
>
>
>  Previously, everything was working fine but after importing a sizeable 
> amount of records (>300k rows) into table A, the app stalls when trying to 
> load a form generated by 
>
> form = SQLFORM(db.B, record = x)
>>
>>  Tracing the stall, I found that this occurred at the point where SQLFORM 
> tries to build the options widget and populate it with records from table 
> A. I have a modest server and hence, this problem may not be noticeable at 
> this scale for a more powerful server. 
>
> The workaround I have managed to get working is to override the default 
> options widget with
>
> db.define_table('B',
> ...
>    field('A', db.A, widget=SQLFORM.widgets.string.widget)
> ...
> )
>
> The question I have is if there is a better way to overcome this?
>

-- 



Reply via email to