[Zope] Dirty Word Filter

Erik Enge erik+list@esol.no
16 Feb 2001 20:44:02 +0100


[Ben Ocean]

| Has anyone developed a Zope dirty word filter?

How do you define filter?  And how would you use it?  F ex when
displaying content?  Or when adding content?

For ZCatalog searches there is a stop-word list, I don't know too much
about it, but for searches, that could be used I guess (albeit, it is
a very ugly solution).

Maybe (untested!):

aString = 'you <dirty word1> bastard!'
DirtyWords = [<dirty word1>, <dirty word2>]


for word in string.split(aString, ' '):
        if word in DirtyWords:
                aString = string.replace(aString, word, '*bleep*')

I guess that would work.  If you combine that, with soundex and
ZCatalog you could get a nice filter.

Create it as a python module in the Extensions/ directory and let
everything you want to check have a run through that script first.