Skip to content

Commit

Permalink
don't serialize kwargs in state transition log when they're not JSON …
Browse files Browse the repository at this point in the history
…serializable
  • Loading branch information
Jonathan Slenders committed May 30, 2012
1 parent 62f39ae commit b018f64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion states2/model_methods.py
Expand Up @@ -148,12 +148,19 @@ def make_transition(si_self, transition, user=None, **kwargs):

# Start transition log
if _state_log_model:
# Try to serialize kwargs, for the log. Save null
# when it's not serializable.
try:
serialized_kwargs = json.dumps(kwargs)
except TypeError:
serialized_kwargs = None

transition_log = _state_log_model.objects.create(
on=self,
from_state=getattr(self, field),
to_state=t.to_state,
user=user,
serialized_kwargs=json.dumps(kwargs)
serialized_kwargs=serialized_kwargs,
)

# Test transition (access/execution validation)
Expand Down

0 comments on commit b018f64

Please sign in to comment.