signal handling oddity

Justin Johnson justinjohnson at fastmail.fm
Mon Jun 9 14:56:49 EDT 2003


I overrode render as follows...  I know the self.send_response stuff is
wrong, and I'll have to replace it with something equivalent from
twisted.  My render method is getting called, but the authorization
header never appears, I believe because the server never challenges the
request, thus asking for username/password???  Do you know what needs to
be done to make this happen?

I appreciate your help.

	def render(self, request):
		headers = request.headers
		if headers.has_key("authorization"):
			print "has authorization key:", a["authorization"]
			real_auth = '%s:%s' % (config.adminUser, config.adminPassword)
			auth = a["authorization"]
			auth = auth.replace("Basic ","")
			decoded_auth = decodestring(auth)
			if not decoded_auth == real_auth:
				print "not authorized"
				self.send_response(401)
				self.end_headers()
			else:
				return xmlrpc.XMLRPC.render(self, request)
		else:
			return xmlrpc.XMLRPC.render(self, request)




On 9 Jun 2003 15:00:13 -0000, "Moshe Zadka" <m at moshez.org> said:
> On Mon, 09 Jun 2003, "Justin Johnson" <justinjohnson at fastmail.fm> wrote:
> 
> > Yeah, I was using twisted before for this server and it did handle
> > control-c correctly.  I was having problems getting authentication to
> > work though, so I ended up moving to SimpleXMLRPCServer and adding some
> > other code to get basic authentication to work.  I'm just not familiar
> > enough with twisted to know what to subclass/override, etc... to get
> > simple user/password authentication to work.
> 
> Well, probably in the render() method of your resource, you do
> the checking of request.headers (there's no problem doing it
> manually), and if they're ok you call the parent's render()
> and otherwise you return a 401.
> -- 
> Moshe Zadka -- http://moshez.org/
> Buffy: I don't like you hanging out with someone that... short.
> Riley: Yeah, a lot of young people nowadays are experimenting with
> shortness.
> Agile Programming Language -- http://www.python.org/
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 





More information about the Python-list mailing list