mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-10 00:50:04 +08:00
Adds an init to protocol.Event to enable setting of initial values.
So that an Event can use an initial dict to set all values,
instead of needing to set initial values one by one.
i.e. enables:
```
foo = Event({'bar': 1, 'baz': 2})
```
in favor of:
```
foo = Event()
foo.bar = 1
foo.baz = 2
```
This commit is contained in:
@@ -31,6 +31,10 @@ DATASOURCE_TYPE = Enum(
|
||||
|
||||
class Event(object):
|
||||
|
||||
def __init__(self, initial_values=None):
|
||||
if initial_values:
|
||||
self.__dict__ = initial_values
|
||||
|
||||
def __getitem__(self, name):
|
||||
return getattr(self, name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user