[7419] | 1 | ## $Id: configuration.py 17788 2024-05-15 07:00:39Z 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 | ## |
---|
[6923] | 18 | """ |
---|
| 19 | Containers for session configuration objects. |
---|
| 20 | """ |
---|
| 21 | import grok |
---|
| 22 | from zope.interface import implementedBy |
---|
[17780] | 23 | from waeup.kofa.utils.helpers import attrs_to_fields, iface_names |
---|
| 24 | from waeup.uniben.interfaces import ( |
---|
| 25 | ICustomSessionConfiguration, ICustomSessionConfigurationAdd) |
---|
[7822] | 26 | from waeup.kofa.configuration import ( |
---|
[17780] | 27 | SessionConfigurationFactory, SessionConfiguration, |
---|
[17788] | 28 | SessionConfigurationProcessor, SessionConfigurationExporter) |
---|
[8020] | 29 | from waeup.uniben.interfaces import ( |
---|
[8204] | 30 | ICustomSessionConfiguration, ICustomSessionConfigurationAdd) |
---|
[6923] | 31 | |
---|
| 32 | |
---|
[8204] | 33 | class CustomSessionConfiguration(SessionConfiguration): |
---|
[6923] | 34 | """ |
---|
| 35 | Customized session configuration model |
---|
| 36 | """ |
---|
| 37 | |
---|
[8204] | 38 | grok.implements(ICustomSessionConfiguration, ICustomSessionConfigurationAdd) |
---|
[6923] | 39 | |
---|
[8204] | 40 | CustomSessionConfiguration = attrs_to_fields(CustomSessionConfiguration) |
---|
[6923] | 41 | |
---|
[8204] | 42 | class CustomSessionConfigurationFactory(SessionConfigurationFactory): |
---|
[6923] | 43 | """A customized factory for session configuration objects. |
---|
| 44 | """ |
---|
| 45 | |
---|
| 46 | def __call__(self, *args, **kw): |
---|
[8204] | 47 | return CustomSessionConfiguration(*args, **kw) |
---|
[6923] | 48 | |
---|
| 49 | def getInterfaces(self): |
---|
[17780] | 50 | return implementedBy(CustomSessionConfiguration) |
---|
| 51 | |
---|
[17788] | 52 | class CustomSessionConfigurationExporter(SessionConfigurationExporter): |
---|
[17780] | 53 | """The Configuration Exporter exports all configuration data. It iterates over all |
---|
| 54 | objects of the ``configuration`` container. |
---|
| 55 | """ |
---|
| 56 | fields = tuple(sorted(iface_names(ICustomSessionConfiguration))) |
---|
| 57 | |
---|
[17788] | 58 | class CustomSessionConfigurationProcessor(SessionConfigurationProcessor): |
---|
[17780] | 59 | """The Configuration Processor processes session configuration objects in |
---|
| 60 | the ``configuration`` container. |
---|
| 61 | |
---|
| 62 | """ |
---|
| 63 | iface = ICustomSessionConfiguration |
---|