vendor/CMF/1.6.3/CMFCore

view exportimport/cookieauth.py @ 0:587011552858

import CMF 1.6.3
author bdelbosc
date Mon, 23 Apr 2007 13:58:01 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
4 #
5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10 # FOR A PARTICULAR PURPOSE.
11 #
12 ##############################################################################
13 """Cookie crumbler xml adapters and setup handlers.
15 $Id$
16 """
18 from Products.GenericSetup.utils import exportObjects
19 from Products.GenericSetup.utils import importObjects
20 from Products.GenericSetup.utils import PropertyManagerHelpers
21 from Products.GenericSetup.utils import XMLAdapterBase
23 from Products.CMFCore.interfaces import ICookieCrumbler
24 from Products.CMFCore.utils import getToolByName
27 class CookieCrumblerXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
29 """XML im- and exporter for CookieCrumbler.
30 """
32 __used_for__ = ICookieCrumbler
34 _LOGGER_ID = 'cookies'
36 name = 'cookieauth'
38 def _exportNode(self):
39 """Export the object as a DOM node.
40 """
41 node = self._getObjectNode('object')
42 node.appendChild(self._extractProperties())
44 self._logger.info('Cookie crumbler exported.')
45 return node
47 def _importNode(self, node):
48 """Import the object from the DOM node.
49 """
50 if self.environ.shouldPurge():
51 self._purgeProperties()
53 self._initProperties(node)
55 self._logger.info('Cookie crumbler imported.')
58 def importCookieCrumbler(context):
59 """Import cookie crumbler settings from an XML file.
60 """
61 site = context.getSite()
62 tool = getToolByName(site, 'cookie_authentication')
64 importObjects(tool, '', context)
66 def exportCookieCrumbler(context):
67 """Export cookie crumbler settings as an XML file.
68 """
69 site = context.getSite()
70 tool = getToolByName(site, 'cookie_authentication', None)
71 if tool is None:
72 logger = context.getLogger('cookies')
73 logger.info('Nothing to export.')
74 return
76 exportObjects(tool, '', context)