automatically customising query result

5 views
Skip to first unread message

Timmie

unread,
Apr 18, 2009, 6:30:55 AM4/18/09
to web2py Web Framework
Hello,
when building a SQLFORM, there are really useful helpers such as
* labels={'name':'Your Full Name:'}
* col3={'name':A('what is this?', _href='http://www.google.com/search?
q=define:name')}

These are very convenient when creating the form in the controller.

Is there a possibility to use the same arguments or similar ones to
customise the selection

def recipes()
recepies = db().select(db.recepies.ALL)

return dict(recipies=recipies)

So that
{{=BEAUTIFY(response._vars)}}

will show the table headers with defined lables (label) and predefined
fields (names)
instead of
recipie.id recipie.title recipie.date ... ?


Thanks & kind regards,
Timmie

Iceberg

unread,
Apr 18, 2009, 10:53:57 AM4/18/09
to web2py Web Framework
Read doc here. http://www.web2py.com/examples/global/vars/SQLTABLE

The "headers" argument does what you want.

Timmie

unread,
Apr 20, 2009, 10:44:40 AM4/20/09
to web2py Web Framework
Thanks about the link to this hidden documentation.

> Read doc here.http://www.web2py.com/examples/global/vars/SQLTABLE
>
> The "headers" argument does what you want.

Searching for SQLTABLE on this list I got:
predefined label and SQLTABLE header [1].

Can you tell me how I need to define my table and retrive my output in
order to let the
headers and SQLForm labels be automatically named as 'Name'

db.define_table('table1',SQLField('name',label='Name'))

Is there an example which employs this technique?

Thanks,
Timmie

[1] http://groups.google.com/group/web2py/browse_thread/thread/c1d1f512c49ecf1e/14096d9146941f32?lnk=gst&q=SQLTABLE#14096d9146941f32

Tim Michelsen

unread,
Apr 21, 2009, 5:45:28 PM4/21/09
to web...@googlegroups.com
Hello,
sorry for comming of with this again.

I defined my table like:


> db.define_table('table1',SQLField('name',label='Name'))

But in the output table I still get:
table1.id table1.name.

Why can this be?

Here comes an improvement suggestion for the db admin:

we can define default values for tables:
* field names
* field labels
* field types
* field validators

If one looks at this, this is just tabular data:


field1.name, field1.label, field1.type, field1.validator
field2.name, field2.label, field2.type, field2.validator

As web2py is so database intelligent, why not letting users enter this
data via a entry for in the data base backend?
This will then be inserted in the metatable of table1.

I tried this with a simple csv file and it reduced already by typing!

I think this could help to improve the usability.

Thanks,
Timmie

mdipierro

unread,
Apr 21, 2009, 5:53:28 PM4/21/09
to web2py Web Framework


On 21 Apr, 16:45, Tim Michelsen <timmichel...@gmx-topmail.de> wrote:
> Hello,
> sorry for comming of with this again.
>
> I defined my table like:
>
> > db.define_table('table1',SQLField('name',label='Name'))
>
> But in the output table I still get:
> table1.id table1.name.
>
> Why can this be?

tables have a unique id by default. You cannot get rid of it.

>
> Here comes an improvement suggestion for the db admin:
>
> we can define default values for tables:
> * field names
> * field labels
> * field types
> * field validators
>
> If one looks at this, this is just tabular data:
>
> field1.name, field1.label, field1.type, field1.validator
> field2.name, field2.label, field2.type, field2.validator
>
> As web2py is so database intelligent, why not letting users enter this
> data via a entry for in the data base backend?
> This will then be inserted in the metatable of table1.
>
> I tried this with a simple csv file and it reduced already by typing!
>
> I think this could help to improve the usability.
>
> Thanks,
> Timmie

working on something like that.

Tim Michelsen

unread,
Apr 21, 2009, 6:28:59 PM4/21/09
to web...@googlegroups.com
>>> db.define_table('table1',SQLField('name',label='Name'))
>> But in the output table I still get:
>> table1.id table1.name.
I am talking of the representation in view / html output.

But the second header should be at least:
ID Name ...

As written in
http://groups.google.com/group/web2py/browse_thread/thread/c1d1f512c49ecf1e/14096d9146941f32?lnk=gst&q=SQLTABLE#14096d9146941f32

> header should read the predefined label as well as
SQLFORM
[...]
> I agree. In 1.56.
But I cannot see this having an effect.
I am running a bzr branch from last week.


Please clarify or post an example.

> working on something like that.

Great!

Thanks,
Timmie


Reply all
Reply to author
Forward
0 new messages