Skip to content

Commit 313111e

Browse files
authored
Merge pull request #19 from alexei/feature/set_dict_as_default_model
Set dict as default model class; close #17
2 parents 26c86cc + 3c0b48f commit 313111e

4 files changed

Lines changed: 7 additions & 15 deletions

File tree

adapter/adapter.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ class undefined:
1414
pass
1515

1616

17-
class Struct(object):
18-
def __init__(self, **data):
19-
self.__dict__.update(data)
20-
21-
def __eq__(self, other):
22-
return self.__dict__ == other.__dict__
23-
24-
2517
class BindingDict(collections.MutableMapping):
2618
def __init__(self, adapter):
2719
self.adapter = adapter
@@ -147,7 +139,7 @@ def get_fields(self):
147139

148140
def adapt(self, data=None):
149141
meta = getattr(self, 'Meta', None)
150-
model_cls = getattr(meta, 'model', Struct)
142+
model_cls = getattr(meta, 'model', dict)
151143
obj = model_cls()
152144
for field_name, field in self.fields.iteritems():
153145
value = field.get_attribute(data or self.data)

tests/inputs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from __future__ import unicode_literals
44
from __future__ import absolute_import
55

6-
from tests.utils import Thing
6+
from tests.utils import Struct
77

88

9-
class Customer(Thing):
9+
class Customer(Struct):
1010
pass

tests/outputs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
from __future__ import unicode_literals
44
from __future__ import absolute_import
55

6-
from tests.utils import Thing
6+
from tests.utils import Struct
77

88

9-
class Customer(Thing):
9+
class Customer(Struct):
1010
pass
1111

1212

13-
class Address(Thing):
13+
class Address(Struct):
1414
pass

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import unicode_literals
44

55

6-
class Thing(object):
6+
class Struct(object):
77
def __init__(self, **data):
88
self.__dict__.update(data)
99

0 commit comments

Comments
 (0)