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:
Eddie Hebert
2013-01-01 22:59:25 -05:00
parent a25590b0a1
commit d1784b26c3
+4
View File
@@ -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)