1 | Marshaller and demarshaller sections |
---|
2 | ==================================== |
---|
3 | |
---|
4 | Marshaller and demarshaller sections are used to serialize content in XML data |
---|
5 | of update it from it with the help of Marshall 1.0.0 Plone product. The |
---|
6 | marshaller section blueprint name is ``quintagroup.transmogrifier.marshaller`` |
---|
7 | and the demarshaller section blueprint name is |
---|
8 | ``quintagroup.transmogrifier.demarshaller``. |
---|
9 | |
---|
10 | Marshaller needs relative path to the object to serialize in XML format. |
---|
11 | Demarshaller needs path and XML data for updating object. Both sections use |
---|
12 | Marshall products internals and serialize/deserialize content with the use of |
---|
13 | ``atxml`` component (this is not Zope 3 component, Marshall calls it's handlers |
---|
14 | components). |
---|
15 | |
---|
16 | Both sections has ``path-key`` option which specify key in item where path to |
---|
17 | object is stored (``_path`` is default) and ``files-key`` option that gives |
---|
18 | key where XML data will be or is stored. Marshaller section also has ``exclude`` |
---|
19 | option that give global list of Archetypes fields to exclude on serializing and |
---|
20 | ``exclude-key`` option, that specifies key where same list per item is stored |
---|
21 | (default is ``_excluded_fields``). Fields that are in any of these lists are |
---|
22 | excluded. |
---|
23 | |
---|
24 | >>> import pprint |
---|
25 | >>> marshall = """ |
---|
26 | ... [transmogrifier] |
---|
27 | ... pipeline = |
---|
28 | ... marshallsource |
---|
29 | ... marshall |
---|
30 | ... demarshaller |
---|
31 | ... printer |
---|
32 | ... |
---|
33 | ... [marshallsource] |
---|
34 | ... blueprint = quintagroup.transmogrifier.tests.marshallsource |
---|
35 | ... |
---|
36 | ... [marshall] |
---|
37 | ... blueprint = quintagroup.transmogrifier.marshaller |
---|
38 | ... exclude = |
---|
39 | ... text |
---|
40 | ... |
---|
41 | ... [demarshaller] |
---|
42 | ... blueprint = quintagroup.transmogrifier.demarshaller |
---|
43 | ... |
---|
44 | ... [printer] |
---|
45 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
46 | ... """ |
---|
47 | >>> registerConfig(u'quintagroup.transmogrifier.tests.marshall', marshall) |
---|
48 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.marshall') # doctest: +REPORT_NDIFF |
---|
49 | {} |
---|
50 | {'_excluded_fields': ('file', 'image'), |
---|
51 | '_files': {'marshall': {'data': 'marshalled', 'name': '.marshall.xml'}}, |
---|
52 | '_path': 'spam/eggs/foo'} |
---|
53 | {'_files': {'marshall': {'data': None, 'name': '.marshall.xml'}}, |
---|
54 | '_path': 'topic/criterion'} |
---|
55 | {'_path': 'not/existing/bar'} |
---|
56 | {'_files': {'marshall': {'data': 'xml', 'name': '.marshall.xml'}}, |
---|
57 | '_path': 'spam/eggs/notatcontent'} |
---|
58 | >>> pprint.pprint(plone.marshalled) |
---|
59 | (('spam/eggs/foo', ('text', 'image', 'file')), ('topic/criterion', ('text',))) |
---|
60 | >>> pprint.pprint(plone.demarshalled) |
---|
61 | ('spam/eggs/foo', 'topic/criterion') |
---|
62 | >>> pprint.pprint(plone.indexed+plone.criterion.indexed) |
---|
63 | ('spam/eggs/foo', 'topic/criterion') |
---|
64 | >>> plone.updatedRoles |
---|
65 | True |
---|
66 | >>> plone.reindexed |
---|
67 | True |
---|
68 | >>> plone.fields['effectiveDate'] |
---|
69 | 'changed' |
---|
70 | >>> plone.criterion.fields['effectiveDate'] |
---|
71 | 'not changed' |
---|