Changeset 159:6e130c152965
- Timestamp:
- 01/21/10 04:22:17 (7 weeks ago)
- Author:
- C?dric Krier <ced@…>
- Branch:
- default
- Message:
-
Update py:attrs attributes in opendocument
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r154
|
r159
|
|
| | 1 | * Update py:attrs attributes in opendocument |
| | 2 | |
| 1 | 3 | 0.5.3 - 20100110 |
| 2 | 4 | * Escape elements values in opendocument template |
-
|
r153
|
r159
|
|
| 186 | 186 | |
| 187 | 187 | |
| | 188 | def update_py_attrs(node, value): |
| | 189 | """An helper function to update py_attrs of a node. |
| | 190 | """ |
| | 191 | if not value: |
| | 192 | return |
| | 193 | py_attrs_attr = '{%s}attrs' % GENSHI_URI |
| | 194 | if not py_attrs_attr in node.attrib: |
| | 195 | node.attrib[py_attrs_attr] = value |
| | 196 | else: |
| | 197 | node.attrib[py_attrs_attr] = \ |
| | 198 | "(lambda x, y: x.update(y) or x)(%s or {}, %s or {})" % \ |
| | 199 | (node.attrib[py_attrs_attr], value) |
| | 200 | |
| | 201 | |
| 188 | 202 | class Template(MarkupTemplate): |
| 189 | 203 | |
| … |
… |
|
| 417 | 431 | # correct value and type for this cell. |
| 418 | 432 | dico = "{'%s': %s, '%s': __relatorio_guess_type(%s)}" |
| 419 | | parent.attrib[py_attrs_attr] = dico % (office_name, expr, |
| 420 | | office_valuetype, expr) |
| | 433 | update_py_attrs(parent, dico % |
| | 434 | (office_name, expr, office_valuetype, expr)) |
| 421 | 435 | parent.attrib.pop(office_valuetype, None) |
| 422 | 436 | parent.attrib.pop(office_name, None) |
| … |
… |
|
| 448 | 462 | # operations, but a unique id within the table is required |
| 449 | 463 | # to support nested column repetition |
| 450 | | ancestor.attrib[py_attrs_attr] = \ |
| 451 | | "__relatorio_reset_col_count(%d)" % loop_id |
| | 464 | update_py_attrs(ancestor, "__relatorio_reset_col_count(%d)" % loop_id) |
| 452 | 465 | |
| 453 | 466 | # 2) add increment code (through a py:attrs attribute) on |
| … |
… |
|
| 456 | 469 | enclosed_cell = outer_o_node.getnext() |
| 457 | 470 | assert enclosed_cell.tag == '{%s}table-cell' % table_namespace |
| 458 | | enclosed_cell.attrib[py_attrs_attr] = \ |
| 459 | | "__relatorio_inc_col_count(%d)" % loop_id |
| | 471 | update_py_attrs(enclosed_cell, "__relatorio_inc_col_count(%d)" % |
| | 472 | loop_id) |
| 460 | 473 | |
| 461 | 474 | # 3) add "store count" code as a py:replace node, as the |