Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit spam/ham - no return value #5

Closed
shacker opened this issue Nov 30, 2017 · 2 comments
Closed

Submit spam/ham - no return value #5

shacker opened this issue Nov 30, 2017 · 2 comments

Comments

@shacker
Copy link

shacker commented Nov 30, 2017

.check() seems to work fine (I get back True/False) but submit_spam() and submit_spam() have no return value, so it's unclear whether they worked or not. No errors, just nothing. Should I assume this means the submissions were successful? It would be handy to have a return value to work with, so we could:

if submit_spam(...):
    // Do something
@shacker
Copy link
Author

shacker commented Nov 30, 2017

Realizing now that there is a Python akismet lib by ubernostrum, who is a Django core developer. Seems very well documented and maintained. No offense, but I'm going to switch to using that one.

http://akismet.readthedocs.io/en/1.0.1/index.html

@Nekmo
Copy link
Owner

Nekmo commented Dec 31, 2017

If it does not work, the library returns an exception. Checking if something has worked for what the method returns, is a fudge.

        parameters = self._get_parameters(locals())
        r = self._request(self.get_submit_spam_url() if is_spam else self.get_submit_ham_url(), parameters)
        if r.text != "Thanks for making the web a better place.":
            raise AkismetServerError("Akismet server returned an error: {0}".format(r.text))

@Nekmo Nekmo closed this as completed Dec 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants