source: products/quintagroup.transmogrifier/branches/plone-2.1/quintagroup.transmogrifier/quintagroup/transmogrifier/binary.txt @ 1413

Last change on this file since 1413 was 461, checked in by piv, 18 years ago

updated version.txt

File size: 2.4 KB
Line 
1File fields exporter and importer sections
2==========================================
3
4File fields importer and exporter sections are used to extract data from
5Archetypes file fields. The exporter section blueprint name is
6``quintagroup.transmogrifier.fileexporter`` and the importer section blueprint
7name is ``quintagroup.transmogrifier.fileimporter``.
8
9Exporter needs relative path to the object, that have file fields. Improter
10needs path and data for updating fields.
11
12Both sections has ``path-key`` option which specify key in item where path to
13object is stored (``_path`` is default) and ``files-key`` option that gives
14key where XML data will be or is stored. Exporter section also has ``exclude-key``
15option, that specifies key where list of file field names will be stored
16(default is ``_excluded_fields``). These list will be used in marshaller
17section.
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
71TODO: write test for getting data for fields from import context
Note: See TracBrowser for help on using the repository browser.