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

Last change on this file since 1589 was 1539, checked in by mylan, 14 years ago

Restrict export interfaces by object to directly provided only

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