コード例 #1
0
def add_event(request):
    # Ideally, the server should know about valid events and be able to present a list
    # and schema for each kind. Then it validates when the human submits an event.
    # For now, we just hardcode this
    try:
        event_json = json.loads(request.POST["event"])
        recipient = request.POST["recipient"]

        session = DBSession()

        # Add the event and flush it so we can get a reliable primary key
        event = Event.from_json(event_json)
        session.add(event)
        session.flush()

        # Create a new command
        command = PullQueueEvent(event, recipient)
        session.add(command)
        session.flush()

        transaction.commit()

        return {u"status": u"ok"}

    except Exception, e:
        session.rollback()
        return {u"error": unicode(e)}
コード例 #2
0
ファイル: views.py プロジェクト: pfoley/yot
def add_event(request):
   # Ideally, the server should know about valid events and be able to present a list
   # and schema for each kind. Then it validates when the human submits an event.
   # For now, we just hardcode this
   try:
      event_json = json.loads(request.POST["event"])
      recipient = request.POST["recipient"]

      session = DBSession()     

      # Add the event and flush it so we can get a reliable primary key
      event = Event.from_json(event_json)      
      session.add(event)  
      session.flush()

      # Create a new command
      command = PullQueueEvent(event, recipient)
      session.add(command)
      session.flush()

      transaction.commit()

      return {u"status" : u"ok"}

   except Exception, e:
      session.rollback()
      return {u"error": unicode(e)}
コード例 #3
0
def client_post(request):
    try:
        event_json = json.loads(request.POST["event"])
        event = Event.from_json(event_json)

        session = DBSession()
        session.add(event)

        session.flush()

        # Run any triggers for this event
        triggers.trigger(event.type, event)

        transaction.commit()

        return {u"status": u"ok"}

    except KeyError, e:
        return {u"param_missing": unicode(e)}
コード例 #4
0
ファイル: views.py プロジェクト: pfoley/yot
def client_post(request):
   try:
      event_json = json.loads(request.POST["event"])
      event = Event.from_json(event_json)

      session = DBSession()
      session.add(event)

      session.flush()

      # Run any triggers for this event
      triggers.trigger(event.type, event)

      transaction.commit()

      return {u"status" : u"ok"}
   
   except KeyError, e:
      return {u"param_missing" : unicode(e)}