I was deeply sad to hear of the untimely death of John Pinner.
I met John at PyCon UK a few years ago, and very quickly learnt a great respect for him as a man, a friend, a mentor.
I saw him but once a year at the annual PyCon UK conference, and yet he had a great effect on me; I can only imagine the huge void that will be left by his passing for those who knew him more closely.
RIP John. I’m glad you were part of my life.
For example, ‘15,99 EUR’
See whether you have the right locale installed.
$ locale -a
$ sudo apt-get install language-pack-es
$ sudo dpkg-reconfigure locales
And then in the code, you can do this
myprice = unicode(locale.atof(myprice))
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.
So I wrote one.
It’s a Work-in-Progress, but I’m using it for my developments, so its definitely usable. Comments, etc, very welcome – please use github for this.
This is a really useful article about “High-performance XML parsing in Python with lxml”.
But there’s one gotcha I’ve discovered with the fast_iter() method described therein. Can’t comment on that website without getting yet another developer ID, so I’ll describe the issue here and hope that Google picks it up.
The problem comes with nested tags with the same name.
<product>Some useful data</product>
As far as I can see, the internal “product” will be cleared before the external one is handled, leaving with you with an empty tag.
To import a module where you have the module name as a string and want to do it programmatically:
X = __import__(‘X’)
X is now a variable that can be used in your code:
e.g. getattr(X, method)
I wanted to start writing a Django app which was to allow a user to enter data in various tables, and then run a workflow process.
I liked the admin front-end but thought I needed to do something clever with generic views to replicate this in my own application.
So I asked this question on the django-users list
On 04/09/05, Rachel Willmer wrote:
> I want to use the generic view mechanism to add/change/delete but I
> don't want to have to write my own form template for each page.
> I'd like it to work just like the admin interface does. Is it
> possible/sensible to hook into the admin code which seems to use
> add_stage/change_stage to automatically generate the templates? Or is
> there a better way of doing this?
> Any pointers welcome...
Now I’ve read a bit more about it, the answer is of course to just use the admin interface. 🙂
django-admin.py includes a useful command “adminindex”, which will auto-generate a copy of the admin interface index page.
So generate that, and copy it into your template directory to over-ride the inbuilt one, as described in Tutorial2
Then you can modify that as you wish…
Hey presto, instant application front end that you can use as the basis for the new application…
In retrospect, this is obvious and documented in the Django tutorial. But at the time, I was thinking in terms of “admin” interface and “main” interface, and it slipped past me that I could in fact use the admin interface *as* the main interface…
That might not work too well for most web applications, but for my purposes, (a local single-user application), it will work just fine…
To help me get to grips with Django quickly, I created a search engine
of the documentation.
On the off-chance this is useful to others, I made it available at http://www.hobthross.com/docs/django/phpdig/search.php
(Sorry if this does not show up as a hyperlink, WordPress appears to be chewing that up and ignoring it)
I’ve just taken a look at Django for the first time, and am seriously impressed.
For a while now, I’ve been trying to find a way of using Python in websites, and haven’t found anything that works well enough – Zope, Cheetah, mod_python – all seem very difficult to get the simplest thing working…
But Django looks like the answer.
The guys behind Django have produced a very useful tutorial to help you get going with it, and the users mailing list seems very responsive…
Very impressed so far…