New in version 0.9.
Spam protection is mandatory when you want to let your users to comment your entries.
Originally Zinnia provided a only one type of spam protection with the support of Akismet.
One it’s not bad, but it’s not enough, because depend of a third-party service may be a little bit risky.
Now Akismet has been moved in a dedicated module and the moderation system let you choose the spam checkers to use. With this new feature you can now write a custom spam checker corresponding to your needs and use it for moderation your comments.
We can imagine for example that you want to authorize comments from a white-list of IPs, it’s possible by writing a backend.
You can use multiple backends for checking the content, because they are chained, useful for a maximum protection.
ZINNIA_SPAM_CHECKER_BACKENDS = ( 'path.to.your.spam.checker.module', 'path.to.your.other.spam.checker.module', )
Built-in spam checkers¶
Writing your own spam checker backend¶
Writing a backend for using a custom spam checker is simple as possible, you only needs to follows 4 rules.
In a new Python file write a function named backend taking in parameter :
contentthe text to verify,
content_objectthe object related to the text and
requestthe current request.
The backend function should returns
contentis spam and
If the backend requires initial configuration you must raise an
ImproperlyConfiguredexception if the configuration is not valid. The error will be displayed in the console.
Register your backend to be used in your project with this setting:
ZINNIA_SPAM_CHECKER_BACKENDS = ('path.to.your.spam.checker.module',)
For a more examples take a look in this folder :