On 05/27/11 - 10:06:50AM, Mark McLoughlin wrote:
If the caller loaded the template, let's avoid having this
method
reload it.
---
imagefactory/BuildDispatcher.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/imagefactory/BuildDispatcher.py b/imagefactory/BuildDispatcher.py
index e30e15e..e07cff9 100644
--- a/imagefactory/BuildDispatcher.py
+++ b/imagefactory/BuildDispatcher.py
@@ -29,7 +29,10 @@ class BuildDispatcher(object):
def builder_for_target_with_template(cls, target, template):
log = logging.getLogger('%s.%s' % (__name__, cls.__name__))
- template_object = Template(template)
+ if isinstance(template, Template):
+ template_object = template
+ else:
+ template_object = Template(template)
builder_class = MockBuilder.MockBuilder
if (target != "mock"): # If target is mock always run mock builder
regardless of template
Ah, I see. I think this is performance optimization so that this can be called
both from ImageFactory.py, where it creates a BuildAdaptor with a template
object, and imgfac.py, where it calls this class method directly with a
template string.
One of my pet-peeves of weakly-typed languages; I would much rather see this
take a single type (probably a template object), and push the problem up to
the caller. But this seems at least to make a minor improvement to the
situation.
ACK
--
Chris Lalancette