1 | Interfaces exporter and importer sections |
---|
2 | ========================================= |
---|
3 | |
---|
4 | Interfaces exporter and importer sections are used to migrate interfaces for |
---|
5 | objects. |
---|
6 | The interfaces exporter section blueprint name is |
---|
7 | ``quintagroup.transmogrifier.interfacesexporter`` and importer section blueprint |
---|
8 | name is ``quintagroup.transmogrifier.interfacesimporter``. |
---|
9 | |
---|
10 | Interfaces are represented in XML format. Both sections need relative |
---|
11 | path to the object with interfaces and importer also needs XML data for updating |
---|
12 | interfaces provided by object. |
---|
13 | |
---|
14 | Both sections has ``path-key`` option which specifies key in item where path to |
---|
15 | object is stored (``_path`` is default) and ``files-key`` option that gives |
---|
16 | key where XML data will be or is stored. Also there are ``include`` and |
---|
17 | ``exclude`` options that give global list of interface identifiers to include or |
---|
18 | exclude on serializing. There are correspondent ``include-key``, ``exclude-key`` |
---|
19 | options, that specifies key where same lists per item is stored (default is |
---|
20 | ``_included_interfaces`` & ``_excluded_interfaces``). These options give you |
---|
21 | alternative way to manage interfaces to serialize and apply to the object. |
---|
22 | ``include`` option - include only interfaces, listed in, and ``exclude`` option |
---|
23 | behave in opposite way. If both options present - only ``include`` option get |
---|
24 | into consideration. If both options is absent - all interfaces will be |
---|
25 | serialized and/or migrated. |
---|
26 | |
---|
27 | |
---|
28 | >>> import pprint |
---|
29 | >>> interfacemanager = """ |
---|
30 | ... [transmogrifier] |
---|
31 | ... pipeline = |
---|
32 | ... interfacemanagersource |
---|
33 | ... interfacesexporter |
---|
34 | ... printer |
---|
35 | ... dataprinter |
---|
36 | ... interfacesimporter |
---|
37 | ... |
---|
38 | ... [interfacemanagersource] |
---|
39 | ... blueprint = quintagroup.transmogrifier.tests.interfacemanagersource |
---|
40 | ... |
---|
41 | ... [interfacesexporter] |
---|
42 | ... blueprint = quintagroup.transmogrifier.interfacesexporter |
---|
43 | ... |
---|
44 | ... [printer] |
---|
45 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
46 | ... |
---|
47 | ... [dataprinter] |
---|
48 | ... blueprint = quintagroup.transmogrifier.tests.dataprinter |
---|
49 | ... print = |
---|
50 | ... _files |
---|
51 | ... interfaces |
---|
52 | ... data |
---|
53 | ... |
---|
54 | ... [interfacesimporter] |
---|
55 | ... blueprint = quintagroup.transmogrifier.interfacesimporter |
---|
56 | ... include = |
---|
57 | ... zope.annotation.interfaces.IAttributeAnnotatable |
---|
58 | ... """ |
---|
59 | >>> registerConfig(u'quintagroup.transmogrifier.tests.interfacemanager', interfacemanager) |
---|
60 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.interfacemanager') # doctest: +ELLIPSIS, +REPORT_NDIFF |
---|
61 | {} |
---|
62 | {'_path': 'not/existing/bar'} |
---|
63 | {'_path': 'spam/eggs/notatcontent'} |
---|
64 | {'_files': {'interfaces': {'data': ... |
---|
65 | 'name': '.interfaces.xml'}}, |
---|
66 | '_path': 'spam/eggs/foo'} |
---|
67 | <?xml version="1.0" encoding="utf-8"?> |
---|
68 | <interfaces> |
---|
69 | <record> |
---|
70 | zope.annotation.interfaces.IAttributeAnnotatable |
---|
71 | </record> |
---|
72 | <record> |
---|
73 | Products.Archetypes.interfaces._base.IBaseObject |
---|
74 | </record> |
---|
75 | </interfaces> |
---|
76 | <BLANKLINE> |
---|
77 | |
---|
78 | >>> pprint.pprint(updated) |
---|
79 | ['zope.annotation.interfaces.IAttributeAnnotatable'] |
---|