I've deleted the testing db and started with a new one and now it works for 
me too. I've tried add a new record to "problemsHere" but it gave me an 
unexpected error (the DAL expected an unique field in "language" and 
"language" is no longer an unique field), so probably the issue was 
somewhere else.

Thanks.

Il giorno lunedì 27 maggio 2013 21:41:58 UTC+2, Niphlod ha scritto:
>
> I can't replicate the issue you're having. That syntax works. Check again 
> your code ....
>
> BTW: it's quite a strange model. you want the language to be unique in the 
> first table. In the second one you reference the first table (that is 
> unique by definition) with a non unique reference, but then you compute a 
> field to be unique.......if this is not a cut/paste just to show us a 
> possible problem and is in fact your underlying model, I'd advise to 
> rethink to it :P
>

It's a simplified version of the two db tables who behaved oddly. 
"ComputedField" is actually an hash value based on different fields from 
the table. :)


>
> On Monday, May 27, 2013 3:53:03 PM UTC+2, Matteo Luperto wrote:
>>
>> Hi, I want to compute a field based on the value of another field, which 
>> is a foreign key, in a way similar to: 
>>
>> db.define_table('language',
>>     Field('language', 'string', required = True, unique = True, length = 
>> 64),
>>     format='%(language)s'
>> )
>>
>> db.define_table('problemsHere',
>>     Field('language', 'reference language', required = True, unique = 
>> False),
>>     Field('otherField', 'integer'),
>>     Field('computedField', 
>>                         length=32,
>>                         unique=True,
>>                         writable=False,
>>                         readable=False,
>>                         compute=lambda row: db.language(row['language']).
>> language)
>> )
>> I've tried both syntaxes from this similar 
>> question<https://groups.google.com/forum/?fromgroups#!topic/web2py/x53LPKqRpgI>but
>>  none of them seems to work for me. The computedField is always set to 
>> "None". 
>> Does anybody knows a way to access a foreign key in a computed field, 
>> solving my problem?
>>
>> Thank you in advance,
>> ~Matteo
>>
>

-- 

--- 
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/groups/opt_out.


Reply via email to