[Checkins] SVN: z3c.dobbin/trunk/s When generating unique ids, force first character between 'a' and 'z'.

Malthe Borch mborch at gmail.com
Wed May 21 09:28:56 EDT 2008


Log message for revision 86879:
  When generating unique ids, force first character between 'a' and 'z'.

Changed:
  U   z3c.dobbin/trunk/setup.py
  U   z3c.dobbin/trunk/src/z3c/dobbin/factory.py

-=-
Modified: z3c.dobbin/trunk/setup.py
===================================================================
--- z3c.dobbin/trunk/setup.py	2008-05-21 13:09:39 UTC (rev 86878)
+++ z3c.dobbin/trunk/setup.py	2008-05-21 13:28:56 UTC (rev 86879)
@@ -15,7 +15,7 @@
 from setuptools import setup, find_packages
 
 setup(name='z3c.dobbin',
-      version='0.2.1',
+      version='0.2.2',
       license='ZPL',
       author = "Malthe Borch, Stefan Eletzhofer and the Zope Community",
       author_email = "zope-dev at zope.org",

Modified: z3c.dobbin/trunk/src/z3c/dobbin/factory.py
===================================================================
--- z3c.dobbin/trunk/src/z3c/dobbin/factory.py	2008-05-21 13:09:39 UTC (rev 86878)
+++ z3c.dobbin/trunk/src/z3c/dobbin/factory.py	2008-05-21 13:28:56 UTC (rev 86879)
@@ -2,9 +2,18 @@
 from zope.interface.declarations import _normalizeargs
 
 from uuid import uuid1
+from random import randint
 
 from ore.alchemist import Session
 
+def uuid():
+    """Return new unique id as string.
+
+    Force first character between 'a' and 'z'.
+    """
+    
+    return chr(randint(ord('a'), ord('z'))) + uuid1().hex[:-1]
+
 def create(spec):
     # set up mapper
     mapper = IMapper(spec)
@@ -13,7 +22,7 @@
     instance = mapper()
 
     # set soup attributes
-    instance.uuid = uuid1().hex
+    instance.uuid = uuid()
     instance.spec = mapper.__spec__
 
     # save to session



More information about the Checkins mailing list