[280] | 1 | Comments exporter and importer sections |
---|
| 2 | ======================================= |
---|
[275] | 3 | |
---|
[280] | 4 | Comments exporter and importer sections are used to migrate comments for site |
---|
| 5 | content. The comments exporter section blueprint name is |
---|
| 6 | ``quintagroup.transmogrifier.commentsexporter`` and importer section blueprint |
---|
| 7 | name is ``quintagroup.transmogrifier.commentsimporter``. |
---|
[275] | 8 | |
---|
[280] | 9 | Comments are represented in XML format. Both sections need relative path to the |
---|
| 10 | object with comments and importer also needs XML data for adding comments. |
---|
[275] | 11 | |
---|
[280] | 12 | Both sections has ``path-key`` option which specify key in item where path to |
---|
| 13 | object is stored (``_path`` is default) and ``files-key`` option that gives |
---|
| 14 | key where XML data will be or is stored. |
---|
[275] | 15 | |
---|
[280] | 16 | >>> import pprint |
---|
| 17 | >>> comments = """ |
---|
[275] | 18 | ... [transmogrifier] |
---|
| 19 | ... pipeline = |
---|
[280] | 20 | ... commentssource |
---|
| 21 | ... commentsexporter |
---|
[275] | 22 | ... printer |
---|
| 23 | ... dataprinter |
---|
[280] | 24 | ... commentsimporter |
---|
[275] | 25 | ... |
---|
[280] | 26 | ... [commentssource] |
---|
| 27 | ... blueprint = quintagroup.transmogrifier.tests.commentssource |
---|
[275] | 28 | ... |
---|
[280] | 29 | ... [commentsexporter] |
---|
| 30 | ... blueprint = quintagroup.transmogrifier.commentsexporter |
---|
[275] | 31 | ... |
---|
| 32 | ... [printer] |
---|
| 33 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
| 34 | ... |
---|
| 35 | ... [dataprinter] |
---|
| 36 | ... blueprint = quintagroup.transmogrifier.tests.dataprinter |
---|
| 37 | ... print = |
---|
| 38 | ... _files |
---|
[280] | 39 | ... comments |
---|
[275] | 40 | ... data |
---|
[280] | 41 | ... |
---|
| 42 | ... [commentsimporter] |
---|
| 43 | ... blueprint = quintagroup.transmogrifier.commentsimporter |
---|
[275] | 44 | ... """ |
---|
[280] | 45 | >>> registerConfig(u'quintagroup.transmogrifier.tests.comments', comments) |
---|
| 46 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.comments') # doctest: +ELLIPSIS, +REPORT_NDIFF |
---|
| 47 | {} |
---|
| 48 | {'_path': 'not/existing/bar'} |
---|
| 49 | {'_path': 'spam/eggs/notdiscussable'} |
---|
| 50 | {'_files': {'comments': {'data': ... |
---|
| 51 | 'name': '.comments.xml'}}, |
---|
[275] | 52 | '_path': 'spam/eggs/foo'} |
---|
[371] | 53 | ... |
---|
[275] | 54 | <discussion> |
---|
| 55 | <item id="1"> |
---|
| 56 | <field name="Creator"> |
---|
| 57 | creator |
---|
| 58 | </field> |
---|
| 59 | <field name="Modification_date"> |
---|
| 60 | date |
---|
| 61 | </field> |
---|
| 62 | <field name="In_reply_to"> |
---|
| 63 | None |
---|
| 64 | </field> |
---|
| 65 | <field name="Text"> |
---|
| 66 | comment to content |
---|
| 67 | </field> |
---|
| 68 | </item> |
---|
| 69 | <item id="2"> |
---|
| 70 | <field name="Creator"> |
---|
| 71 | creator |
---|
| 72 | </field> |
---|
| 73 | <field name="Modification_date"> |
---|
| 74 | date |
---|
| 75 | </field> |
---|
| 76 | <field name="In_reply_to"> |
---|
| 77 | 1 |
---|
| 78 | </field> |
---|
| 79 | <field name="Text"> |
---|
| 80 | reply to first comment |
---|
| 81 | </field> |
---|
| 82 | </item> |
---|
| 83 | <item id="3"> |
---|
| 84 | <field name="Creator"> |
---|
| 85 | creator |
---|
| 86 | </field> |
---|
| 87 | <field name="Modification_date"> |
---|
| 88 | date |
---|
| 89 | </field> |
---|
| 90 | <field name="In_reply_to"> |
---|
| 91 | None |
---|
| 92 | </field> |
---|
| 93 | <field name="Text"> |
---|
| 94 | other comment to content |
---|
| 95 | </field> |
---|
| 96 | </item> |
---|
| 97 | </discussion> |
---|
| 98 | <BLANKLINE> |
---|
[280] | 99 | >>> pprint.pprint(plone._container) |
---|
| 100 | {'1': <DicussionItem creator date None comment to content>, |
---|
| 101 | '2': <DicussionItem creator date 1 reply to first comment>, |
---|
| 102 | '3': <DicussionItem creator date None other comment to content>} |
---|