Celery: group, chain & chord: what happens on error?

Found this useful summary in Ask’s reply:

https://github.com/celery/celery/issues/1662

Group (runs in parallel): Error on one task does not stop the others

Chain (runs in serial): Error on one task halts the chain

Chord (group with callback): Error in group prevents callback from firing

Update: From Celery 3.0.14, this Chord behaviour is configurable. See CELERY_CHORD_PROPAGATES config option.

John Pinner RIP

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.

http://pyconuk.net/InMemoriam

 

Review: “Discover Meteor”,Tom Coleman & Sacha Greif

http://www.discovermeteor.com

Currently available at $39 and upwards (May 2014)

Check the current live price at Luzme

Meteor is a new web framework which promises near-real time data updates on the client.

If you’re planning to learn how to learn Meteor (which you should, it’s awesome!), you need this book “Discover Meteor”.

Continue reading Review: “Discover Meteor”,Tom Coleman & Sacha Greif

Handling European currencies

For example, ‘15,99 EUR’

See whether you have the right locale installed.

$ locale -a

If not

$ sudo apt-get install language-pack-es
$ sudo dpkg-reconfigure locales

And then in the code, you can do this

import locale
myprice = unicode(locale.atof(myprice))

Migrating from django-registration to django-allauth

I’ve been wanting to migrate away from django-registration for a while.

Yes, I know it’s been the default registration package since forever and I’ve used it happily for many years. But :

  • it’s no longer actively maintained
  • I want to do away with the email confirmation
  • I want to allow login using either email or username

So after a bit of googling, I decided to try out django-allauth, and I’ve just finished the migration.

Here’s some notes for anyone else thinking about doing the same.

I’ve got an existing system:

  • Django==1.5.1
  • django-registration==1.0

Note: I’m only setting up the ‘accounts’ side of the allauth package, I’ll leave the social-accounts for later.

So here’s what I did:

  1. Set up django-allauth as per their documentation at http://django-allauth.readthedocs.org/
  2. Removed the django-registration module from the settings
  3. I wanted to use my own templates rather than theirs, so I added an account subdirectory into my accounts/templates and copied theirs over from the package. I needed to ensure that their package was called later in INSTALLED_APPS to make sure my templates were found first.
  4. Mostly the templates just worked by changing my copy of their templates to use my base template, and other cosmetic changes
  5. One minor gotcha was that the django-registration login template uses id_username as the field, whereas django-allauth uses id_login (since it can be either username or email)
  6. By default, allauth will produce a message for every action. Their base template displays these. I decided I didn’t want them; so following their instructions at http://django-allauth.readthedocs.org/en/latest/index.html?highlight=templates#messagesI replaced the provided templates with blanks.
  7. I added a redirect url from the old django-registration /accounts/register to the new django-allauth /accounts/signup

That was it. Much easier than I expected.

Thanks!

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…

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?”, moves on to installation, and then runs through an example usage of an e-commerce shop, adding in more complexity through various examples.

All the code is written in Node.js; if you don’t already know this, you may find getting your head round the event-driven model used by Node.js to be a distraction from learning about RabbitMQ.

The installation section talks through setting up both RabbitMQ and the Node.js systems; also mentions the RabbitMQ CLI and web UI tools.

The examples run through the usages of all the various AMQP concepts of brokers, exchanges, queues and bindings. These concepts are the most complicated aspect of programming RabbitMQ in your system; I’d have appreciated more detail about when and why you would choose one kind of exchange over another; why you would use one kind of binding. But I appreciate that within the space constraints of the book, this may not have been possible.

The author finishes with an interesting last chapter “Go Forth and Multiply” of further topics for consideration, including a useful last section on architecture and performance choices.

In summary, I thought the book was good value for its price. I would read more by this author, and I would especially be interested in a larger or followup book containing more detail on the “why” part of using RabbitMQ, rather than the “how”; I think he would have a lot of useful material to share.

PLUS POINTS:

  • A concise run-through setting up and designing for a reliable, distributed system which used the RabbitMQ messaging system
  • As an existing RabbitMQ developer, I found it interesting and I learnt from it
  • It’s well written
  • Good value

MINUS POINTS:

  • The title is a bit of a mouthful, especially for a book in the “Instant” series (“Short, Fast, Focussed”)
  • The book description should mention its reliance on Node.js for all code examples
  • More detail needed on AMQP principles: exchanges, bindings, queues. When to choose which sort?