Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #354 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH] custom properties of sql_class cannot be displayed in DataGrid

Reported by: ksenia Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TurboGears Version:
Severity: normal Keywords: datagrid
Cc:

Description

When displaying column headers, DataGrid searches sourceClass.sqlmeta.columns dictionary for column names and therefor throws an error when one of the columns is a custom property ( http://sqlobject.org/SQLObject.html#adding-magic-attributes-properties)

Attachments

datagrid_custom_properties.patch Download (772 bytes) - added by ksenia 13 years ago.
PATCH

Change History

Changed 13 years ago by ksenia

PATCH

comment:1 Changed 13 years ago by michele

  • Summary changed from custom properties of sql_class cannot be displayed in DataGrid to [PATCH] custom properties of sql_class cannot be displayed in DataGrid

comment:2 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

this was committed in [562] as part of the related join ticket.

comment:3 Changed 13 years ago by ksenia

  • Status changed from closed to reopened
  • Resolution fixed deleted

When the new version of DataGrid is used in a old-fashioned way, with column names in fields list, custom properties or foreign keys are not recognized.

Index: turbogears/fastdata/datawidgets.py
===================================================================
--- turbogears/fastdata/datawidgets.py  (revision 569)
+++ turbogears/fastdata/datawidgets.py  (working copy)
@@ -66,8 +66,14 @@
             def f(col):
                 if not isinstance(col, tuple): # backward compatibility
                     name = col # assume col is just a name of the column
-                    column = columns_meta[name] # get columns' metadata
-                    header = column.title or column.name.capitalize()
+                    if columns_meta.has_key(name):
+                        column = columns_meta[name] # get columns' metadata
+                        header = column.title or column.name.capitalize()
+                    elif columns_meta.has_key(name + 'ID'): # key column
+                        column = columns_meta[name + 'ID']
+                        header = column.title or column.name[:-2].capitalize()
+                    else:
+                        header = name # assume col is a property
                     col = (header, name) # assemble a tuple
                 return col
             collist_raw = [f(col) for col in collist_raw]

comment:4 Changed 13 years ago by Max <ischenko@…>

  • Status changed from reopened to closed
  • Resolution set to fixed

Merged as of r570.

Note: See TracTickets for help on using tickets.