[Zope-CMF] Re: Usernames without spaces

Thomas Olsen tol@tanghus.dk
Mon, 26 Nov 2001 17:19:26 +0100


On Monday 26 November 2001 17:17, Gitte Wange wrote:
> Is there anyone out there who already has a function that does this
> little trick ?

I grabbed this from someone who used it for ids in CMF (don't ask me about 
the regex cause I suck at that):

def cookId(self, title):
    '''make a Zope friendly id out of a title (or user name)'''
    import re
    rgx = re.compile(r'(^_|[^a-zA-Z0-9-_~\,\.])')
    cooked = re.sub(rgx,"",str(title))
    return cooked

If you don't want to change the CMF directly the best thing is to create a 
hotfix.

/Thomas