forked from eea/eea.facetednavigation
-
Notifications
You must be signed in to change notification settings - Fork 22
/
faceted.py
35 lines (31 loc) · 1.21 KB
/
faceted.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
""" Faceted
"""
import logging
from zope.component import queryMultiAdapter
from Products.GenericSetup.interfaces import IBody
from Products.GenericSetup.utils import XMLAdapterBase
from eea.facetednavigation.interfaces import IFacetedNavigable
from eea.facetednavigation.interfaces import ICriteria
logger = logging.getLogger('eea.facetednavigation.exportimport.faceted')
class FacetedNavigableXMLAdapter(XMLAdapterBase):
""" GenericSetup XML Adapter for faceted navigable context
"""
__used_for__ = IFacetedNavigable
def _exportNode(self):
"""Export the object as a DOM node.
"""
node = self._getObjectNode('object')
criteria = ICriteria(self.context)
exporter = queryMultiAdapter((criteria, self.environ), IBody)
node.appendChild(exporter.node)
return node
def _importNode(self, node):
"""Import the object from the DOM node.
"""
criteria = ICriteria(self.context)
for child in node.childNodes:
if child.nodeName != 'criteria':
continue
importer = queryMultiAdapter((criteria, self.environ), IBody)
importer.node = child
node = property(_exportNode, _importNode)