# HG changeset patch # User Thierry Florac # Date 1345481653 -7200 # Node ID b09c98b285cc99d8e73311fccf1ccd8d08f3721f # Parent d07844bfe41deb9200266df3c887882bf50204b2 Added parameters to getContentName function diff -r d07844bfe41d -r b09c98b285cc 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