1 | Portlets exporter and importer sections |
---|
2 | ======================================= |
---|
3 | |
---|
4 | Portlets exporter and importer sections are used to migrate Plone 3 contextual |
---|
5 | portlet assignments and blacklist settings. |
---|
6 | The portlets exporter section blueprint name is |
---|
7 | ``quintagroup.transmogrifier.portletsexporter`` and importer section blueprint |
---|
8 | name is ``quintagroup.transmogrifier.portletsimporter``. |
---|
9 | |
---|
10 | Portlet assignments and blacklists are stored in XML format. Both sections need |
---|
11 | relative path to the object with portlets assigned and importer also needs XML |
---|
12 | data for updating them. |
---|
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. |
---|
17 | |
---|
18 | >>> import pprint |
---|
19 | >>> portlets = """ |
---|
20 | ... [transmogrifier] |
---|
21 | ... pipeline = |
---|
22 | ... portletssource |
---|
23 | ... portletsexporter |
---|
24 | ... printer |
---|
25 | ... dataprinter |
---|
26 | ... portletsimporter |
---|
27 | ... |
---|
28 | ... [portletssource] |
---|
29 | ... blueprint = quintagroup.transmogrifier.tests.portletssource |
---|
30 | ... |
---|
31 | ... [portletsexporter] |
---|
32 | ... blueprint = quintagroup.transmogrifier.portletsexporter |
---|
33 | ... |
---|
34 | ... [printer] |
---|
35 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
36 | ... |
---|
37 | ... [dataprinter] |
---|
38 | ... blueprint = quintagroup.transmogrifier.tests.dataprinter |
---|
39 | ... print = |
---|
40 | ... _files |
---|
41 | ... portlets |
---|
42 | ... data |
---|
43 | ... |
---|
44 | ... [portletsimporter] |
---|
45 | ... blueprint = quintagroup.transmogrifier.portletsimporter |
---|
46 | ... files-key = files |
---|
47 | ... """ |
---|
48 | >>> registerConfig(u'quintagroup.transmogrifier.tests.portlets', portlets) |
---|
49 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.portlets') # doctest: +ELLIPSIS, +REPORT_NDIFF |
---|
50 | {} |
---|
51 | {'_path': 'not/existing/bar'} |
---|
52 | {'_path': 'spam/eggs/notassignable'} |
---|
53 | {'_files': {'portlets': {'data': ... |
---|
54 | 'name': '.portlets.xml'}}, |
---|
55 | '_path': 'assignable'} |
---|
56 | <?xml version="1.0" encoding="utf-8"?> |
---|
57 | <portlets> |
---|
58 | <assignment category="context" key="/assignable" manager="plone.leftcolumn" name="rss" type="portlets.rss"> |
---|
59 | <property name="count"> |
---|
60 | 10 |
---|
61 | </property> |
---|
62 | <property name="url"> |
---|
63 | http://sumno.com/feeds/main-page/ |
---|
64 | </property> |
---|
65 | <property name="portlet_title"> |
---|
66 | RSS feed |
---|
67 | </property> |
---|
68 | <property name="timeout"> |
---|
69 | 60 |
---|
70 | </property> |
---|
71 | </assignment> |
---|
72 | </portlets> |
---|
73 | <BLANKLINE> |
---|
74 | {'_files': {'portlets': {'data': ... |
---|
75 | 'name': '.portlets.xml'}}, |
---|
76 | '_path': 'other-assignable', |
---|
77 | 'files': {'portlets': {'data': ... |
---|
78 | 'name': '.portlets.xml'}}} |
---|
79 | <?xml version="1.0" encoding="utf-8"?> |
---|
80 | <portlets> |
---|
81 | <assignment category="context" key="/other-assignable" manager="plone.leftcolumn" name="rss" type="portlets.rss"> |
---|
82 | <property name="count"> |
---|
83 | 10 |
---|
84 | </property> |
---|
85 | <property name="url"> |
---|
86 | http://sumno.com/feeds/main-page/ |
---|
87 | </property> |
---|
88 | <property name="portlet_title"> |
---|
89 | RSS feed |
---|
90 | </property> |
---|
91 | <property name="timeout"> |
---|
92 | 60 |
---|
93 | </property> |
---|
94 | </assignment> |
---|
95 | </portlets> |
---|
96 | <BLANKLINE> |
---|
97 | |
---|
98 | >>> 'habra-rss' in mapping |
---|
99 | True |
---|
100 | >>> mapping['habra-rss'].count |
---|
101 | 20 |
---|
102 | >>> mapping['habra-rss'].url |
---|
103 | u'http://habrahabr.ru/rss/' |
---|
104 | >>> mapping['habra-rss'].portlet_title |
---|
105 | u'Habrahabr RSS feed' |
---|
106 | >>> mapping['habra-rss'].timeout |
---|
107 | 120 |
---|