Django

Code

Changeset 8573

Show
Ignore:
Timestamp:
08/26/08 01:58:43 (3 months ago)
Author:
mtredinnick
Message:

The comments app was unconditionally accessing various settings that didn't
exist in Django's global settings. Changed those accesses to conditional
lookups with default fallbacks.

The comment_test tests now pass without needing to add any extra settings.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/comments/__init__.py

    r8557 r8573  
    1111    """ 
    1212    # Make sure the app's in INSTALLED_APPS 
    13     comments_app = getattr(settings, 'COMMENTS_APP', 'django.contrib.comments'
     13    comments_app = get_comment_app_name(
    1414    if comments_app not in settings.INSTALLED_APPS: 
    1515        raise ImproperlyConfigured("The COMMENTS_APP (%r) "\ 
     
    1818    # Try to import the package 
    1919    try: 
    20         package = __import__(settings.COMMENTS_APP, '', '', ['']) 
     20        package = __import__(comments_app, '', '', ['']) 
    2121    except ImportError: 
    2222        raise ImproperlyConfigured("The COMMENTS_APP setting refers to "\ 
     
    3131 
    3232    return package 
     33 
     34def get_comment_app_name(): 
     35    """ 
     36    Returns the name of the comment app (either the setting value, if it 
     37    exists, or the default). 
     38    """ 
     39    return getattr(settings, 'COMMENTS_APP', 'django.contrib.comments') 
    3340 
    3441def get_model(): 
     
    4754    Get the URL for the "flag this comment" view. 
    4855    """ 
    49     if settings.COMMENTS_APP != __name__ and hasattr(get_comment_app(), "get_flag_url"): 
     56    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_flag_url"): 
    5057        return get_comment_app().get_flag_url(comment) 
    5158    else: 
     
    5663    Get the URL for the "delete this comment" view. 
    5764    """ 
    58     if settings.COMMENTS_APP != __name__ and hasattr(get_comment_app(), "get_delete_url"): 
     65    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_delete_url"): 
    5966        return get_comment_app().get_flag_url(get_delete_url) 
    6067    else: 
     
    6572    Get the URL for the "approve this comment from moderation" view. 
    6673    """ 
    67     if settings.COMMENTS_APP != __name__ and hasattr(get_comment_app(), "get_approve_url"): 
     74    if get_comment_app_name() != __name__ and hasattr(get_comment_app(), "get_approve_url"): 
    6875        return get_comment_app().get_approve_url(comment) 
    6976    else: 
  • django/trunk/django/contrib/comments/templatetags/comments.py

    r8557 r8573  
    8282            is_public    = True, 
    8383        ) 
    84         if settings.COMMENTS_HIDE_REMOVED
     84        if getattr(settings, 'COMMENTS_HIDE_REMOVED', True)
    8585            qs = qs.filter(is_removed=False) 
    8686