Added checks in BaseTable data attributes lambda functions to handle contents without a name
authorThierry Florac <thierry.florac@onf.fr>
Wed, 04 Mar 2015 14:09:12 +0100
changeset 29 cb1e1855f1aa
parent 28 460e9a649bd0
child 30 a4a95e733cac
Added checks in BaseTable data attributes lambda functions to handle contents without a name
src/pyams_skin/table.py
--- a/src/pyams_skin/table.py	Wed Mar 04 14:08:18 2015 +0100
+++ b/src/pyams_skin/table.py	Wed Mar 04 14:09:12 2015 +0100
@@ -65,9 +65,9 @@
 
     @property
     def data_attributes(self):
-        return {'tr': {'id': lambda x: '{0}::{1}'.format(self.id, x.__name__),
-                       'data-ams-element-name': lambda x: x.__name__,
-                       'data-ams-url': lambda x: getattr(get_element_editor(self, x), 'url', ''),
+        return {'tr': {'id': lambda x: '{0}::{1}'.format(self.id, getattr(x, '__name__', '')),
+                       'data-ams-element-name': lambda x: getattr(x, '__name__', None),
+                       'data-ams-url': lambda x: getattr(get_element_editor(self, x), 'url', None),
                        'data-toggle': lambda x: 'modal' if getattr(get_element_editor(self, x), 'modal_target', None) else None}}
 
     batchSize = 10000