Hi,

I attached a file with code that reproduces the problem.
For this example I expect to only return options African and Swallow, not 
John and not Doe.
I traced the problem back to the call from sqlhtml.py on line 217 to the 
IS_IN_DB validators function options(). I'm not sure if the fix should be 
in the widget or in the IS_IN_DB validator.
Personally I'd fix it in the IS_IN_DB validator, but then that might break 
the way request_tenant was intended to behave and/or break backwards 
compatibiity.

If you tell me where you want it fixed I might be able to cook up a patch 
over the weekend,

Thanks,

Tsvi

On Wednesday, February 29, 2012 12:47:04 AM UTC+2, tsvim wrote:
>
> Hi,
>
> In my models I have 2 tables, where table 1 has field "a" referencing
> table 2. As each user has a bunch of fields both in table 1 as well as
> in table 2, I used the request_tenant field with some uuid in both
> tables which is tied to the user (I'm not using the users ID for
> various reasons).
> I tried creating a form for table 1 with SQLFORM, but the select
> dropdown for field "a" returns all the items in table 2, and doesn't
> filter them according to the request_tenant field, which I would
> consider the correct behavior.
>
> I'll show some code tomorrow.
> Can you confirm this being a bug? Or am I missing something?
>
> Thanks,
>
> Tsvi
> Sent from my phone
>
>
On Wednesday, February 29, 2012 12:47:04 AM UTC+2, tsvim wrote:
>
> Hi,
>
> In my models I have 2 tables, where table 1 has field "a" referencing
> table 2. As each user has a bunch of fields both in table 1 as well as
> in table 2, I used the request_tenant field with some uuid in both
> tables which is tied to the user (I'm not using the users ID for
> various reasons).
> I tried creating a form for table 1 with SQLFORM, but the select
> dropdown for field "a" returns all the items in table 2, and doesn't
> filter them according to the request_tenant field, which I would
> consider the correct behavior.
>
> I'll show some code tomorrow.
> Can you confirm this being a bug? Or am I missing something?
>
> Thanks,
>
> Tsvi
> Sent from my phone
>
>
db = DAL('sqlite://storage.sqlite')
db._common_fields.append(Field('request_tenant',default=lambda: session.token,writable=False))
db.define_table('a',Field('name','string'),format='%(name)s')
db.define_table('b',Field('a_name','reference a'))
session.token = '1234'
sample_list = [{'name':'John'},{'name':'Doe'}]
db.a.bulk_insert(sample_list)
session.token = '4567'
sample_list = [{'name':'African'},{'name':'Swallow'}]
db.a.bulk_insert(sample_list)
form = SQLFORM(db.b)
print form

Reply via email to