[web2py] Re: How to display reference field in sqltable?

2012-03-09 Thread Edward Shave
Many, many thanks for that. I ran your fix and now all is present and 
correct.

Thanks again,
Ed

On Friday, 9 March 2012 07:01:25 UTC, nick name wrote:

 On Thursday, March 8, 2012 8:52:34 PM UTC-5, Edward Shave wrote:

 Many thanks for reply, unfortunately it didn't work in this instance... I 
 wonder if it is because the table is referencing itself?


 By coincidence, I noticed the same problem earlier myself and opened 
 ticket #700 http://code.google.com/p/web2py/issues/detail?id=700 .

 It's not just self-referencing tables; it's referencing any table that has 
 not yet been defined. I also posted a more general solution in the ticket. 



[web2py] Re: How to display reference field in sqltable?

2012-03-08 Thread Alan Etkin
This should tell web2py to display the name instead of the id in
references

db.define_table('account', ..., format='%(name)s')

You can find more info in the book's chapter 6.5, Record
representation

On 7 mar, 20:52, Edward Shave ed.sh...@eshavefindings.co.uk wrote:
 *I have the following table definition...*
 *
 *
 *db.define_table('account',
 *
 *    Field('name'),*
 *    Field('transfer_acc','reference account'),
 *
 *    )*
 *
 db.account.name.requires = IS_NOT_EMPTY()
 *
 *
 db.account.transfer_acc.requires = IS_IN_DB(db,db.account.id,'%(name)s')

 ...Note the table contains a self referencing field.

 *
 *The reference field displays the referenced id in sqltable... What is best
 way to replace id with name of account? *


[web2py] Re: How to display reference field in sqltable?

2012-03-08 Thread Edward Shave
Many thanks for reply, unfortunately it didn't work in this instance... I 
wonder if it is because the table is referencing itself?

Anyway I have found the following works but I wonder about the efficiency? 

*db.account.transfer_acc.represent= lambda value:db.account[value].name*

On Thursday, 8 March 2012 11:27:14 UTC, Alan Etkin wrote:

 This should tell web2py to display the name instead of the id in 
 references 

 db.define_table('account', ..., format='%(name)s') 

 You can find more info in the book's chapter 6.5, Record 
 representation 

 On 7 mar, 20:52, Edward Shave ed.sh...@eshavefindings.co.uk wrote: 
  *I have the following table definition...* 
  * 
  * 
  *db.define_table('account', 
  * 
  *Field('name'),* 
  *Field('transfer_acc','reference account'), 
  * 
  *)* 
  * 
  db.account.name.requires = IS_NOT_EMPTY() 
  * 
  * 
  db.account.transfer_acc.requires = IS_IN_DB(db,db.account.id,'%(name)s') 

  
  ...Note the table contains a self referencing field. 
  
  * 
  *The reference field displays the referenced id in sqltable... What is 
 best 
  way to replace id with name of account? *



[web2py] Re: How to display reference field in sqltable?

2012-03-08 Thread Anthony
On Thursday, March 8, 2012 8:52:34 PM UTC-5, Edward Shave wrote:

 Many thanks for reply, unfortunately it didn't work in this instance... I 
 wonder if it is because the table is referencing itself?

 Anyway I have found the following works but I wonder about the efficiency? 

 *db.account.transfer_acc.represent= lambda value:db.account[value].name*


Yeah, I don't think format works for self referencing fields. Anyway, 
even if it did work, it would be doing the same thing as above, so wouldn't 
be any more efficient.

Anthony


[web2py] Re: How to display reference field in sqltable?

2012-03-08 Thread nick name
On Thursday, March 8, 2012 8:52:34 PM UTC-5, Edward Shave wrote:

 Many thanks for reply, unfortunately it didn't work in this instance... I 
 wonder if it is because the table is referencing itself?


By coincidence, I noticed the same problem earlier myself and opened ticket 
#700 http://code.google.com/p/web2py/issues/detail?id=700 .

It's not just self-referencing tables; it's referencing any table that has 
not yet been defined. I also posted a more general solution in the ticket.