1 | Properties exporter and importer sections |
---|
2 | ========================================= |
---|
3 | |
---|
4 | Properties exporter and importer sections are used to migrate properties for |
---|
5 | objects that inherit from OFS.PropertyManager.PropertyManager mixin class. |
---|
6 | The properties exporter section blueprint name is |
---|
7 | ``quintagroup.transmogrifier.propertiesexporter`` and importer section blueprint |
---|
8 | name is ``quintagroup.transmogrifier.propertiesimporter``. |
---|
9 | |
---|
10 | Properties are represented in XML format and this is done with help of |
---|
11 | GenericSetup.utils.PropertyManagerHelpers class. Both sections need relative |
---|
12 | path to the object with properties and importer also needs XML data for updating |
---|
13 | properties. |
---|
14 | |
---|
15 | Both sections has ``path-key`` option which specifies key in item where path to |
---|
16 | object is stored (``_path`` is default) and ``files-key`` option that gives |
---|
17 | key where XML data will be or is stored. Exporter section also has ``exclude`` |
---|
18 | option that give global list of property ids to exclude on serializing and |
---|
19 | ``exclude-key`` option, that specifies key where same list per item is stored |
---|
20 | (default is ``_excluded_properties``). Properties that are present in any of |
---|
21 | these lists are excluded. |
---|
22 | |
---|
23 | >>> import pprint |
---|
24 | >>> propertymanager = """ |
---|
25 | ... [transmogrifier] |
---|
26 | ... pipeline = |
---|
27 | ... propertymanagersource |
---|
28 | ... propertiesexporter |
---|
29 | ... printer |
---|
30 | ... dataprinter |
---|
31 | ... propertiesimporter |
---|
32 | ... |
---|
33 | ... [propertymanagersource] |
---|
34 | ... blueprint = quintagroup.transmogrifier.tests.propertymanagersource |
---|
35 | ... |
---|
36 | ... [propertiesexporter] |
---|
37 | ... blueprint = quintagroup.transmogrifier.propertiesexporter |
---|
38 | ... exclude = |
---|
39 | ... title |
---|
40 | ... notexistentprop |
---|
41 | ... |
---|
42 | ... [printer] |
---|
43 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
44 | ... |
---|
45 | ... [dataprinter] |
---|
46 | ... blueprint = quintagroup.transmogrifier.tests.dataprinter |
---|
47 | ... print = |
---|
48 | ... _files |
---|
49 | ... propertymanager |
---|
50 | ... data |
---|
51 | ... |
---|
52 | ... [propertiesimporter] |
---|
53 | ... blueprint = quintagroup.transmogrifier.propertiesimporter |
---|
54 | ... exclude = author |
---|
55 | ... """ |
---|
56 | >>> registerConfig(u'quintagroup.transmogrifier.tests.propertymanager', propertymanager) |
---|
57 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.propertymanager') # doctest: +ELLIPSIS, +REPORT_NDIFF |
---|
58 | {} |
---|
59 | {'_path': 'not/existing/bar'} |
---|
60 | {'_path': 'spam/eggs/notatcontent'} |
---|
61 | {'_excluded_properties': ('encoding',), |
---|
62 | '_files': {'propertymanager': {'data': ... |
---|
63 | 'name': '.properties.xml'}}, |
---|
64 | '_path': 'spam/eggs/foo'} |
---|
65 | <?xml version="1.0" encoding="utf-8"?> |
---|
66 | <properties> |
---|
67 | <property name="description"> |
---|
68 | value |
---|
69 | </property> |
---|
70 | <property name="author"> |
---|
71 | value |
---|
72 | </property> |
---|
73 | </properties> |
---|
74 | <BLANKLINE> |
---|
75 | >>> pprint.pprint(plone.updated) |
---|
76 | ('spam/eggs/foo', 'description', 'value') |
---|