Biblioteka Riklaunima - rkblog.rk.edu.pl http://www.rkblog.rk.edu.pl/ Artykuły i Wiadomości z rkblog.rk.edu.pl | Python pl Biblioteka Riklaunima - rkblog.rk.edu.pl | Python http://www.rkblog.rk.edu.pl/site_media/layout/tux.png http://www.rkblog.rk.edu.pl/ 132 124 http://www.rkblog.rk.edu.pl/w/p/pil-great/ http://www.rkblog.rk.edu.pl/w/p/pil-great/ PIL is great In my job I got a task to check what can make good thumbnails of big JPEGs in shortest time. As the site is written in PHP I've tested MagicWand and GD plus PIL and EPEG. Making thumbs from few pictures (40MB) took for MagicWand Resize 4,7s, MagicWand Scale 1,77s, GD 0,8s, PIL 0,2s, EPEG 0,15s. EPEG is a e17 library which is designed to make JPEG thumbs but it lacks extra filters (sharpen) so the thumbs aren't top quality. PIL has antialias, sharpen and preserves ratio by default and is faster than GD and imagemagick (convert and MagicWand in PHP) so PIL won. 2008-03-07 17:27:00.298891 http://www.rkblog.rk.edu.pl/w/p/gdata-token-validation-problems/ http://www.rkblog.rk.edu.pl/w/p/gdata-token-validation-problems/ GData token validation problems To authenticate a web based application for use of Google services through GData we use AuthSub, which will generate a token. To get a token for multiple requests we can use session token. Ok, but how the token is validated ? For me it's an important question, as I have to make similar API. I've written a simple Django authentication decorator and two simple views using the session token: Google GData Authentication decorator - Google GData API can be used to retreive data from Google services... It can also be implemented on other sites (which I have on my ToDo list at my current job) helping in creation of backed applications. "Read" to see a simple view with custom decorator that authenticate user agains a GData provider (Google in this case). You can also read the auth docs.
What if I get a session token – and hardcode it in the code:
def index(request):
	"""
	Simple example - list google docs documents
	"""
	request.session['token'] = 'session token here'
	if 'token' in request.session:
		con = HTTPConnection("docs.google.com")
		con.putrequest('GET', '/feeds/documents/private/full/')
		con.putheader('Authorization', 'AuthSub token="%s"' % request.session['token'])
		con.endheaders()
		con.send('')
		r2 = con.getresponse()
		dane = r2.read()
		soup = BeautifulStoneSoup(dane)
		dane = soup.prettify()
		return render_to_response('a.html', {'dane':dane}, context_instance=RequestContext(request))
	else:
		return render_to_response('a.html', {'dane':'dupa'}, context_instance=RequestContext(request))
And call this view from a browser in which I'm not logged in to my Google account, or put this app on another server than my public localhost. Will it work? YES :) The token seems to be valid for different domains/IPs (you specify GET next when you request one-time-token at start...) and it isn't (it can't be?) validated if it's really me that uses the token (and not an evil server that harvest my contacts :)). I may be wrong, but it's not so super secure when a simple token may give someone read, and even write access to my data at GData enabled site.
2008-02-05 15:25:48.811330
http://www.rkblog.rk.edu.pl/w/p/comet-boom/ http://www.rkblog.rk.edu.pl/w/p/comet-boom/ Comet Boom Comet + Django tutorial got a lot of attention in the net - from django and ajax communities, reddit and many others. So it looks like I'll have to write more about this topic ;)
2007-12-28 18:46:53.396898
http://www.rkblog.rk.edu.pl/w/p/qscintilla2-and-pyqt4/ http://www.rkblog.rk.edu.pl/w/p/qscintilla2-and-pyqt4/ QScintilla2 and PyQT4 Adding widgets for programmers to PyQt4. 2007-10-12 01:20:52.625451 http://www.rkblog.rk.edu.pl/w/p/django/ http://www.rkblog.rk.edu.pl/w/p/django/ Django Django web framework related articles 2007-09-04 19:58:55.663352