[Zope-CMF] Automatic ID generation -- > Title Got it!

seb bacon seb@jamkit.com
Tue, 24 Apr 2001 11:32:46 +0100


* Ignacio Valdes <ivaldes@hal-pc.org> [010424 05:47]:
<lots of snipping>
> Now if I could get Folder metadata editing to quit bombing (it bombs on every single CMF
> site I have) after editing title and escription, I'm there!!!

hmm, it looks a tiny bit like the Zope catalog bug to me - have you
got the newest version of Zope?

on autogenerating ids: if I've got you correctly, you want to do this
because basing an id on a title won't work due to prohibited
characters.  If so, another solution is to strip out illegal chars
from the Title before generating the id.  This way, you have readable
ids, which is nice, but on the down side, the system will see P'tang
and P$tang! as identical.  Anyway, that's how I do it:

    import re
    def cookId(self,title):
        rgx = re.compile(r'(^_|[^a-zA-Z0-9-_~\,\.])')
        return re.sub(rgx,"",title)

seb