'Put an email message on the queue.
:param Participant to: the participant to send the email message to
:param unicode template: the name of the template to use when rendering
the email, corresponding to a filename in ``emails/`` without the
file extension
:param bool _user_initiated: user-initiated emails are throttled;
system-initiated messages don\'t count against throttling
:param dict context: the values to use when rendering the template
:raise Throttled: if the participant already has a few messages in the
queue (that they put there); the specific number is tunable with
the ``EMAIL_QUEUE_ALLOW_UP_TO`` envvar.
:returns: ``None``'

def put(self, to, template, _user_initiated=True, **context):

    with self.db.get_cursor() as cursor:
        cursor.run(u'\n                                                                INSERT    INTO    email_queue\n                                                                                                                (participant,    spt_name,    context,    user_initiated)\n                                                                                    VALUES    (%s,    %s,    %s,    %s)\n                                                ', (to.id, template, pickle.dumps(context), _user_initiated))
        if _user_initiated:
            n = cursor.one(u'SELECT    count(*)    FROM    email_queue    WHERE    participant=%s    AND    user_initiated', (to.id,))
            if (n > self.allow_up_to):
                raise Throttled()
