26/07/2010
sudo aptitude install python-wxtools
sudo easy_install runsnakerun
sudo aptitude install python-profiler
(If you are using Debian check this out : http://www.cherrypy.org/wiki/ProfilingOnDebian
)
run with:
python -m cProfile -o barbazzr.profile barbazzr.py
Check out the output with:
runsnake name.profilepython -m cProfile -o barbazzr.profile barbazzr.py
17/02/2010
Are you updating an old Django project to use Django 1.2, and getting this error message when you try to login to the Django admin page?
403 Forbidden
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF cookie not set.
Then you need to add ‘django.middleware.csrf.CsrfViewMiddleware’, and ‘django.middleware.csrf.CsrfResponseMiddleware’ your settings.py file. Mine looks like this:
MIDDLEWARE_CLASSES = (
‘django.middleware.common.CommonMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.middleware.csrf.CsrfResponseMiddleware’,
)
Thanks to the Django docs http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it
19/06/2009
The builtin inspect module makes it easy to find out information about the modules you are loading. Just ‘import inspect’ and use inspect.getfile
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import inspect
>>> import random
>>> inspect.getfile(random)
‘c:\\Python26\\lib\\random.pyc’