equal
deleted
inserted
replaced
63 |
63 |
64 from cubicweb import _ |
64 from cubicweb import _ |
65 |
65 |
66 from copy import copy |
66 from copy import copy |
67 from types import MethodType |
67 from types import MethodType |
68 |
|
69 from six import string_types, add_metaclass, create_bound_method |
|
70 from six.moves import range |
|
71 |
68 |
72 from logilab.mtconverter import xml_escape |
69 from logilab.mtconverter import xml_escape |
73 from logilab.common.decorators import cachedproperty |
70 from logilab.common.decorators import cachedproperty |
74 from logilab.common.deprecation import class_deprecated |
71 from logilab.common.deprecation import class_deprecated |
75 from logilab.common.registry import yes |
72 from logilab.common.registry import yes |
284 |
281 |
285 def cell_attributes(self, rownum, _colnum, renderer): |
282 def cell_attributes(self, rownum, _colnum, renderer): |
286 attrs = renderer.attributes.copy() |
283 attrs = renderer.attributes.copy() |
287 if renderer.sortable: |
284 if renderer.sortable: |
288 sortvalue = renderer.sortvalue(rownum) |
285 sortvalue = renderer.sortvalue(rownum) |
289 if isinstance(sortvalue, string_types): |
286 if isinstance(sortvalue, str): |
290 sortvalue = sortvalue[:self.sortvalue_limit] |
287 sortvalue = sortvalue[:self.sortvalue_limit] |
291 if sortvalue is not None: |
288 if sortvalue is not None: |
292 attrs[u'cubicweb:sortvalue'] = js_dumps(sortvalue) |
289 attrs[u'cubicweb:sortvalue'] = js_dumps(sortvalue) |
293 return attrs |
290 return attrs |
294 |
291 |
715 try: |
712 try: |
716 acopy = copy(self) |
713 acopy = copy(self) |
717 for aname, member in[('renderfunc', renderfunc), |
714 for aname, member in[('renderfunc', renderfunc), |
718 ('sortfunc', sortfunc)]: |
715 ('sortfunc', sortfunc)]: |
719 if isinstance(member, MethodType): |
716 if isinstance(member, MethodType): |
720 member = create_bound_method(member.__func__, acopy) |
717 member = MethodType(member.__func__, acopy) |
721 setattr(acopy, aname, member) |
718 setattr(acopy, aname, member) |
722 return acopy |
719 return acopy |
723 finally: |
720 finally: |
724 self.renderfunc = renderfunc |
721 self.renderfunc = renderfunc |
725 self.sortfunc = sortfunc |
722 self.sortfunc = sortfunc |
910 ################################################################################ |
907 ################################################################################ |
911 # DEPRECATED tables ############################################################ |
908 # DEPRECATED tables ############################################################ |
912 ################################################################################ |
909 ################################################################################ |
913 |
910 |
914 |
911 |
915 @add_metaclass(class_deprecated) |
912 class TableView(AnyRsetView, metaclass=class_deprecated): |
916 class TableView(AnyRsetView): |
|
917 """The table view accepts any non-empty rset. It uses introspection on the |
913 """The table view accepts any non-empty rset. It uses introspection on the |
918 result set to compute column names and the proper way to display the cells. |
914 result set to compute column names and the proper way to display the cells. |
919 |
915 |
920 It is however highly configurable and accepts a wealth of options. |
916 It is however highly configurable and accepts a wealth of options. |
921 """ |
917 """ |
1176 __regid__ = 'editable-table' |
1172 __regid__ = 'editable-table' |
1177 finalview = 'editable-final' |
1173 finalview = 'editable-final' |
1178 title = _('editable-table') |
1174 title = _('editable-table') |
1179 |
1175 |
1180 |
1176 |
1181 @add_metaclass(class_deprecated) |
1177 class CellView(EntityView, metaclass=class_deprecated): |
1182 class CellView(EntityView): |
|
1183 __deprecation_warning__ = '[3.14] %(cls)s is deprecated' |
1178 __deprecation_warning__ = '[3.14] %(cls)s is deprecated' |
1184 __regid__ = 'cell' |
1179 __regid__ = 'cell' |
1185 __select__ = nonempty_rset() |
1180 __select__ = nonempty_rset() |
1186 |
1181 |
1187 def cell_call(self, row, col, cellvid=None): |
1182 def cell_call(self, row, col, cellvid=None): |