[web2py] Re: Change title of db field in a DAL select

2013-03-07 Thread Niphlod
If you want to do that not using executesql() you need to alter all the Row 
dicts in the resultset. Altering the colnames is not even documented 

On Thursday, March 7, 2013 6:55:05 AM UTC+1, at wrote:


 actually I was looking alternative of sql statement like *select **name, 
 dob date_of_birth, occupation from persons* in web2py DAL.

 anyways, after retrieving, when I print rows.colnames[3]  it returns str: 
 persons.dob
 but setting rows.colnames[3] to 'date_of_birth' gives error

 *rows.colnames[3] = 'date_of_birth' 
 *type 'exceptions.AttributeError' 'Row' object has no attribute '_extra'

 regards

 On Wednesday, 6 March 2013 14:34:30 UTC+5, Niphlod wrote:

 you can do it after retrieving it. After all, you define a model to be 
 consistent ^_^ .
 PS: the resultset is ~ a list of dictionaries, so you can play with it 
 freely.

 On Wednesday, March 6, 2013 10:21:39 AM UTC+1, at wrote:

 actually I wanted to change this label just in current record set, I 
 mean in *rows* only; is it possible? 

 thanks

 On Wednesday, 6 March 2013 14:18:32 UTC+5, 黄祥 wrote:

 i'm usually use it on models for :
 db.person.dob.label=T('Date of Birth')
 the other solution is to use labels in form (SQLFORM, CRUD, GRID)
 http://web2py.com/books/default/chapter/29/07



-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread 黄祥
yes, it can please use label
e.g.
db.person.dob.label=T('Date of Birth')

or if you use sqltable you can use headers
http://web2py.com/books/default/chapter/29/06#Serializing-Rows-in-views

-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread at
thanks for the swift response!

when this label statement should be run ... before or after running *
db().select*?

regards

On Wednesday, 6 March 2013 13:29:21 UTC+5, 黄祥 wrote:

 yes, it can please use label
 e.g.
 db.person.dob.label=T('Date of Birth')

 or if you use sqltable you can use headers
 http://web2py.com/books/default/chapter/29/06#Serializing-Rows-in-views


-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread 黄祥
i'm usually use it on models for :
db.person.dob.label=T('Date of Birth')
the other solution is to use labels in form (SQLFORM, CRUD, GRID)
http://web2py.com/books/default/chapter/29/07



-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread at
actually I wanted to change this label just in current record set, I mean 
in *rows* only; is it possible? 

thanks

On Wednesday, 6 March 2013 14:18:32 UTC+5, 黄祥 wrote:

 i'm usually use it on models for :
 db.person.dob.label=T('Date of Birth')
 the other solution is to use labels in form (SQLFORM, CRUD, GRID)
 http://web2py.com/books/default/chapter/29/07



-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread Niphlod
you can do it after retrieving it. After all, you define a model to be 
consistent ^_^ .
PS: the resultset is ~ a list of dictionaries, so you can play with it 
freely.

On Wednesday, March 6, 2013 10:21:39 AM UTC+1, at wrote:

 actually I wanted to change this label just in current record set, I mean 
 in *rows* only; is it possible? 

 thanks

 On Wednesday, 6 March 2013 14:18:32 UTC+5, 黄祥 wrote:

 i'm usually use it on models for :
 db.person.dob.label=T('Date of Birth')
 the other solution is to use labels in form (SQLFORM, CRUD, GRID)
 http://web2py.com/books/default/chapter/29/07



-- 

--- 
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.




[web2py] Re: Change title of db field in a DAL select

2013-03-06 Thread at

actually I was looking alternative of sql statement like *select **name, 
dob date_of_birth, occupation from persons* in web2py DAL.

anyways, after retrieving, when I print rows.colnames[3]  it returns str: 
persons.dob
but setting rows.colnames[3] to 'date_of_birth' gives error

*rows.colnames[3] = 'date_of_birth' 
*type 'exceptions.AttributeError' 'Row' object has no attribute '_extra'

regards

On Wednesday, 6 March 2013 14:34:30 UTC+5, Niphlod wrote:

 you can do it after retrieving it. After all, you define a model to be 
 consistent ^_^ .
 PS: the resultset is ~ a list of dictionaries, so you can play with it 
 freely.

 On Wednesday, March 6, 2013 10:21:39 AM UTC+1, at wrote:

 actually I wanted to change this label just in current record set, I mean 
 in *rows* only; is it possible? 

 thanks

 On Wednesday, 6 March 2013 14:18:32 UTC+5, 黄祥 wrote:

 i'm usually use it on models for :
 db.person.dob.label=T('Date of Birth')
 the other solution is to use labels in form (SQLFORM, CRUD, GRID)
 http://web2py.com/books/default/chapter/29/07



-- 

--- 
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.