From 0fe19ac5d1bb0198c006f47886ea2f71c22d385b Mon Sep 17 00:00:00 2001 From: Rory McCann Date: Sat, 10 Jan 2009 23:31:14 +0000 Subject: [PATCH] Cleaned up some stuff I don't use anymore --- __init__.py | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/__init__.py b/__init__.py index 5aa1ee8..b3aff0c 100644 --- a/__init__.py +++ b/__init__.py @@ -34,47 +34,6 @@ TEMPLATES = join(dirname(__file__), 'templates') _verified_keys = set() -class InvalidKey(ValueError): - """Raised with a message if the key is invalid.""" - - def __init__(self, message): - self.message = message - ValueError.__init__(self, message) - - -def is_valid_key(message=None, memorize=False): - """A validator that validates keys.""" - if message is None: - message = _('The key is invalid.') - - def validate(form, apikey): - blog_url = get_application().cfg['blog_url'] - cachekey = (apikey, blog_url) - if cachekey in _verified_keys: - return - - data = {'key': apikey, 'blog': blog_url} - resp = send_request(apikey, False, data, 'verify-key') - if resp is None: - raise ValidationError(_('Could not verify key because of a ' - 'server to server connection error.')) - elif resp != 'valid': - raise ValidationError(message) - if memorize: - _verified_keys.add(cachekey) - return validate - - -def get_recaptcha_key(): - """Return the recaptcha key for the current application or - `None` if there is no key or the key is invalid. - """ - app = get_application() - key = app.cfg['recaptcha_spam_filter/apikey'] - if key and check(is_valid_key, key, memorize=True): - return key - - class ConfigurationForm(forms.Form): """The configuration form.""" pubkey = forms.TextField(validators=[is_valid_key()]) @@ -152,20 +111,6 @@ def show_recaptcha_config(req): form=form.as_widget()) -#class AkismetBlockedCommentsCounterWidget(Widget): -# NAME = 'get_akismet_blocked_comments' -# TEMPLATE = 'akismet_widget.html' -# -# def __init__(self, show_title=False, title='Akismet Blocked Comments'): -# self.show_title = show_title -# self.title = title -# self.spam_comments = Comment.objects.filter( -# Comment.blocked_msg == BLOCKED_MSG).count() -# -# @staticmethod -# def get_display_name(): -# return _('Comments Blocked by Akismet') - def add_captcha(req, post): return captcha.displayhtml(req.app.cfg['recaptcha_spam_filter/pubkey']) @@ -183,4 +128,3 @@ def setup(app, plugin): app.connect_event('before-comment-saved', do_spamcheck) app.connect_event('modify-admin-navigation-bar', add_recaptcha_link) app.add_template_searchpath(TEMPLATES) - #app.add_widget(AkismetBlockedCommentsCounterWidget) -- 2.11.4.GIT