Changeset 1503 for trunk/pylucid/PyLucid/tools/shortcuts.py
- Timestamp:
- 03/25/08 09:24:47 (8 months ago)
- Files:
-
- 1 modified
-
trunk/pylucid/PyLucid/tools/shortcuts.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/PyLucid/tools/shortcuts.py
r1331 r1503 11 11 $Author$ 12 12 13 :copy right: 2007by Jens Diemer.13 :copyleft: 2007-2008 by Jens Diemer. 14 14 :license: GNU GPL v3, see LICENSE.txt for more details. 15 15 """ 16 16 17 17 import string 18 18 19 ALLOW_CHARS = string.ascii_letters + string.digits + "_" 20 19 21 20 22 def makeUnique(item_name, name_list): 21 23 """ 22 returns a unique shortcut.24 returns a URL safe, unique shortcut. 23 25 - delete all non-ALLOW_CHARS characters. 24 26 - if the shotcut already exists in name_list -> add a sequential number 25 27 Note: 26 Not only used for making page shortcuts unique. 27 Also used in PyLucid.defaulttags.lucidTag.lucidTagNode._add_unique_div() 28 Not only used for making page shortcuts unique with getUniqueShortcut(), 29 also used in: 30 -PyLucid.defaulttags.lucidTag.lucidTagNode._add_unique_div() 31 -PyLucid.middlewares.headline_anchor.HeadlineAnchor() 28 32 """ 29 33 # delete all non-ALLOW_CHARS characters and separate in parts … … 32 36 if not char in ALLOW_CHARS: 33 37 if parts[-1] != "": 34 # No double "-" e.g.: "foo - bar" -> "foo-bar" not "foo---bar" 38 # No double "-" e.g.: "foo - bar" -> "foo-bar" not "foo---bar" 35 39 parts.append("") 36 40 else: … … 56 60 return item_name 57 61 62 58 63 def getUniqueShortcut(shortcut, exclude_shortcut=None): 59 64 from PyLucid.models import Page … … 67 72 # print "existing_shortcuts:", existing_shortcuts 68 73 return makeUnique(shortcut, existing_shortcuts) 74 69 75 70 76
