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

Last change on this file since 1589 was 283, checked in by fenix, 18 years ago

removed as unworkable

File size: 2.6 KB
Line 
1Properties exporter and importer sections
2=========================================
3
4Properties exporter and importer sections are used to migrate properties for
5objects that inherit from OFS.PropertyManager.PropertyManager mixin class.
6The properties exporter section blueprint name is
7``quintagroup.transmogrifier.propertiesexporter`` and importer section blueprint
8name is ``quintagroup.transmogrifier.propertiesimporter``.
9
10Properties are represented in XML format and this is done with help of
11GenericSetup.utils.PropertyManagerHelpers class. Both sections need relative
12path to the object with properties and importer also needs XML data for updating
13properties.
14
15Both sections has ``path-key`` option which specifies key in item where path to
16object is stored (``_path`` is default) and ``files-key`` option that gives
17key where XML data will be or is stored. Exporter section also has ``exclude``
18option 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
21these 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')
Note: See TracBrowser for help on using the repository browser.