<?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: RPC4Django Update October 2009</title>
	<atom:link href="http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/</link>
	<description>Some Things to Some People</description>
	<lastBuildDate>Thu, 02 Sep 2010 05:29:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: David</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/comment-page-1/#comment-81</link>
		<dc:creator>David</dc:creator>
		<pubDate>Fri, 16 Oct 2009 22:03:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=285#comment-81</guid>
		<description>The &lt;a href=&quot;http://docs.djangoproject.com/en/dev/howto/auth-remote-user/&quot; rel=&quot;nofollow&quot;&gt;RemoteUserMiddleware&lt;/a&gt; doesn&#039;t actually check the password because it assumes that your web server has already done that for you. With Apache, you would probably be using something like Django&#039;s &lt;a href=&quot;http://docs.djangoproject.com/en/dev/howto/apache-auth/&quot; rel=&quot;nofollow&quot;&gt;mod_python auth handler&lt;/a&gt; or the soon to be integrated (hopefully) &lt;a href=&quot;http://code.djangoproject.com/ticket/10809&quot; rel=&quot;nofollow&quot;&gt;mod_wsgi auth handler&lt;/a&gt;. This is pretty common for an intranet deployment, but an internet deployment might want to use the cookie/session based approach that you implemented with your custom middleware.

As for &lt;code&gt;allow_none&lt;/code&gt;, there is no particular reason. In fact, I think it should be allowed or at least optional. It may require some testing because I believe they added that parameter to SimpleXMLRPCDispatcher in Python 2.5. I&#039;ll add this to the TODO list.

I&#039;m glad to see you&#039;re using RPC4Django. Normally, I&#039;d be glad to take a beer via Paypal, but I have 5 gallons of &lt;a href=&quot;http://www.brew365.com/beer_dennys_bourbon_vanilla_porter.php&quot; rel=&quot;nofollow&quot;&gt; bourbon vanilla porter&lt;/a&gt; bottle conditioning right now. It should be ready to drink in about a week and a half. Instead, if you feel like donating, please take a look at my &lt;a href=&quot;http://amzn.com/w/1Z1GLQYQPFBT1&quot; rel=&quot;nofollow&quot;&gt;wish list&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>The <a href="http://docs.djangoproject.com/en/dev/howto/auth-remote-user/" rel="nofollow">RemoteUserMiddleware</a> doesn&#8217;t actually check the password because it assumes that your web server has already done that for you. With Apache, you would probably be using something like Django&#8217;s <a href="http://docs.djangoproject.com/en/dev/howto/apache-auth/" rel="nofollow">mod_python auth handler</a> or the soon to be integrated (hopefully) <a href="http://code.djangoproject.com/ticket/10809" rel="nofollow">mod_wsgi auth handler</a>. This is pretty common for an intranet deployment, but an internet deployment might want to use the cookie/session based approach that you implemented with your custom middleware.</p>
<p>As for <code>allow_none</code>, there is no particular reason. In fact, I think it should be allowed or at least optional. It may require some testing because I believe they added that parameter to SimpleXMLRPCDispatcher in Python 2.5. I&#8217;ll add this to the TODO list.</p>
<p>I&#8217;m glad to see you&#8217;re using RPC4Django. Normally, I&#8217;d be glad to take a beer via Paypal, but I have 5 gallons of <a href="http://www.brew365.com/beer_dennys_bourbon_vanilla_porter.php" rel="nofollow"> bourbon vanilla porter</a> bottle conditioning right now. It should be ready to drink in about a week and a half. Instead, if you feel like donating, please take a look at my <a href="http://amzn.com/w/1Z1GLQYQPFBT1" rel="nofollow">wish list</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ale</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/comment-page-1/#comment-80</link>
		<dc:creator>ale</dc:creator>
		<pubDate>Fri, 16 Oct 2009 17:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=285#comment-80</guid>
		<description>I&#039;m now successfully doctesting rpc4django with something like:

