Just to let you know the patch I'm currently using:

=== modified file 'web2py/gluon/contrib/gql.py'
--- web2py/gluon/contrib/gql.py 2009-06-15 20:35:28 +0000
+++ web2py/gluon/contrib/gql.py 2009-06-21 20:44:14 +0000
@@ -796,6 +796,8 @@
         self.hooks = True
         self.compact = True

+        self.labels = dict([(c, db[c.split('.')[0]][c.split('.')
[1]].label) for c in colnames])
+
     def __getitem__(self, i):
         if i >= len(self.response) or i < 0:
             raise SyntaxError, 'SQLRows: no such row'

=== modified file 'web2py/gluon/sql.py'
--- web2py/gluon/sql.py 2009-06-23 18:52:10 +0000
+++ web2py/gluon/sql.py 2009-06-28 04:25:21 +0000
@@ -2238,6 +2238,9 @@
         self.response = response
         self.hooks = True
         self.compact = True
+
+        self.labels = dict([(c, db[c.split('.')[0]][c.split('.')
[1]].label) for c in colnames])
+

     def __nonzero__(self):
         if len(self.response):

=== modified file 'web2py/gluon/sqlhtml.py'
--- web2py/gluon/sqlhtml.py     2009-06-27 05:40:49 +0000
+++ web2py/gluon/sqlhtml.py     2009-06-28 04:25:21 +0000
@@ -864,6 +864,7 @@
         orderby=None,
         headers={},
         truncate=16,
+        fieldheaders=True,
         **attributes
         ):

@@ -872,6 +873,14 @@
         self.attributes = attributes
         self.sqlrows = sqlrows
         (components, row) = (self.components, [])
+
+        if fieldheaders:
+            labels = {}
+            labels.update(sqlrows.labels)
+            labels.update(headers)
+            headers = labels
+
+        # header
         if not orderby:
             for c in sqlrows.colnames:
                 row.append(TH(headers.get(c, c)))
@@ -880,6 +889,8 @@
                 row.append(TH(A(headers.get(c, c), _href='?orderby='
                             + c)))
         components.append(THEAD(TR(*row)))
+
+        # body
         tbody = []
         for (rc, record) in enumerate(sqlrows):
             row = []



On 31 mei, 18:12, Hans Donner <hans.don...@pobox.com> wrote:
> Ok, not yet encountered that but I can imagine it. Needs a bit of work
> than and I keep it for my own projects than for now.
>
>
>
> On Sun, May 31, 2009 at 5:50 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > this would break the dal because table headers can be aggregates and
> > are not necessarily table fields. That is why it is not done by
> > default.
>
> > On May 31, 3:49 am, HansD <hans.don...@pobox.com> wrote:
> >> currently when having
> >> {{=records}}
> >> in your view, it prints out a table with the records, the table
> >> headers being the 'ugly' field names (prefixed with the table).
>
> >> The following patch will make use of the labels supplied on the
> >> db.define(...)
>
> >> I've not yet tested this for GAE.

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