Commit cce105f4 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac565] Reorder the config_handler for readability

The closures are moved to the top of the function and commented. It'll
hopefully be more readable this way.
parent e5961a4c
...@@ -232,9 +232,9 @@ class BoB: ...@@ -232,9 +232,9 @@ class BoB:
# If this is initial update, don't do anything now, leave it to startup # If this is initial update, don't do anything now, leave it to startup
if not self.runnable: if not self.runnable:
return return
if self.verbose: # Now we declare few functions used only internally here. Besides the
sys.stdout.write("[bind10] Handling new configuration: " + # benefit of not polluting the name space, they are closures, so we
str(new_config) + "\n") # don't need to pass some variables
def start_stop(name, started, start, stop): def start_stop(name, started, start, stop):
if not'start_' + name in new_config: if not'start_' + name in new_config:
return return
...@@ -246,14 +246,14 @@ class BoB: ...@@ -246,14 +246,14 @@ class BoB:
start() start()
else: else:
stop() stop()
# These four functions are passed to start_stop (smells like functional
# programming little bit)
def resolver_on(): def resolver_on():
self.start_resolver(self.c_channel_env) self.start_resolver(self.c_channel_env)
self.started_resolver_family = True self.started_resolver_family = True
def resolver_off(): def resolver_off():
self.stop_resolver() self.stop_resolver()
self.started_resolver_family = False self.started_resolver_family = False
start_stop('resolver', self.started_resolver_family, resolver_on,
resolver_off)
def auth_on(): def auth_on():
self.start_auth(self.c_channel_env) self.start_auth(self.c_channel_env)
self.start_xfrout(self.c_channel_env) self.start_xfrout(self.c_channel_env)
...@@ -266,11 +266,17 @@ class BoB: ...@@ -266,11 +266,17 @@ class BoB:
self.stop_xfrout() self.stop_xfrout()
self.stop_auth() self.stop_auth()
self.started_auth_family = False self.started_auth_family = False
# The real code of the config handler function follows here
if self.verbose:
sys.stdout.write("[bind10] Handling new configuration: " +
str(new_config) + "\n")
start_stop('resolver', self.started_resolver_family, resolver_on,
resolver_off)
start_stop('auth', self.started_auth_family, auth_on, auth_off) start_stop('auth', self.started_auth_family, auth_on, auth_off)
answer = isc.config.ccsession.create_answer(0) answer = isc.config.ccsession.create_answer(0)
return answer return answer
# TODO
def command_handler(self, command, args): def command_handler(self, command, args):
if self.verbose: if self.verbose:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment