Added parameters to getContentName function ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Mon, 20 Aug 2012 18:54:13 +0200
branchZTK-1.1
changeset 164 b09c98b285cc
parent 163 d07844bfe41d
child 165 9615e7d1a4ee
Added parameters to getContentName function
src/ztfy/utils/container.py
--- a/src/ztfy/utils/container.py	Fri Aug 17 16:13:21 2012 +0200
+++ b/src/ztfy/utils/container.py	Mon Aug 20 18:54:13 2012 +0200
@@ -23,13 +23,18 @@
 # import Zope3 packages
 
 # import local packages
+from ztfy.utils.unicode import translateString
 
 
-def getContentName(container, base_name):
+def getContentName(container, base_name, translate=True, max_length=30):
     """Get a real name for a given base name and a container
     
     Target name will be suffixed with an index if base name already exists
     """
+    if translate:
+        base_name = translateString(base_name, spaces='-')
+    if max_length:
+        base_name = base_name[0:max_length]
     if base_name not in container:
         return base_name
     index = 2