user-avatar
Today is Saturday
February 4, 2012

Category: Django

January 8, 2012

DjangoRedmineAdmin 1.0 released

by Thomas Capricelli — Categories: Admin, Django — Tags: , Leave a comment

I recently needed (again) to ‘browse’ a redmine database, and I used my DjangoRedmineAdmin application to do so. I took this opportunity to update the code and doing some more tests/fixes. As a result I decided to tag this as 1.0.

The main modifications are:

  • updated to comply with current redmine version (1.2.1 and 1.3.0)
  • updated to use Django 1.3 instead of Django 1.2, which is now deprecated.
  • added a lot of new improvements to the admin pages, such as displaying a list of related model instead of the raw id, or presenting data in a cleaner way.
  • it now works now with mysql too. Previous version would have problems handling boolean fields on a mysql database. We need to blame ruby ORB here, which actually handle boolean differently depending on the db backend. Sqlite3 was and is still supported.

You can clone the repository or download tarballs from the mercurial source page.

The wiki has more information / documentation.

December 2, 2011

Celery init scripts for Gentoo

by Thomas Capricelli — Categories: Admin, Django, Gentoo3 Comments

I’m using django-celery on a project. The only difficult part was that gentoo ebuilds would not provide init scripts. It might be that some ebuilds in some obscure overlay provides those, but this was far too far away from the mainstream portage tree for me.

Yes, the documentation about celery has some scripts using supervisord, but I still like the init.d kind of scripts, so here they are.

The first one is /etc/init.d/celeryd, used for every worker.

#!/sbin/runscript
# Copyright 2011 Sylphide Consulting / Thomas Capricelli

# this file should be installed as /etc/init.d/celeryd

# doc:
# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4#doc_chap4

# configuration is taken from /etc/conf.d/celeryd
# You NEED to configure CELERYD_APP_DIR
# You MAY configure CELERYD_USER, CELERYD_GROUP, CELERYD_CONCURRENCY

depend() {
    need net

}

checkconfig() {
    if [ -z "${CELERYD_APP_DIR}" ] ; then
        eerror "Please configure /etc/conf.d/celeryd"
        return 1
    fi
}

start() {
    concurrency=${CELERYD_CONCURRENCY:-1}
    options="--workdir=${CELERYD_APP_DIR} --pidfile=/var/run/celeryd.pid --logfile=/var/log/celeryd.log --concurrency=${concurrency} --events"
    if [ -n "${CELERYD_USER}" ] ; then
        options="${options} --uid=${CELERYD_USER}"
    fi
    if [ -n "${CELERYD_GROUP}" ] ; then
        options="${options} --gid=${CELERYD_GROUP}"
    fi
    ebegin "Starting celeryd"
    start-stop-daemon \
        --chdir ${CELERYD_APP_DIR} \
        --start \
        --pidfile /var/run/celeryd.pid \
        --exec ${CELERYD_APP_DIR}/manage.py -- \
        celeryd_detach ${options}
    eend $?
}

stop() {
    ebegin "Stopping celeryd"
    start-stop-daemon --stop --pidfile=/var/run/celeryd.pid
    eend $?
}

The second one is /etc/init.d/celerybeat, for the scheduler. I’m using redis, but if you dont, just comment out the after redis line.

#!/sbin/runscript
# Copyright 2011 Sylphide Consulting / Thomas Capricelli

# this file should be installed as /etc/init.d/celerybeat

# doc:
# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4#doc_chap4

# configuration is taken from /etc/conf.d/celerybeat
# You NEED to configure CELERYBEAT_APP_DIR
# You MAY configure CELERYBEAT_USER, CELERYBEAT_GROUP

depend() {
    need net
    after redis
}

checkconfig() {
    if [ -z "${CELERYBEAT_APP_DIR}" ] ; then
        eerror "Please configure /etc/conf.d/celerybeat"
        return 1
    fi
}

start() {
    options="--workdir=${CELERYBEAT_APP_DIR} --pidfile=/var/run/celerybeat.pid --logfile=/var/log/celerybeat.log --detach"
    if [ -n "${CELERYBEAT_USER}" ] ; then
        options="${options} --uid=${CELERYBEAT_USER}"
    fi
    if [ -n "${CELERYBEAT_GROUP}" ] ; then
        options="${options} --gid=${CELERYBEAT_GROUP}"
    fi
    ebegin "Starting celerybeat"
    start-stop-daemon \
        --chdir ${CELERYBEAT_APP_DIR} \
        --start \
        --pidfile /var/run/celerybeat.pid \
        --exec ${CELERYBEAT_APP_DIR}/manage.py -- \
        celerybeat ${options}
    eend $?
}   

stop() {
    ebegin "Stopping celerybeat"
    start-stop-daemon --stop --pidfile=/var/run/celerybeat.pid
    eend $?
}

April 7, 2011

