1 | ## $Id: configuration.py 17756 2024-05-10 13:49:33Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
4 | ## This program is free software; you can redistribute it and/or modify |
---|
5 | ## it under the terms of the GNU General Public License as published by |
---|
6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
7 | ## (at your option) any later version. |
---|
8 | ## |
---|
9 | ## This program is distributed in the hope that it will be useful, |
---|
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | ## GNU General Public License for more details. |
---|
13 | ## |
---|
14 | ## You should have received a copy of the GNU General Public License |
---|
15 | ## along with this program; if not, write to the Free Software |
---|
16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | ## |
---|
18 | """ |
---|
19 | Containers for session configuration objects. |
---|
20 | """ |
---|
21 | import grok |
---|
22 | from zope.interface import implementedBy |
---|
23 | from waeup.kofa.utils.helpers import attrs_to_fields, iface_names |
---|
24 | from waeup.kofa.configuration import ( |
---|
25 | SessionConfigurationFactory, SessionConfiguration, |
---|
26 | ConfigurationProcessor, ConfigurationExporter) |
---|
27 | from kofacustom.iuokada.interfaces import ( |
---|
28 | ICustomSessionConfiguration, ICustomSessionConfigurationAdd) |
---|
29 | |
---|
30 | |
---|
31 | class CustomSessionConfiguration(SessionConfiguration): |
---|
32 | """ |
---|
33 | Customized session configuration model |
---|
34 | """ |
---|
35 | |
---|
36 | grok.implements(ICustomSessionConfiguration, ICustomSessionConfigurationAdd) |
---|
37 | |
---|
38 | CustomSessionConfiguration = attrs_to_fields(CustomSessionConfiguration) |
---|
39 | |
---|
40 | class CustomSessionConfigurationFactory(SessionConfigurationFactory): |
---|
41 | """A customized factory for session configuration objects. |
---|
42 | """ |
---|
43 | |
---|
44 | def __call__(self, *args, **kw): |
---|
45 | return CustomSessionConfiguration(*args, **kw) |
---|
46 | |
---|
47 | def getInterfaces(self): |
---|
48 | return implementedBy(CustomSessionConfiguration) |
---|
49 | |
---|
50 | class CustomConfigurationExporter(ConfigurationExporter): |
---|
51 | """The Configuration Exporter exports all configuration data. It iterates over all |
---|
52 | objects of the ``configuration`` container. |
---|
53 | """ |
---|
54 | fields = tuple(sorted(iface_names(ICustomSessionConfiguration))) |
---|
55 | |
---|
56 | class CustomConfigurationProcessor(ConfigurationProcessor): |
---|
57 | """The Configuration Processor processes session configuration objects in |
---|
58 | the ``configuration`` container. |
---|
59 | |
---|
60 | """ |
---|
61 | iface = ICustomSessionConfiguration |
---|
62 | |
---|