&gt;&gt;&gt; from django.core.management import call_command
&gt;&gt;&gt; # install fixture
&gt;&gt;&gt; call_command(&#039;loaddata&#039;, &#039;auth_sites.json&#039;)
Installing json fixture &#039;auth_sites&#039; from...
Installed...
&gt;&gt;&gt; from django.test.client import Client
&gt;&gt;&gt; c = Client()
&gt;&gt;&gt; from xmlrpclib import *
&gt;&gt;&gt; r = c.post(&#039;/RPC2&#039;, dumps(tuple([ &quot;cat_test&quot;,  &quot;cat_desc&quot;]), &quot;risorse.add_category&quot;) , content_type = &#039;text/xml&#039;)
... DEBUG Method &quot;risorse.add_category&quot; is protected by permission &quot;add_category&quot;
... INFO User &quot;AnonymousUser&quot; is NOT authorized
&gt;&gt;&gt; from django.contrib.auth.models import User
&gt;&gt;&gt; u = User.objects.get(username=&#039;admin&#039;)
&gt;&gt;&gt; u

&gt;&gt;&gt; c.login(username=&#039;admin&#039;, password=&#039;admin&#039;)
True
&gt;&gt;&gt; r = c.post(&#039;/RPC2&#039;, dumps(tuple([ &quot;cat_test1&quot;,  &quot;cat_desc1&quot;]), &quot;risorse.add_category&quot;) , content_type = &#039;text/xml&#039;)
... DEBUG Method &quot;risorse.add_category&quot; is protected by permission &quot;add_category&quot;
... DEBUG User &quot;admin&quot; is authorized


One more question: I had to change rpcdispatcher.py to allow_none:

           self.xmlrpcdispatcher = SimpleXMLRPCDispatcher(allow_none=True, 
                                                           encoding=None)


Why did you set it up to not allow none? Is there a particular reason ?


You really did a great job with rpc4django !!

I would be happy to donate you a beer or two via paypal.</description>
		<content:encoded><![CDATA[<p>I&#8217;m now successfully doctesting rpc4django with something like:</p>
<p>&gt;&gt;&gt; from django.core.management import call_command<br />
&gt;&gt;&gt; # install fixture<br />
&gt;&gt;&gt; call_command(&#8216;loaddata&#8217;, &#8216;auth_sites.json&#8217;)<br />
Installing json fixture &#8216;auth_sites&#8217; from&#8230;<br />
Installed&#8230;<br />
&gt;&gt;&gt; from django.test.client import Client<br />
&gt;&gt;&gt; c = Client()<br />
&gt;&gt;&gt; from xmlrpclib import *<br />
&gt;&gt;&gt; r = c.post(&#8216;/RPC2&#8242;, dumps(tuple([ "cat_test",  "cat_desc"]), &#8220;risorse.add_category&#8221;) , content_type = &#8216;text/xml&#8217;)<br />
&#8230; DEBUG Method &#8220;risorse.add_category&#8221; is protected by permission &#8220;add_category&#8221;<br />
&#8230; INFO User &#8220;AnonymousUser&#8221; is NOT authorized<br />
&gt;&gt;&gt; from django.contrib.auth.models import User<br />
&gt;&gt;&gt; u = User.objects.get(username=&#8217;admin&#8217;)<br />
&gt;&gt;&gt; u</p>
<p>&gt;&gt;&gt; c.login(username=&#8217;admin&#8217;, password=&#8217;admin&#8217;)<br />
True<br />
&gt;&gt;&gt; r = c.post(&#8216;/RPC2&#8242;, dumps(tuple([ "cat_test1",  "cat_desc1"]), &#8220;risorse.add_category&#8221;) , content_type = &#8216;text/xml&#8217;)<br />
&#8230; DEBUG Method &#8220;risorse.add_category&#8221; is protected by permission &#8220;add_category&#8221;<br />
&#8230; DEBUG User &#8220;admin&#8221; is authorized</p>
<p>One more question: I had to change rpcdispatcher.py to allow_none:</p>
<p>           self.xmlrpcdispatcher = SimpleXMLRPCDispatcher(allow_none=True,<br />
                                                           encoding=None)</p>
<p>Why did you set it up to not allow none? Is there a particular reason ?</p>
<p>You really did a great job with rpc4django !!</p>
<p>I would be happy to donate you a beer or two via paypal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ale</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/comment-page-1/#comment-79</link>
		<dc:creator>ale</dc:creator>
		<pubDate>Fri, 16 Oct 2009 17:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=285#comment-79</guid>
		<description>Thank you for answering,

I&#039;m using the manage.py  testing server, I solved the issue writing a middleware that checks HTTP_AUTHORIZATION


class HttpAuthMiddleware:
   def process_request(self, request):    
        auth_basic = request.META.get(&#039;HTTP_AUTHORIZATION&#039;)
        if auth_basic:
            import base64
            try:
                username , dummy,  password = base64.decodestring(auth_basic[6:]).partition(&#039;:&#039;)
                user = User.objects.get(username=username)
                if user.check_password(password):
                   request.user = user
            except User.DoesNotExist:
                return None

I&#039;m confused about how RemoteUserMiddleware works, it just checks for a previous session ? It seems like it never checks for a password...

I&#039;m trying to have this setup:
* users can normally login through admin site with cookie based auth (default Django behavior)
* machine-2-machine webservice calls should use HTTP Basic sending credentials from standard libraries like http://username:password@example.com</description>
		<content:encoded><![CDATA[<p>Thank you for answering,</p>
<p>I&#8217;m using the manage.py  testing server, I solved the issue writing a middleware that checks HTTP_AUTHORIZATION</p>
<p>class HttpAuthMiddleware:<br />
   def process_request(self, request):<br />
        auth_basic = request.META.get(&#8216;HTTP_AUTHORIZATION&#8217;)<br />
        if auth_basic:<br />
            import base64<br />
            try:<br />
                username , dummy,  password = base64.decodestring(auth_basic[6:]).partition(&#8216;:&#8217;)<br />
                user = User.objects.get(username=username)<br />
                if user.check_password(password):<br />
                   request.user = user<br />
            except User.DoesNotExist:<br />
                return None</p>
<p>I&#8217;m confused about how RemoteUserMiddleware works, it just checks for a previous session ? It seems like it never checks for a password&#8230;</p>
<p>I&#8217;m trying to have this setup:<br />
* users can normally login through admin site with cookie based auth (default Django behavior)<br />
* machine-2-machine webservice calls should use HTTP Basic sending credentials from standard libraries like <a href="http://username:password@example.com" rel="nofollow">http://username:password@example.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/comment-page-1/#comment-78</link>
		<dc:creator>David</dc:creator>
		<pubDate>Fri, 16 Oct 2009 15:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=285#comment-78</guid>
		<description>I&#039;m glad you&#039;re using it!

What message is the protocol error giving you? A &quot;401 Unauthorized&quot; is a protocol error and RPC4Django will return that if you don&#039;t have access to call the appropriate method. I ask this because you have enabled the remote user middleware and you mentioned that you still needed admin/admin to login to the control panel. With the remote user middleware working properly, you should not need to login to the demo site because you would already be authenticated with Apache. If you aren&#039;t using Apache authentication, there&#039;s no need to send the authentication with the XMLRPC request.

I think with a little more information about your setup, we can get to the bottom of this.</description>
		<content:encoded><![CDATA[<p>I&#8217;m glad you&#8217;re using it!</p>
<p>What message is the protocol error giving you? A &#8220;401 Unauthorized&#8221; is a protocol error and RPC4Django will return that if you don&#8217;t have access to call the appropriate method. I ask this because you have enabled the remote user middleware and you mentioned that you still needed admin/admin to login to the control panel. With the remote user middleware working properly, you should not need to login to the demo site because you would already be authenticated with Apache. If you aren&#8217;t using Apache authentication, there&#8217;s no need to send the authentication with the XMLRPC request.</p>
<p>I think with a little more information about your setup, we can get to the bottom of this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ale</title>
		<link>http://www.davidfischer.name/2009/10/rpc4django-update-oct-09/comment-page-1/#comment-77</link>
		<dc:creator>ale</dc:creator>
		<pubDate>Fri, 16 Oct 2009 11:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidfischer.name/?p=285#comment-77</guid>
		<description>Hi,

Thanks for this wonderful application!

I&#039;m having an hard time testing my services, particularly: I cannot make authentication work (user admin password admin can log in the control panel).

Also, I should be able to access the request object (or at least the authenticated  User informations) from inside the method, do you know any way to do it?.

Settings:

MIDDLEWARE_CLASSES  = (
    &#039;django.middleware.common.CommonMiddleware&#039;,
    &#039;django.contrib.sessions.middleware.SessionMiddleware&#039;,
    &#039;django.contrib.auth.middleware.AuthenticationMiddleware&#039;,
    # Required for RPC4Django authenticated method calls
    # Requires Django 1.1+
    &#039;django.contrib.auth.middleware.RemoteUserMiddleware&#039;, 
    &#039;django.middleware.locale.LocaleMiddleware&#039;,
    &#039;middleware.SiteDetectionMiddleware&#039;,
)

AUTHENTICATION_BACKENDS = (
    &#039;django.contrib.auth.backends.RemoteUserBackend&#039;,
    # if the following line is commented, I cannot log in the control panel!!!
    &#039;django.contrib.auth.backends.ModelBackend&#039;,
)


Test:

from xmlrpclib import ServerProxy 
s = ServerProxy(&#039;http://admin:admin@127.0.0.1:8000/RPC2&#039;)
r = s.risorse.add_category(&#039;test_cat&#039;, &#039;test_desc&#039;)

xmlrpclib.ProtocolError: </description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for this wonderful application!</p>
<p>I&#8217;m having an hard time testing my services, particularly: I cannot make authentication work (user admin password admin can log in the control panel).</p>
<p>Also, I should be able to access the request object (or at least the authenticated  User informations) from inside the method, do you know any way to do it?.</p>
<p>Settings:</p>
<p>MIDDLEWARE_CLASSES  = (<br />
    &#8216;django.middleware.common.CommonMiddleware&#8217;,<br />
    &#8216;django.contrib.sessions.middleware.SessionMiddleware&#8217;,<br />
    &#8216;django.contrib.auth.middleware.AuthenticationMiddleware&#8217;,<br />
    # Required for RPC4Django authenticated method calls<br />
    # Requires Django 1.1+<br />
    &#8216;django.contrib.auth.middleware.RemoteUserMiddleware&#8217;,<br />
    &#8216;django.middleware.locale.LocaleMiddleware&#8217;,<br />
    &#8216;middleware.SiteDetectionMiddleware&#8217;,<br />
)</p>
<p>AUTHENTICATION_BACKENDS = (<br />
    &#8216;django.contrib.auth.backends.RemoteUserBackend&#8217;,<br />
    # if the following line is commented, I cannot log in the control panel!!!<br />
    &#8216;django.contrib.auth.backends.ModelBackend&#8217;,<br />
)</p>
<p>Test:</p>
<p>from xmlrpclib import ServerProxy<br />
s = ServerProxy(&#8216;http://admin:admin@127.0.0.1:8000/RPC2&#8242;)<br />
r = s.risorse.add_category(&#8216;test_cat&#8217;, &#8216;test_desc&#8217;)</p>
<p>xmlrpclib.ProtocolError:</p>
]]></content:encoded>
	</item>
</channel>
</rss>
