source: products/quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/marshall.txt @ 1589

Last change on this file since 1589 was 706, checked in by mylan, 17 years ago

Create 0.2 version tag.

File size: 2.6 KB
Line 
1Marshaller and demarshaller sections
2====================================
3
4Marshaller and demarshaller sections are used to serialize content in XML data
5of update it from it with the help of Marshall 1.0.0 Plone product. The
6marshaller section blueprint name is ``quintagroup.transmogrifier.marshaller``
7and the demarshaller section blueprint name is
8``quintagroup.transmogrifier.demarshaller``.
9
10Marshaller needs relative path to the object to serialize in XML format.
11Demarshaller needs path and XML data for updating object. Both sections use
12Marshall products internals and serialize/deserialize content with the use of
13``atxml`` component (this is not Zope 3 component, Marshall calls it's handlers
14components).
15
16Both sections has ``path-key`` option which specify key in item where path to
17object is stored (``_path`` is default) and ``files-key`` option that gives
18key where XML data will be or is stored. Marshaller section also has ``exclude``
19option 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
22excluded.
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
65True
66>>> plone.reindexed
67True
68>>> plone.fields['effectiveDate']
69'changed'
70>>> plone.criterion.fields['effectiveDate']
71'not changed'
Note: See TracBrowser for help on using the repository browser.