RkBlog

Diamanda 2008-TEST-1.1 released

I've released a new version of Diamanda Application Set - 2008-TEST-1.1. It's a small update against 1.0 stable release. Most changes affected layout (new look, fixes in templates, CSS and JS files), but also more generic use of forum topics as comments systems. Also password change has been fixed to work with Django 1.0.*.

› Read more

Nginx and Cherokee wars

Admin asked me what's the best way to host a Django app. The answer is Nginx or Cherokee (if he likes something "new"). I've been playing with Cherokee a long time ago, before Cherokee Admin and other goodies. To refresh info about Django on Cherokee I've installed ver 0.9.4 and configured it to host a Django project (local copy of this site) with SCGI. I've compared this configuration with Nginx 0.6.32 running the same application with FastCGI.

Test was simple - hit the main page few times:
httperf --client=0/1 --server=localhost --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=5 --num-calls=100
Cherokee:
Total: connections 5 requests 500 replies 500 test-duration 46.861 s
CPU time [s]: user 2.51 system 17.27 (user 5.3% system 36.9% total 42.2%)
Nginx:
Total: connections 5 requests 500 replies 500 test-duration 48.677 s
CPU time [s]: user 2.53 system 16.15 (user 5.2% system 33.2% total 38.4%)

Results are nearly equal. For now I would choose Nginx, as it can be easily configured. With cherokee-admin I had some issues with saving config for round-robin balancer - so I'm waiting for the incoming next stable Cherokee release (with new features). Some more serious tests to come :)

› Read more

Fun with Google App Engine

I've made a small GAE application called PythonMore, which is currently a set of Google Custom Search Engines flavored for Python searches, and also for Django, Pylons, GAE and PyQt. I'm planning to add Google Code Search with GData.

› Read more

Password reset in Django 1.0

Resetting password changed in 1.0, and the documentation for this is missing. The basic way of using new views is to add this set to urlconf:

import django.contrib.auth.views
....
(r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
Default templates are in django/contrib/admin/templates/registration and can be used out of the box, but they have Admin Panel like look. You can set paths to your custom templates (copy & edit the original ones):
(r'^password_reset/$', 'django.contrib.auth.views.password_reset', {'template_name':'userpanel/password_reset_form.html', 'email_template_name':'userpanel/password_reset_email.html'}),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', {'template_name':'userpanel/password_reset_done.html'}),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name':'userpanel/password_reset_confirm.html'}),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete', {'template_name':'userpanel/password_reset_complete.html'}),
If you want to use those views wrapped in your own views, then you will get few NoReverseMatch: Reverse for 'yourapp.django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments... exceptions. You have to pass to the views also a post_reset_redirect argument with URLs to other password reset views:
  • password_reset - URL for password_reset_done view
  • password_reset_confirm - URL for password_reset_complete view
  • password_reset_email.html - You have add in some way URL to password_reset_confirm in URL tag:
    {% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}
    
Example:
def password_reset(request):
	"""
	django.contrib.auth.views.password_reset view (forgotten password)
	"""
	if not request.user.is_authenticated():
		return django.contrib.auth.views.password_reset(request,
                          template_name='userpanel/password_reset_form.html',
                          email_template_name= 'userpanel/password_reset_email.html',
                          post_reset_redirect='/user/password_reset/done/')
	else:
		return HttpResponseRedirect("/user/")
For the links in the email domain name from Sites app is used. If you change the domain in Admin Panel/Sites, then you will have to restart the server to see the changes in emails.

› Read more

Power in Google CSE - how to make Google Python search engine :)

Google has a public service called Custom Search Engine - CSE. It's not very popular - if you want google powered search for your site you use Google Ajax search or other services. Google CSE is much more complex, and it's hart to see the "cool part" until you get the dreamed result.

Google CSE allows you to tune the Google search results against some keywords, sites etc. If you want a search engine for Python frameworks then Rainhard Django or construction pylons aren't the things you look for...

› Read more

RkBlog main page Search RSS Contact