def test_register(self):
     def t(e):
         pass
     k = 'test:1'
     ZVent.register(k, t)
     assert ZVent.MAP.has_key(k)
     assert len(ZVent.MAP[k]) == 1
     assert ZVent.MAP[k][0] == t
    def test_register(self):
        def t(e):
            pass

        k = 'test:1'
        ZVent.register(k, t)
        assert ZVent.MAP.has_key(k)
        assert len(ZVent.MAP[k]) == 1
        assert ZVent.MAP[k][0] == t
    def test_publish(self):
        def t(e):
            data['foo'] = 'bar'

        data = {'foo': 'foo'}
        k = 'test:2'
        ZVent.register(k, t)
        ze = ZVent(ztype=k, data=data)
        ZVent.publish(ze)
        assert data['foo'] == 'bar'
    def test_publish(self):
        def t(e):
            data['foo'] = 'bar'

        data = {'foo':'foo'}
        k = 'test:2'
        ZVent.register(k, t)
        ze = ZVent(ztype=k, data=data)
        ZVent.publish(ze)
        assert data['foo'] == 'bar'
Пример #5
0
    The user event handlers are implemented on the class so 
    we don't really need much to see here. Basically we need to 
    do 3 steps:
        * First load the User object so that it is the current state
        * Save the event to the datastore
        * Apply it to update the current state
    """
    u = User()
    u.load(e.data['id'])
    u.save(e)
    u.apply(e)


# Maps the all events that the User class is handling
for k in User.apply_map.keys():
    ZVent.register(k, handle_user_event)


class Message(Storage):
    namespace = 'message'  # Base directory could be bucket or table name

    def __init__(self):
        Storage.__init__(self)

        self.id = None
        self.user_id = None
        self.text = None
        self.deleted = None

    def new(self, e):
        self.id = e.data['id']
Пример #6
0
    """
    The user event handlers are implemented on the class so 
    we don't really need much to see here. Basically we need to 
    do 3 steps:
        * First load the User object so that it is the current state
        * Save the event to the datastore
        * Apply it to update the current state
    """
    u = User()
    u.load(e.data['id'])
    u.save(e)
    u.apply(e)

# Maps the all events that the User class is handling
for k in User.apply_map.keys():
    ZVent.register(k, handle_user_event)




class Message(Storage):
    namespace = 'message' # Base directory could be bucket or table name
    
    def __init__(self):
        Storage.__init__(self)

        self.id = None
        self.user_id = None
        self.text = None
        self.deleted = None