From d9c39d3db908605b9de03bc33654cf24f7443d6d Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Thu, 17 Sep 2015 22:35:23 -0500 Subject: [PATCH] markov: better context/target creation ex handling --- dr_botzo/markov/lib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dr_botzo/markov/lib.py b/dr_botzo/markov/lib.py index 3b2d693..dfb9993 100644 --- a/dr_botzo/markov/lib.py +++ b/dr_botzo/markov/lib.py @@ -92,7 +92,6 @@ def get_or_create_target_context(target_name): # find the stuff, or create it try: target = MarkovTarget.objects.get(name=target_name) - return target.context except MarkovTarget.DoesNotExist: # we need to create a context and a target, and we have to make the context first # make a context --- lacking a good idea, just create one with this target name until configured otherwise @@ -100,6 +99,9 @@ def get_or_create_target_context(target_name): target, c = MarkovTarget.objects.get_or_create(name=target_name, context=context) return target.context + + try: + return target.context except MarkovContext.DoesNotExist: # make a context --- lacking a good idea, just create one with this target name until configured otherwise context, c = MarkovContext.objects.get_or_create(name=target_name)