Replace user-input field with enforced value in Django form

I’m subclassing someone else’s form; I need to remove their input field and replace it with a fixed value. class MyForm(TheirForm): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) # remove unwanted field self.fields.pop('fixedfield') def clean(self, *args, **kwargs): cleaned_data = super(MyForm, self).clean(*args, **kwargs) # Restore field with fixed value cleaned_data['fixedfield'] = FIXEDVALUE return cleaned_data Simples…

Upgrading very old Ubuntu

Can’t find the upgrades because the ubuntu distribution is just too old? Change /etc/apt/sources.list to use old-releases.ubuntu.com

Review: "Instant RabbitMQ" by Andrew Keig

This is a review of the book “Instant RabbitMQ Messaging Application Development How-to” by Andrew Keig, in the “Instant” series (“Short, Fast, Focussed”) by Packt Pubiishing. Disclaimer: I was given this book for review by Packt Publishing. My opinions are, however, my own. http://www.packtpub.com/rabbitmq-messaging-application-development/book Currently on offer at £5.09, usual price £5.99 (Jun 2013) Live ebook prices are available at Luzme The book starts with “What can RabbitMQ do for you?

Testing HTTPS with openssl

` $ openssl s_client -connect localhost:443 CONNECTED(00000003) …lots of certificate-related stuff here… GET / HTTP/1.0 HTTP/1.1 200 OK Date: Mon, 04 Feb 2008 09:19:01 GMT Server: Apache/2.2.7 (Unix) mod_ssl/2.2.7 OpenSSL/0.9.7l DAV/2 mod_python/3.3.1 Python/2.5.1 Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT Accept-Ranges: bytes Content-Length: 44 Connection: close Content-Type: text/html It works! Connection closed by foreign host. ` Thanks to http://blog.yimingliu.com/ for posting this… http://blog.yimingliu.com/2008/02/04/testing-https-with-openssl/

Ubuntu Server upgrade

sudo apt-get install update-manager-core vi /etc/update-manager/release-upgrades and set “prompt=normal” sudo do-release-upgrade

Review: "Lean Analytics" by Alistair Croll, Benjamin Yoskovitz; O'Reilly Media

Alistair Croll & Benjamin Yoskovitz have written Lean Analytics for the entrepreneur who’s using the “Lean Startup” ideas of business model development. Lean Startup is big on data-driven decisions; “don’t guess - measure”. And then change your plan based on what you learnt. This book focuses on that measurement, how to choose the metric, how to measure it, how to use the results. The authors use many case studies to illustrate their experiences, which I found very useful.

Setting up django-behave

BDD
Install django-behave from pypi or github. Edit test_settings.py (or which settings file you use when running tests). Add this: INSTALLED_APPS += ('django-behave', ) TEST_RUNNER = 'django-behave.runner.DjangoBehave_Runner' Create a features dir, in the apps you want to test. If you then run test on that app, you should now see something like this: ` (ve)$ PYTHONPATH=. python proj/manage.py test author –settings=proj.test_settings E ERROR: runTest (django-behave.runner.DjangoBehaveTestCase) Traceback (most recent call last): File “…/ve/lib/python2.

django-behave

I like BDD. I like cucumber. I like python. I like django. I don’t like lettuce, a commonly-used python port of cucumber, when used with django. They’ve chosen the completely daft option to use your main database when testing. I’d forgotten this, so when I discovered I’d torched my production database just because I wanted to write a test, I decided to not touch lettuce again… And then I discovered behave, which works fine as a python BDD tool; except it doesn’t have an easy tie-up with django.