I think instead of patching there should a repository of SQLFORMxxx.py
and SQLTABLExxx.py that you put in your models and do different things
when you need.

Massimo

On 27 Apr, 08:50, DenesL <denes1...@yahoo.ca> wrote:
> On Apr 27, 5:59 am, Timmie <timmichel...@gmx-topmail.de> wrote:
>
> > I liked this option most.
> :)
>
> > Here is the function I derived from this:
>
> > def rows_transpose(rows_obj):
> >     """transposes a rows object
>
> >     input:    a rows object selected from the data base
> >     output:   a html table of the transposed table
>
> >     This can still be improved by using the headers attribute of the
> >     SQLTABLE and a CSS alogn attribute
> >     """
>
> >     tbody=[]
> >     for col in rows_obj.colnames:
> >         fld=col.split('.')[1]
> >         r=[TH(col,_scope='row', _style="text-align : left")]
> >         for row in rows_obj:
> >             r.append(TD(row[fld]))
> >         tbody.append(TR(r))
> >     res_table=TABLE(tbody)
>
> >     return res_table
>
> > Although the numpy version was faster, this function gives more
> > control over the html output.
>
> > I would be great if such a functionality could be included in web2py!
>
> This could be in patched into SQLTABLE but I don't have the time right
> now.
>
> > I still have the following questions:
>
> > * How can I retrieve and use the default field lables set in the model
> > as colnames?
>
> h={}
> for c in rows.colnames:
>   tbl,fld=c.split('.')
>   h[c]=rows._db[tbl][fld].label
> tt=SQLTABLE(rows,headers=h)
>
> > * When I put this function in an extra module file and save this in
> > applications.myapp.helper.py
> > I get the following error:
>
> > File "applications\myapp\modules\helper.py", line 27, in
> > rows_transpose
> > r=[TH(col,_scope='row', _style="text-align : left")]
> > NameError: global name 'TH' is not defined
>
> > Why this? How can I have modules which are awar of the web2py
> > namespace in the modules folder?
> > Or shall I leave such helper functions in the default.py?
>
> In your module you have to import the helpers:
> from gluon.html import *
>
>
>
> > Regards,
> > Timmie
>
> Denes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to