Index: /main/waeup.kofa/trunk/src/waeup/kofa/beaker.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/beaker.py	(revision 8426)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/beaker.py	(revision 8426)
@@ -0,0 +1,60 @@
+"""Configure dolmen.beaker.
+
+One main advantage of using dolmen.beaker is that session data for a
+certain user can be stored almost automatically in a cookie, thus
+reducing the number of needed ZODB operations.
+
+Security Advisory
+-----------------
+
+To prevent users from playing around with their session data, these
+data is encrypted by some keys stored in a dict registered as a global
+utility.
+
+These keys are set each time the Zope instance starts. If they change,
+all existing cookies will become unreadable and therefore the stored
+sessions will be lost. Already logged-in users will have to login
+again and all other session based operations might have to be
+restarted.
+
+Changing the keys might therefore have sideeffects.
+
+On the other hand static keys stored in SVN might become known to
+users and enable them to manipulate their session data.
+
+For better security the keys (or one of the keys) could therefore be
+gathered from 'outside' (a file in filesystem, some environment var,
+or whatever).
+"""
+import grok
+from zope.app.appsetup.interfaces import IDatabaseOpenedWithRootEvent
+from zope.component import getUtility
+
+#: Our configuration for dolmen.beaker sessions.
+#:
+#: See http://gitweb.dolmen-project.org/dolmen.beaker.git?a=blob;f=src/dolmen/beaker/utilities.py
+#:
+#: for default configuration.
+BEAKER_CONFIG = dict(
+    data_dir=None,
+    invalidate_corrupt=True,
+    key='waeup.kofa.session.id',
+    log_file=None,
+    secret="KofaRocks",
+    timeout=600,
+    type="cookie",
+    validate_key="thisMightBeChanged",
+    )
+
+@grok.subscribe(IDatabaseOpenedWithRootEvent)
+def set_beaker_conf(event):
+    # Set beaker conf once when ZODB was opened
+    try:
+        from dolmen.beaker.interfaces import ISessionConfig
+    except ImportError:
+        # we seem to work without dolmen.beaker
+        return
+
+    config = getUtility(ISessionConfig)
+    config.update(BEAKER_CONFIG)
+    return
Index: /main/waeup.kofa/trunk/src/waeup/kofa/configure.zcml
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/configure.zcml	(revision 8425)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/configure.zcml	(revision 8426)
@@ -7,6 +7,17 @@
   <include package="waeup.kofa" file="meta.zcml" />
   <includeDependencies package="." />
+
+  <!-- Comment the following line if you don't want dolmen.beaker,
+       for instance on Windows if you were not able to compile it
+
+       We have to configure dolmen.beaker manually, because it is
+       not part of installation requirements and will therefore not
+       be found by the includeDependencies directive. -->
+  <include package="dolmen.beaker" file="configure.zcml" />
   <grok:grok package="." />
+
+
   <includeOverrides package="waeup.kofa.widgets" file="overrides.zcml" />
   <includeOverrides package="waeup.kofa.utils" file="overrides.zcml" />
+
 </configure>
Index: /main/waeup.kofa/trunk/src/waeup/kofa/tests/test_beaker.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/tests/test_beaker.py	(revision 8426)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/tests/test_beaker.py	(revision 8426)
@@ -0,0 +1,22 @@
+from zope.component.hooks import setSite
+from zope.publisher.browser import TestRequest
+from zope.session.interfaces import ISession
+from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
+
+class BeakerTests(FunctionalTestCase):
+    # Beaker-related tests.
+
+    layer = FunctionalLayer
+
+    def test_beaker_session(self):
+        # Make sure we get a beaker session when asking for ISession.
+        try:
+            import dolmen.beaker
+        except ImportError:
+            # no beaker installed, no test
+            return
+        setSite(self.getRootFolder()) # needed to start transaction
+        request = TestRequest()
+        session = ISession(request)
+        self.assertTrue(session.__module__.startswith('dolmen.beaker'))
+        return
