Ticket #8630: __init__.py.patch

File __init__.py.patch, 1.9 KB (added by amir, 16 years ago)

Also removed the checks in get_comment_app() so it's possible to override only part of the functions and use the default for the rest.

  • contrib/comments/__init__.py

     
    2222        raise ImproperlyConfigured("The COMMENTS_APP setting refers to "\
    2323                                   "a non-existing package.")
    2424
    25     # Make sure some specific attributes exist inside that package.
    26     for attribute in REQUIRED_COMMENTS_APP_ATTRIBUTES:
    27         if not hasattr(package, attribute):
    28             raise ImproperlyConfigured("The COMMENTS_APP package %r does not "\
    29                                        "define the (required) %r function" % \
    30                                             (package, attribute))
    3125
    3226    return package
    3327
     
    3933    return getattr(settings, 'COMMENTS_APP', 'django.contrib.comments')
    4034
    4135def get_model():
    42     from django.contrib.comments.models import Comment
    43     return Comment
     36    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_model"):
     37        return get_comment_app().get_model()
     38    else:
     39        from django.contrib.comments.models import Comment
     40        return Comment
    4441
    4542def get_form():
    46     from django.contrib.comments.forms import CommentForm
    47     return CommentForm
     43    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_form"):
     44        return get_comment_app().get_form()
     45    else:
     46        from django.contrib.comments.forms import CommentForm
     47        return CommentForm
    4848
    4949def get_form_target():
    50     return urlresolvers.reverse("django.contrib.comments.views.comments.post_comment")
     50    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_form_target"):
     51        return get_comment_app().get_form_target()
     52    else:
     53        return urlresolvers.reverse("django.contrib.comments.views.comments.post_comment")
    5154
    5255def get_flag_url(comment):
    5356    """
Back to Top