markov: better context/target creation ex handling
This commit is contained in:
parent
4f17234a0a
commit
d9c39d3db9
|
@ -92,7 +92,6 @@ def get_or_create_target_context(target_name):
|
||||||
# find the stuff, or create it
|
# find the stuff, or create it
|
||||||
try:
|
try:
|
||||||
target = MarkovTarget.objects.get(name=target_name)
|
target = MarkovTarget.objects.get(name=target_name)
|
||||||
return target.context
|
|
||||||
except MarkovTarget.DoesNotExist:
|
except MarkovTarget.DoesNotExist:
|
||||||
# we need to create a context and a target, and we have to make the context first
|
# 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
|
# 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)
|
target, c = MarkovTarget.objects.get_or_create(name=target_name, context=context)
|
||||||
|
|
||||||
return target.context
|
return target.context
|
||||||
|
|
||||||
|
try:
|
||||||
|
return target.context
|
||||||
except MarkovContext.DoesNotExist:
|
except MarkovContext.DoesNotExist:
|
||||||
# make a context --- lacking a good idea, just create one with this target name until configured otherwise
|
# 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)
|
context, c = MarkovContext.objects.get_or_create(name=target_name)
|
||||||
|
|
Loading…
Reference in New Issue