コード例 #1
0
ファイル: Content.py プロジェクト: datagovuk/mollom
    def checkContent( self
                    , post_title=None
                    , post_body=None
                    , author_name=None
                    , author_url=None
                    , author_mail=None
                    , author_open_id=None
                    , author_ip=None
                    , author_id=None
                    , checks=None
                    , unsure=None
                    , strictness=None
                    , rate_limit=None
                    , honeypot=None
                    , stored=None
                    , url=None
                    , context_url=None
                    , context_title=None):
        """Submit content to the Mollom service to have it checked for spaminess.

        Keyword arguments:
        post_title     (optional) -- The title of your post or comment.
        post_body      (optional) -- The main content that needs to be checked.
        author_name    (optional) -- The content author.
        author_url     (optional) -- The URL of the content author's website.
        author_mail    (optional) -- The email address of the content author.
        author_open_id (optional) -- The Open ID of the content author.
        author_ip      (optional) -- The IP address of the content author.
        author_id      (optional) -- The ID the content author has on the website where the posting takes place.
        checks         (optional) --
        unsure         (optional) --
        strictness     (optional) --
        rate_limit     (optional) --
        honeypot       (optional) --
        stored         (optional) --
        url            (optional) --
        context_url    (optional) --
        context_title  (optional) --

        Returns:
        A dictionary with following keys if succesful
            id                  -- the content ID corresponding to the submission
            spamScore           -- only returned when the check included SPAM
        """

        tuples = {'postTitle': post_title
            , 'postBody': post_body
            , 'authorName': author_name
            , 'authorUrl': author_url
            , 'authorMail': author_mail
            , 'authorOpenid': author_open_id
            , 'authorIp': author_ip
            , 'authorId': author_id
            , 'checks': checks #FIXME: these should be concatenated
            , 'unsure': unsure
            , 'strictness': strictness
            , 'rateLimit': rate_limit
            , 'honeypot': honeypot
            , 'stored': stored
            , 'url': url
            , 'contextUrl': context_url
            , 'contextTitle': context_title}
        data = __cat_maybe_values(tuples)
        answer = __service('POST', 'content', data, 22)

        # for now, we check for a None, this should be fixed when we throw exceptions
        if answer == None:
            return None

        return self.__parseContentResponse(json.loads(answer))
コード例 #2
0
    def checkContent(self,
                     post_title=None,
                     post_body=None,
                     author_name=None,
                     author_url=None,
                     author_mail=None,
                     author_open_id=None,
                     author_ip=None,
                     author_id=None,
                     checks=None,
                     unsure=None,
                     strictness=None,
                     rate_limit=None,
                     honeypot=None,
                     stored=None,
                     url=None,
                     context_url=None,
                     context_title=None):
        """Submit content to the Mollom service to have it checked for spaminess.

        Keyword arguments:
        post_title     (optional) -- The title of your post or comment.
        post_body      (optional) -- The main content that needs to be checked.
        author_name    (optional) -- The content author.
        author_url     (optional) -- The URL of the content author's website.
        author_mail    (optional) -- The email address of the content author.
        author_open_id (optional) -- The Open ID of the content author.
        author_ip      (optional) -- The IP address of the content author.
        author_id      (optional) -- The ID the content author has on the website where the posting takes place.
        checks         (optional) --
        unsure         (optional) --
        strictness     (optional) --
        rate_limit     (optional) --
        honeypot       (optional) --
        stored         (optional) --
        url            (optional) --
        context_url    (optional) --
        context_title  (optional) --

        Returns:
        A dictionary with following keys if succesful
            id                  -- the content ID corresponding to the submission
            spamScore           -- only returned when the check included SPAM
        """

        tuples = {
            'postTitle': post_title,
            'postBody': post_body,
            'authorName': author_name,
            'authorUrl': author_url,
            'authorMail': author_mail,
            'authorOpenid': author_open_id,
            'authorIp': author_ip,
            'authorId': author_id,
            'checks': checks  #FIXME: these should be concatenated
            ,
            'unsure': unsure,
            'strictness': strictness,
            'rateLimit': rate_limit,
            'honeypot': honeypot,
            'stored': stored,
            'url': url,
            'contextUrl': context_url,
            'contextTitle': context_title
        }
        data = __cat_maybe_values(tuples)
        answer = __service('POST', 'content', data, 22)

        # for now, we check for a None, this should be fixed when we throw exceptions
        if answer == None:
            return None

        return self.__parseContentResponse(json.loads(answer))
