<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Django &#8220;anonymous_required&#8221; decorator</title>
	<atom:link href="http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1157</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Fri, 12 Feb 2010 15:50:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1157</guid>
		<description>Read the python manual on decorators :)</description>
		<content:encoded><![CDATA[<p>Read the python manual on decorators <img src='http://blog.motane.lu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1156</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Fri, 12 Feb 2010 15:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1156</guid>
		<description>Thanks it works..
I did not know before i thought both login = never_cache(login) and @never_cache works in same fashion.
Really great post and it could give me more logic regarding decorator.
Regards
Praveen</description>
		<content:encoded><![CDATA[<p>Thanks it works..<br />
I did not know before i thought both login = never_cache(login) and @never_cache works in same fashion.<br />
Really great post and it could give me more logic regarding decorator.<br />
Regards<br />
Praveen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1155</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Fri, 12 Feb 2010 14:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1155</guid>
		<description>Try it like:

[sourcecode lang=&quot;python&quot;]
@anonymous_required
@never_cache
def login( ... )
[/sourcecode]</description>
		<content:encoded><![CDATA[<p>Try it like:</p>
<pre class="brush: python; title: ; notranslate">
@anonymous_required
@never_cache
def login( ... )
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1154</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Fri, 12 Feb 2010 14:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1154</guid>
		<description>Yeah.. many thanks.. The problem was with &quot;never_cache&quot; decorator..
But i do not why we are disabling cache here.

Regards
Praveen</description>
		<content:encoded><![CDATA[<p>Yeah.. many thanks.. The problem was with &#8220;never_cache&#8221; decorator..<br />
But i do not why we are disabling cache here.</p>
<p>Regards<br />
Praveen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1153</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Fri, 12 Feb 2010 14:19:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1153</guid>
		<description>I think it might be conflicting with the &quot;never_cache&quot; decorator...</description>
		<content:encoded><![CDATA[<p>I think it might be conflicting with the &#8220;never_cache&#8221; decorator&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1151</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Fri, 12 Feb 2010 14:15:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1151</guid>
		<description>Still i am getting the same error.. here is my login view [I am using python2.6]
[code lang=&quot;python&quot;]
@anonymous_required
def login(request, form_class=None, template_name=&#039;registration/login.html&#039;, redirect_field_name=REDIRECT_FIELD_NAME):
	&quot;Displays the login form and handles the login action.&quot;
	redirect_to = request.REQUEST.get(redirect_field_name, &#039;&#039;)
    
        if request.method == &quot;POST&quot;:
            form = AuthenticationForm(data=request.POST)
	    if form.is_valid():
                if not redirect_to or &#039;//&#039; in redirect_to or &#039; &#039; in redirect_to:
                    redirect_to = settings.LOGIN_REDIRECT_URL
                from django.contrib.auth.views import login
                
                login(request, form.get_user())
                if request.session.test_cookie_worked():
                    request.session.delete_test_cookie()
                return HttpResponseRedirect(reverse(&#039;goto_dashboard&#039;))
        else:
            form = AuthenticationForm(request)
	    #captchform = form_class()
        request.session.set_test_cookie()
        if Site._meta.installed:
            current_site = Site.objects.get_current()
        else:
            current_site = RequestSite(request)
        return render_to_response(template_name, {
	    &#039;form&#039;: form,
        redirect_field_name: redirect_to,
        &#039;site&#039;: current_site,
        &#039;site_name&#039;: current_site.name,
    }, context_instance=RequestContext(request))
login = never_cache(login)
[/code]</description>
		<content:encoded><![CDATA[<p>Still i am getting the same error.. here is my login view [I am using python2.6]</p>
<pre class="brush: python; title: ; notranslate">
@anonymous_required
def login(request, form_class=None, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME):
	&quot;Displays the login form and handles the login action.&quot;
	redirect_to = request.REQUEST.get(redirect_field_name, '')

        if request.method == &quot;POST&quot;:
            form = AuthenticationForm(data=request.POST)
	    if form.is_valid():
                if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
                    redirect_to = settings.LOGIN_REDIRECT_URL
                from django.contrib.auth.views import login

                login(request, form.get_user())
                if request.session.test_cookie_worked():
                    request.session.delete_test_cookie()
                return HttpResponseRedirect(reverse('goto_dashboard'))
        else:
            form = AuthenticationForm(request)
	    #captchform = form_class()
        request.session.set_test_cookie()
        if Site._meta.installed:
            current_site = Site.objects.get_current()
        else:
            current_site = RequestSite(request)
        return render_to_response(template_name, {
	    'form': form,
        redirect_field_name: redirect_to,
        'site': current_site,
        'site_name': current_site.name,
    }, context_instance=RequestContext(request))
login = never_cache(login)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tudor</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1147</link>
		<dc:creator>Tudor</dc:creator>
		<pubDate>Thu, 11 Feb 2010 20:25:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1147</guid>
		<description>There was an &quot;or&quot; instead of an &quot;and&quot; (fixed now), but nothing that could generate that error.</description>
		<content:encoded><![CDATA[<p>There was an &#8220;or&#8221; instead of an &#8220;and&#8221; (fixed now), but nothing that could generate that error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://blog.motane.lu/2010/01/06/django-anonymous_required-decorator/comment-page-1/#comment-1145</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Thu, 11 Feb 2010 19:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.motane.lu/?p=1269#comment-1145</guid>
		<description>That what i was looking for.
I tried your code but did not work
[code lang=&quot;plain&quot;]
Error:
AttributeError at /accounts/login/

&#039;AnonymousRequired&#039; object has no attribute &#039;__name__&#039;

Request Method: 	GET
Request URL: 	http://localhost:8000/accounts/login/
Exception Type: 	AttributeError
Exception Value: 	

&#039;AnonymousRequired&#039; object has no attribute &#039;__name__&#039;

Exception Location: 	C:\Python26\lib\functools.py in update_wrapper, line 33
Python Executable: 	C:\Python26\python.exe
Python Version: 	2.6.0
[/code]</description>
		<content:encoded><![CDATA[<p>That what i was looking for.<br />
I tried your code but did not work</p>
<pre class="brush: plain; title: ; notranslate">
Error:
AttributeError at /accounts/login/

'AnonymousRequired' object has no attribute '__name__'

Request Method: 	GET
Request URL: 	<a href="http://localhost:8000/accounts/login/" rel="nofollow">http://localhost:8000/accounts/login/</a>
Exception Type: 	AttributeError
Exception Value: 	

'AnonymousRequired' object has no attribute '__name__'

Exception Location: 	C:\Python26\lib\functools.py in update_wrapper, line 33
Python Executable: 	C:\Python26\python.exe
Python Version: 	2.6.0
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

