1 | Catalog source section |
---|
2 | ====================== |
---|
3 | |
---|
4 | This is a source section that returns items queried from catalog. The catalog |
---|
5 | source section blueprint name is ``quintagroup.transmogrifier.catalogsource``. |
---|
6 | |
---|
7 | Catalog source section has next options: |
---|
8 | - ``path-key' (default ``_path``) - key where object path is stored |
---|
9 | - ``entries-key`` (default ``_entries``) - key where data for manifest section |
---|
10 | is stored (tuple of contained items) |
---|
11 | |
---|
12 | All other options are assumed to be catalog query parameters, option name |
---|
13 | corresponds to index and its value is value for search or string representation |
---|
14 | of record object. Record object is a dictionary, which items are separeted by |
---|
15 | ``;`` and key is separeted from value with ``=``. |
---|
16 | |
---|
17 | Test parsing os catalog query, which is given in section options (here we |
---|
18 | manually initialize section with that query). |
---|
19 | |
---|
20 | >>> from pprint import pprint |
---|
21 | >>> from quintagroup.transmogrifier.catalogsource import CatalogSourceSection |
---|
22 | >>> options = {'modified': 'query = 2008/11/02 12:00:00 GMT+0 ; range = min', |
---|
23 | ... 'Type': 'Document', |
---|
24 | ... 'blueprint': 'quintagroup.transmogrifier.catalogsource'} |
---|
25 | >>> section = CatalogSourceSection(transmogrifier, 'catalogsource', options, object()) |
---|
26 | >>> pprint(section.query) |
---|
27 | {'Type': 'Document', |
---|
28 | 'modified': {'query': '2008/11/02 12:00:00 GMT+0', 'range': 'min'}} |
---|
29 | |
---|
30 | Now test functionality of this section. |
---|
31 | |
---|
32 | >>> catalogsource = """ |
---|
33 | ... [transmogrifier] |
---|
34 | ... pipeline = |
---|
35 | ... catalogsource |
---|
36 | ... printer |
---|
37 | ... |
---|
38 | ... [catalogsource] |
---|
39 | ... blueprint = quintagroup.transmogrifier.catalogsource |
---|
40 | ... modified = query = 2008-11-02T12:00:00Z; range = min |
---|
41 | ... |
---|
42 | ... [printer] |
---|
43 | ... blueprint = collective.transmogrifier.sections.tests.pprinter |
---|
44 | ... """ |
---|
45 | >>> registerConfig(u'quintagroup.transmogrifier.tests.catalogsource', |
---|
46 | ... catalogsource) |
---|
47 | >>> transmogrifier(u'quintagroup.transmogrifier.tests.catalogsource') #doctest: +REPORT_NDIFF |
---|
48 | {'_entries': (('folder2', 'Folder'), ('folder1', 'Folder')), '_path': ''} |
---|
49 | {'_entries': (('document2', 'Document'), ('document3', 'Document')), |
---|
50 | '_path': 'folder1'} |
---|
51 | {'_path': 'folder1/document2'} |
---|
52 | {'_path': 'folder1/document3'} |
---|
53 | {'_entries': (('document4', 'Document'),), '_path': 'folder2'} |
---|
54 | {'_path': 'folder2/document4'} |
---|