old_contents: # :coding: utf-8
  # :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
  # :license: See LICENSE.txt.
  
  from .template import Template
  
  
new_contents: # :coding: utf-8
  # :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
  # :license: See LICENSE.txt.
  
  import os
  import uuid
  import imp
  
  from .template import Template
  
  
  def discover_templates(paths=None, recursive=True):
      '''Search *paths* for mount points and load templates from them.
  
      *paths* should be a list of filesystem paths to search for mount points.
      If not specified will try to use value from environment variable
      :envvar:`LUCIDITY_TEMPLATE_PATH`.
  
      A mount point is a Python file that defines a 'register' function. The
      function should return a list of instantiated
      :py:class:`~lucidity.template.Template` objects.
  
      If *recursive* is True (the default) then all directories under a path
      will also be searched.
  
      '''
      templates = []
  
      if paths is None:
          paths = os.environ.get('LUCIDITY_TEMPLATE_PATH', '').split(os.pathsep)
  
      for path in paths:
          for base, directories, filenames in os.walk(path):
              for filename in filenames:
                  _, extension = os.path.splitext(filename)
                  if extension != '.py':
                      continue
  
                  module_path = os.path.join(base, filename)
                  module_name = uuid.uuid4().hex
                  module = imp.load_source(module_name, module_path)
                  try:
                      registered = module.register()
                  except AttributeError:
                      pass
                  else:
                      if registered:
                          templates.extend(registered)
  
              if not recursive:
                  del directories[:]
  
      return templates
  
  
subject: Add helper method to load templates from disk.