On Thursday 03 December 2009 14:18:10 Waylan Limberg wrote:

> Looking though this patch I couldn't help but notice the new
> get_messages function. What if a project has neither the
> MessageMiddleware nor the contrib.auth app enabled? Sure a reusable
> app could catch the error, but that error will change once all
>  support for user.messages are removed in 1.4. Shouldn't the call
>  to user.get_and_delete_messages be wrapped in a check that
>  request.user exists like the new add_message function does?

It is - the inline 'get_user()' function does effectively just that:

<<<
def get_messages(request):
    """
    Returns the message storage on the request if it exists, otherwise 
returns
    user.message_set.all() as the old auth context processor did.
    """
    if hasattr(request, '_messages'):
        return request._messages

    def get_user():
        if hasattr(request, 'user'):
            return request.user
        else:
            from django.contrib.auth.models import AnonymousUser
            return AnonymousUser()

    return lazy(memoize(get_user().get_and_delete_messages, {}, 0), 
list)()
>>>

Luke

-- 
"I am going to let you move around more, just to break up the 
mahogany." (True Quotes From Induhviduals, Scott Adams)

Luke Plant || http://lukeplant.me.uk/

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.


Reply via email to