Changes between Version 2 and Version 3 of Events


Ignore:
Timestamp:
12/09/14 11:18:17 (11 years ago)
Author:
mschenk
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Events

    v2 v3  
    103103channel.basic_publish(
    104104  exchange='extensionschoolevents',
    105   routing_key='mail.sending',
     105  routing_key='learner.add',
    106106  body=jsonpickle.encode(message),
    107107  properties=pika.BasicProperties(delivery_mode=2),
    108108)
    109109}}}
     110
     111#### Update ####
     112
     113This event must be sent when a new learner has registered. At this moment the learner MUST also have provided a password for his registration.
     114
     115The routing key for this event is '''learner.update'''
     116
     117The body of a learner.add event consists of a JSON-encoded dictionary of the following object:
     118{{{
     119{
     120  'learner': {
     121    'id': 15,
     122    'email': 'a.g.degroot@hotmail.com',
     123    'userlevel': 1,
     124    'newslettersubscription': false,
     125    'surname': 'Groot',
     126    'firstname': 'Anne',
     127    'nameprefix': 'de',
     128    'initials': 'A.G.',
     129    'gender': 'Female',         
     130  }
     131  'password': 'plaintext password for this learner'
     132}
     133}}}
     134
     135The 'learner' key holds an encoding of the django-object from learners.models
     136
     137The 'password' key is optional and should only be filled in case of a password change.
     138
     139Example of a '''learner.update''' event:
     140
     141
     142{{{
     143#!py
     144import pika
     145import jsonpickle
     146
     147credentials = pika.PlainCredentials(SETTINGS.queueuser, SETTINGS.queuepassword)
     148connection = pika.BlockingConnection(pika.ConnectionParameters(
     149    host=SETTINGS.queuehost,credentials=credentials))
     150channel = connection.channel()
     151learner = learners.models.Learner.objects.get(id=learnerid)
     152message = {
     153  'learners': learner,
     154  'password': learnerpassword,
     155}
     156channel.basic_publish(
     157  exchange='extensionschoolevents',
     158  routing_key='learner.update',
     159  body=jsonpickle.encode(message),
     160  properties=pika.BasicProperties(delivery_mode=2),
     161)
     162}}}