コード例 #3
0
ファイル: Content.py プロジェクト: datagovuk/mollom
    def updateContent( self
                     , post_title=None
                     , post_body=None
                     , author_name=None
                     , author_url=None
                     , author_mail=None
                     , author_open_id=None
                     , author_ip=None
                     , author_id=None
                     , checks=None
                     , unsure=None
                     , strictness=None
                     , rate_limit=None
                     , honeypot=None
                     , stored=None
                     , url=None
                     , context_url=None
                     , context_title=None
    ):
        """Submit content to the Mollom service to have it updated. The contentId is
        taken from the calling object, so you should not use this unless you called
        checkContent first.

        Keyword arguments:
        post_title     (optional) -- The title of your post or comment.
        post_body      (optional) -- The main content that needs to be checked.
        author_name    (optional) -- The content author.
        author_url     (optional) -- The URL of the content author's website.
        author_mail    (optional) -- The email address of the content author.
        author_open_id (optional) -- The Open ID of the content author.
        author_ip      (optional) -- The IP address of the content author.
        author_id      (optional) -- The ID the content author has on the website where the posting takes place.
        checks         (optional) --
        unsure         (optional) --
        strictness     (optional) --
        rate_limit     (optional) --
        honeypot       (optional) --
        stored         (optional) --
        url            (optional) --
        context_url    (optional) --
        context_title  (optional) --

        Returns:
        A dictionary with following keys if succesful
          spam       -- 1 for ham, 2 for spam, 3 for unsure
          quality    -- Mollom's assesment of the content quality [0,1]
          session_id -- The session ID for communicating with Mollom about this chunk of content
        """

        # FIXME: throw an exception
        if self.contentId == None:
            return None

        tuples = {'contentId': self.contentId
            , 'post_title': post_title
            , 'post_body': post_body
            , 'author_name': author_name
            , 'author_url': author_url
            , 'authorMail': author_mail
            , 'authorOpenid': author_open_id
            , 'authorIp': author_ip
            , 'authorId': author_id
            , 'checks': checks #FIXME: these should be concatenated
            , 'unsure': unsure
            , 'strictness': strictness
            , 'rateLimit': rate_limit
            , 'honeypot': honeypot
            , 'stored': stored
            , 'url': url
            , 'contextUrl': context_url
            , 'contextTitle': context_title}
        data = __cat_maybe_values(tuples)
        answer = __service('POST', 'content', data, 2)

        # for now, we check for a None, this should be fixed when we throw exceptions
        if answer == None:
            return None

        return self.__parseContentResponse(json.loads(answer))
コード例 #4
0
    def updateContent(self,
                      post_title=None,
                      post_body=None,
                      author_name=None,
                      author_url=None,
                      author_mail=None,
                      author_open_id=None,
                      author_ip=None,
                      author_id=None,
                      checks=None,
                      unsure=None,
                      strictness=None,
                      rate_limit=None,
                      honeypot=None,
                      stored=None,
                      url=None,
                      context_url=None,
                      context_title=None):
        """Submit content to the Mollom service to have it updated. The contentId is
        taken from the calling object, so you should not use this unless you called
        checkContent first.

        Keyword arguments:
        post_title     (optional) -- The title of your post or comment.
        post_body      (optional) -- The main content that needs to be checked.
        author_name    (optional) -- The content author.
        author_url     (optional) -- The URL of the content author's website.
        author_mail    (optional) -- The email address of the content author.
        author_open_id (optional) -- The Open ID of the content author.
        author_ip      (optional) -- The IP address of the content author.
        author_id      (optional) -- The ID the content author has on the website where the posting takes place.
        checks         (optional) --
        unsure         (optional) --
        strictness     (optional) --
        rate_limit     (optional) --
        honeypot       (optional) --
        stored         (optional) --
        url            (optional) --
        context_url    (optional) --
        context_title  (optional) --

        Returns:
        A dictionary with following keys if succesful
          spam       -- 1 for ham, 2 for spam, 3 for unsure
          quality    -- Mollom's assesment of the content quality [0,1]
          session_id -- The session ID for communicating with Mollom about this chunk of content
        """

        # FIXME: throw an exception
        if self.contentId == None:
            return None

        tuples = {
            'contentId': self.contentId,
            'post_title': post_title,
            'post_body': post_body,
            'author_name': author_name,
            'author_url': author_url,
            'authorMail': author_mail,
            'authorOpenid': author_open_id,
            'authorIp': author_ip,
            'authorId': author_id,
            'checks': checks  #FIXME: these should be concatenated
            ,
            'unsure': unsure,
            'strictness': strictness,
            'rateLimit': rate_limit,
            'honeypot': honeypot,
            'stored': stored,
            'url': url,
            'contextUrl': context_url,
            'contextTitle': context_title
        }
        data = __cat_maybe_values(tuples)
        answer = __service('POST', 'content', data, 2)

        # for now, we check for a None, this should be fixed when we throw exceptions
        if answer == None:
            return None

        return self.__parseContentResponse(json.loads(answer))