1 | File fields exporter and importer sections |
---|
2 | ========================================== |
---|
3 | |
---|
4 | File fields importer and exporter sections are used to extract data from |
---|
5 | Archetypes file fields. The exporter section blueprint name is |
---|
6 | ``quintagroup.transmogrifier.fileexporter`` and the importer section blueprint |
---|
7 | name is ``quintagroup.transmogrifier.fileimporter``. |
---|
8 | |
---|
9 | Exporter needs relative path to the object, that have file fields. Improter |
---|
10 | needs path and data for updating fields. |
---|
11 | |
---|
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. Exporter section also has ``exclude-key`` |
---|
15 | option, that specifies key where list of file field names will be stored |
---|
16 | (default is ``_excluded_fields``). These list will be used in marshaller |
---|
17 | section. |
---|
18 | |
---|
19 | >>> import pprint |
---|
20 | >>> binary = """ |
---|
21 | ... [transmogrifier] |
---|
22 | ... pipeline = |
---|
23 | ... binarysource |
---|
24 | ... fileexporter |
---|
25 | ... fileimporter |
---|
26 | ... printer |
---|
27 | ... dataprinter |
---|
28 | ... |
---|
29 | ... [binarysource] |
---|
30 | ... blueprint = quintagroup.transmogrifier.tests.binarysource |
---|
31 | ... |
---|
32 | ... [fileexporter] |
---|
33 | ... blueprint = quintagroup.transmogrifier.fileexporter |
---|
34 | ... |
---|
35 | ... [dataprinter] |
---|
36 | ... blueprint = quintagroup.transmogrifier.tests.dataprinter |
---|
37 | ... print = |
---|
38 | ... _files |
---|
39 | ... file-fields |
---|
40 | ... data |
---|
41 | ... |
---|
42 | ... [fileimporter] |
---|
43 | ... blueprint = quintagroup.transmogrifier.fileimporter |
---|
44 | ... |
---|
45 | ... [printer] |
---|
46 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
47 | ... """ |
---|
48 | >>> registerConfig(u'quintagroup.transmogrifier.tests.binary', binary) |
---|
49 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.binary') # doctest: +REPORT_NDIFF, +ELLIPSIS |
---|
50 | {} |
---|
51 | {'_path': 'not/existing/bar'} |
---|
52 | {'_path': 'spam/eggs/notatcontent'} |
---|
53 | {'_excluded_fields': ['image', 'file'], |
---|
54 | '_files': {'archive.tar.gz': {'content_type': 'application/x-tar', |
---|
55 | 'data': 'binary data', |
---|
56 | 'name': 'archive.tar.gz'}, |
---|
57 | 'file-fields': {'data': ..., |
---|
58 | 'name': '.file-fields.xml'}}, |
---|
59 | '_path': 'spam/eggs/foo'} |
---|
60 | <?xml version="1.0" ?> |
---|
61 | <manifest> |
---|
62 | <field name="file"> |
---|
63 | <filename>archive.tar.gz</filename> |
---|
64 | <mimetype>application/x-tar</mimetype> |
---|
65 | </field> |
---|
66 | </manifest> |
---|
67 | <BLANKLINE> |
---|
68 | >>> pprint.pprint(plone.updated) |
---|
69 | ('archive.tar.gz', 'application/x-tar', 'binary data') |
---|
70 | |
---|
71 | TODO: write test for getting data for fields from import context |
---|