Exemple #1
0
def pingback_post(response, target_uri, slug):
    """This is the pingback handler for posts."""
    post = Post.query.filter_by(slug=slug).first()
    if post is None:
        return False

    if post is None or not post.pings_enabled:
        raise PingbackError(33, 'no such post')
    elif not post.can_read():
        raise PingbackError(49, 'access denied')
    title, excerpt = get_excerpt(response, target_uri)
    if not title:
        raise PingbackError(17, 'no title provided')
    elif not excerpt:
        raise PingbackError(17, 'no useable link to target')
    old_pingback = Comment.query.filter((Comment.is_pingback == True) &
                                        (Comment.www == response.url)).first()
    if old_pingback:
        raise PingbackError(48, 'pingback has already been registered')
    Comment(post,
            title,
            excerpt,
            '',
            response.url,
            is_pingback=True,
            submitter_ip=get_request().remote_addr,
            parser='text')
    db.commit()
    return True
Exemple #2
0
def login(username, password):
    user = User.query.filter_by(username=username).first()
    if user is None or not user.check_password(password):
        raise Fault(403, 'Bad login/pass combination.')
    if not user.is_manager:
        raise Fault(403, 'You need to be a manager in order to '
                    'use the blog RPC API')

    # store the user on the request object so that the functions
    # inside Rezine work on the request of this user.
    request = get_request()
    request.user = user
    return request
Exemple #3
0
def login(username, password):
    user = User.query.filter_by(username=username).first()
    if user is None or not user.check_password(password):
        raise Fault(403, 'Bad login/pass combination.')
    if not user.is_manager:
        raise Fault(
            403, 'You need to be a manager in order to '
            'use the blog RPC API')

    # store the user on the request object so that the functions
    # inside Rezine work on the request of this user.
    request = get_request()
    request.user = user
    return request
Exemple #4
0
def pingback_post(response, target_uri, slug):
    """This is the pingback handler for posts."""
    post = Post.query.filter_by(slug=slug).first()
    if post is None:
        return False

    if post is None or not post.pings_enabled:
        raise PingbackError(33, "no such post")
    elif not post.can_read():
        raise PingbackError(49, "access denied")
    title, excerpt = get_excerpt(response, target_uri)
    if not title:
        raise PingbackError(17, "no title provided")
    elif not excerpt:
        raise PingbackError(17, "no useable link to target")
    old_pingback = Comment.query.filter((Comment.is_pingback == True) & (Comment.www == response.url)).first()
    if old_pingback:
        raise PingbackError(48, "pingback has already been registered")
    Comment(
        post, title, excerpt, "", response.url, is_pingback=True, submitter_ip=get_request().remote_addr, parser="text"
    )
    db.commit()
    return True