template_path attribute supported by Template class.
template_path attribute supported by Template class.

Right now, all classes must define implement templatePath method in order to define a template path. It should be possible to 'inject' that value to the constructor. It actually makes the code a little more reusable.

This is a temporary solution: the render method will look for the template path first by looking for template_path attribute. It it is not defined (or evaluates to None), it will call templatePath function.

However, it may be difficult to actually require that a path must be always passed to a constructor of a reusable template. Instead, in some cases, subclasses may also exist, but they will only invoke parent's __init__ and pass an approporiate path.

class ReusableTemplate(Template):

  def __init__(self, template_path, *args, **kwargs):
    # initialization

class ConcreteReusableTemplate(ReusableTemplate):

  def __init__(self, *args, **kwargs):
    super(ConcreteReusableTemplate, self).__init__('actual-path.html', *args, *kwargs)

It is relatively simple. We might go for a more sophisticated technique to curry arguments for constructors. The question is how clear can it be?

rhyolight/nupic.son,rhyolight/nupic.son,rhyolight/nupic.son