Mercurial mirror for Django stable branch 1.3

by Thomas Capricelli — Categories: Admin, Django — Tags: , , 4 Comments

Django recently released the 1.3 version, and as such a new ‘stable’ branch was created in subversion. As I did for the 1.2 branch, there’s now a mercurial mirror, following the 1.3 branch. It is updated every (european) night.

The 1.2 mirror is not removed, it is still running and maintained.

The url for this new mirror is http://bitbucket.freehackers.org/django-1.3-mirror

September 9, 2010

New mercurial mirror for Django stable branch 1.2

by Thomas Capricelli — Categories: Admin, Django — Tags: , , Leave a comment

I have tried for the last few years to use one of the mercurial mirrors on bitbucket.org to follow Django. Since far before Django 1.0 was released, I was following trunk, but I have switched to the stable branch around Django 1.1.

I’ve always had problems with the mirrors on bitbucket, they seem mostly unmaintained. There are several of them, mostly because they create a new one when one fails… so you have to guess which one is the ‘current’ one. As of today, the one I’m using has not been updated for one month,… and I would like to merge the recent important security fix to my own Django branch (that I use for my Consulting jobs).

So I decided to create, and maintain, a mercurial mirror of Django stable, which is 1.2 currently. I publish it on

http://bitbucket.freehackers.org/django-1.2-mirror

and it is updated nightly.

The history/log only starts at the 1.2 branching in svn, which allows to keep the mirror size very small. For comparison, the “.hg” directory was worth 130Mb using the mirror provided by bitbucket staff, and this one is 17M.

April 3, 2010

Announcing colibri 1.0 alpha1, a mailing list manager with a django based web interface

by Thomas Capricelli — Categories: Admin, Django, Gentoo — Tags: , 3 Comments

It has been more than one year now that I’m running my own mailing list software here at freehackers, and I think it is now time to release a first preview of it. Let me introduce Colibri 1.0 alpha1

Colibri is a free software (GPL), based on python and Django.

myaccount2

It’s not feature complete, but it actually forward mails. From the web interface, people can (un)subscribe and configure their accounts.

The webpage, with screenshots, download, bugtracker and some documentation is at http://labs.freehackers.org/projects/colibri/wiki

I use mercurial for source control, and the repository is available both for cloning and browsing at http://sources.freehackers.org/Colibri/

November 2, 2008

Activities gallery

by Thomas Capricelli — Categories: Admin, Django, Gentoo, KDE, Linux kernel — Tags: , , , , , , , 3 Comments

While developing my recently released activity mercurial extension (and here too), I did a lot of tests on some quite famous/big projects. I’ve found the results to be quite interesting and decided to put up this gallery. Are you interested in the history of commits for kde, linux, django, portage(software), and others?

warning : this is just for fun (copyright Linus Torvalds), I’m perfectly aware that the number of commits is a very bad indicator for development.

The gallery : http://labs.freehackers.org/projects/hgactivity/wiki/Gallery

September 27, 2008

Django browser for Redmine database

by Thomas Capricelli — Categories: Admin, Django — Tags: , 6 Comments

Do you know redmine ? This is, to my knowledge, the best project manager you could ever find out there. I like to describe it as ‘trac done well‘. It has only one, big, ugly, fat inconvenient for me : it is written on top of ruby on rails. I could tell you how slow it is (true), or how many security flaws are found everyday in the ruby/rails world. But the real reason I’m actually really concerned about ruby/rails is that I don’t know ruby. When I look at the code I don’t understand anything, and I can’t change something to ‘suit my needs’, as is so common in Free Software.

I wish it was written in Django.

Well, anyway, I spent some times today to create a small Django application in order to display stuff from the redmine database. For this, I’ve used the wonderful “inspectdb” feature of Django, which access a database and creates the (Django) models required to access it.

Then, I had to ‘adapt’ those models and to create an admin.py file so that I could browse (and even modify) the database from django.

Adapting meant:

  • removing all the “id” field, they are automatically created by Django and it seems rails use the very same name (“id”) so this is compatible.
  • Change the “obvious” references to other model from IntegerField to ForeignKey
  • Some models reference themselves, you need to use a ForeignKey to ‘self’ (including quotes) to do that.
  • add some __unicode__(self) for the most important/obvious models

The admin works was basically about:

  • Creates Admin objects for all models (thanks vim’s macro!)
  • add list_display / list_filter args for the most important ones

And the remaining problem is :

  • It seems Boolean from ruby/rails have the values ‘t’/'f’ while those from django have 1/0 (fixed since then)

Mandatory screenshot (corresponding to the public stuff from http://labs.freehackers.org):

Example of djangoredmineadmin in use

Link to the project homepage

© 2012 Thomas Capricelli All rights reserved - Wallow theme v0.46.5 by ([][]) TwoBeers - Powered by WordPress - Have fun!