Skip to content

Commit

Permalink
really broken version of Model.update
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzure committed Jun 28, 2014
1 parent 34e9e28 commit 56e875e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions modelo/model/model.py
Expand Up @@ -184,5 +184,24 @@ def update(self, data):
:param data: update the model with this data
:type data: dict
"""
for (key, value) in iteritems(data):
pass
# get a dictionary of traits based on the class definition
traits = self.traits()

# process update data based on model traits
for (trait_name, trait) in iteritems(traits):
# skip traits that aren't going to be updated
if trait_name not in data.keys():
continue

# based on input to this function
given_value = data[trait_name]

# based on the existing value on the model
current_value = getattr(self, trait_name)

# use this to defer assignment on to self
deferred_value = None

# Set the deferred_value on to the current model at the appropriate
# trait key (trait_name).
setattr(self, trait_name, deferred_value)

0 comments on commit 56e875e

Please sign in to comment.