Index: main/waeup.ikoba/trunk/src/waeup/ikoba/idgen.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/idgen.py	(revision 12252)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/idgen.py	(revision 12252)
@@ -0,0 +1,50 @@
+## $Id$
+##
+## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+"""ID generators.
+
+Give you unique IDs for objects.
+"""
+import grok
+import uuid
+from waeup.ikoba.interfaces import IIDSource
+
+
+class IDSource(grok.GlobalUtility):
+    """This utility provides 'Universally Unique IDentifiers'.
+
+    It is registered without name on startup. You can get an instance
+    of this utility with
+
+      >>> from zope.component import getUtility
+      >>> from waeup.ikoba.interfaces import IIDSource
+      >>> source = getUtility(IIDSource)
+
+    """
+    grok.implements(IIDSource)
+
+    @classmethod
+    def get_uuid(self):
+        """Get a UUID string of 36 hexadecimal chars and hyphens.
+        """
+        return str(uuid.uuid4())
+
+    @classmethod
+    def get_hex_uuid(self):
+        """Get a UUID string of 32 hexadecimal chars.
+        """
+        return uuid.uuid4().hex
Index: main/waeup.ikoba/trunk/src/waeup/ikoba/tests/test_idgen.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/tests/test_idgen.py	(revision 12252)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/tests/test_idgen.py	(revision 12252)
@@ -0,0 +1,48 @@
+import re
+import unittest
+from zope.component import queryUtility
+from zope.interface.verify import verifyClass, verifyObject
+from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
+from waeup.ikoba.idgen import IIDSource, IDSource
+
+
+# format of raw uuids (36 chars including 4 hyphens)
+RE_FORMAT_UUID = re.compile(
+    "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
+    )
+
+# format of hex uuids (32 chars)
+RE_FORMAT_HEX_UUID = re.compile("^[0-9a-f]{32}$")
+
+
+class IDGeneratorTests(unittest.TestCase):
+
+    def test_iface(self):
+        # we fullfill any interface contracts
+        src = IDSource()
+        verifyClass(IIDSource, IDSource)
+        verifyObject(IIDSource, src)
+
+    def test_get_uuid(self):
+        # we can get universally unique identifiers
+        src = IDSource()
+        result = src.get_uuid()
+        assert(RE_FORMAT_UUID.match(result))
+        assert src.get_uuid() != result
+
+    def test_get_hex_uuid(self):
+        # we can get UUIDs as hex strings
+        src = IDSource()
+        result = src.get_hex_uuid()
+        assert (RE_FORMAT_HEX_UUID.match(result))
+        assert src.get_hex_uuid() != result
+
+
+class FunctionalIDSourceTests(FunctionalTestCase):
+
+    layer = FunctionalLayer
+
+    def test_IIDSource_utility_registered(self):
+        # an IIDSource is registered on startup
+        util = queryUtility(IIDSource)
+        assert util is not None
