Example #1
0
    def get_next_event(self, session, timeout=None):
        """
        """
        event_queue_key = 'eventqueue:%s' % session.redis_key

        logger.debug('Waiting for event to be popped out of event queue: %s' %
                     event_queue_key)

        blob = self.redis.brpop([event_queue_key], timeout=timeout)

        logger.debug('Popping one event from the session event queue %s' %
                     event_queue_key)

        if not blob:
            return

        key, pack = blob
        event = GAPushEvent.from_dict(data=msgpack.unpackb(pack))
        resources = [
            GAResource(name=event.entity.rest_name, value=event.entity.id)
        ]
        request = GARequest(action=GARequest.ACTION_READ, resources=resources)
        context = GAContext(request=request, session=session)
        context.object = event.entity

        # operation_manager = GAOperationsController(context=context,
        #                                            logic_controller=self.core_controller.logic_controller,
        #                                            storage_controller=self.core_controller.storage_controller)
        # operation_manager.run()

        # if not context.has_errors:
        #     logger.debug('Returning one event to session %s' % session.redis_key)
        return event
Example #2
0
    def get_next_event(self, session, timeout=None):
        """
        """
        event_queue_key = 'eventqueue:%s' % session.redis_key

        logger.debug('Waiting for event to be popped out of event queue: %s' % event_queue_key)

        blob = self.redis.brpop([event_queue_key], timeout=timeout)

        logger.debug('Popping one event from the session event queue %s' % event_queue_key)

        if not blob:
            return

        key, pack = blob
        event = GAPushEvent.from_dict(data=msgpack.unpackb(pack))
        resources = [GAResource(name=event.entity.rest_name, value=event.entity.id)]
        request = GARequest(action=GARequest.ACTION_READ, resources=resources)
        context = GAContext(request=request, session=session)
        context.object = event.entity

        # operation_manager = GAOperationsController(context=context,
        #                                            logic_controller=self.core_controller.logic_controller,
        #                                            storage_controller=self.core_controller.storage_controller)
        # operation_manager.run()

        # if not context.has_errors:
        #     logger.debug('Returning one event to session %s' % session.redis_key)
        return event
Example #3
0
 def test_from_dict(self):
     """
     """
     data = {
         'entities': [{
             'description': None,
             'zipcode': None,
             'parentType': None,
             'lastUpdatedDate': None,
             'parentID': None,
             'owner': None,
             'creationDate': None,
             'ID': None,
             'name': 'enterprise1'
         }],
         'entityType':
         'enterprise',
         'type':
         'CREATE',
         'updateMechanism':
         'DEFAULT',
         'eventReceivedTime':
         None
     }
     GASDKLibrary().register_sdk('default', tstdk)
     event = GAPushEvent.from_dict(data)
     self.assertEqual(event.entity.name, 'enterprise1')
Example #4
0
 def test_from_dict(self):
     """
     """
     data = {'entities': [{'description': None, 'zipcode': None, 'parentType': None, 'lastUpdatedDate': None, 'parentID': None, 'owner': None, 'creationDate': None, 'ID': None, 'name': 'enterprise1'}], 'entityType': 'enterprise', 'type': 'CREATE', 'updateMechanism': 'DEFAULT', 'eventReceivedTime': None}
     GASDKLibrary().register_sdk('default', tstdk)
     event = GAPushEvent.from_dict(data)
     self.assertEqual(event.entity.name, 'enterprise1')