"""
Functions to initialize environment settings.
"""

def setup():
    """Adds <project_root>/lib to the python path.  
    
    Starts in current working directory and traverses up until app.yaml is found.
    Assumes app.yaml is in project root.
    """
    import os, sys
    start_path = os.path.abspath('.')
    search_path = start_path
    while search_path:
        app_yaml_path = os.path.join(search_path, 'app.yaml')
        if os.path.exists(app_yaml_path):
            lib_path = os.path.join(search_path, 'lib')
            if lib_path not in sys.path:
                sys.path.insert(0, lib_path)
            break
        search_path, last_dir = os.path.split(search_path)
    else:
        raise os.error('app.yaml not found for env_setup.setup().%sSearch started in: %s'% (os.linesep, start_path))

def setup_django(settings='settings', version='1.2', ):
    """
    Sets up the django libraries.

    :param settings: The name of the settings file. Default: ``'settings'``.
    :param version: The django version to set up. Default: ``'1.2'``.
    """
    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = settings
    from google.appengine.dist import use_library
    use_library('django', version)
    from django.conf import settings
    _ = settings.TEMPLATE_DIRS

@@ -475,24 +475,34 @@
         lib_
+substrate_
 path = os.pa
@@ -527,16 +527,29 @@
 h, 'lib'
+, 'substrate'
 )%0A      
@@ -557,24 +557,34 @@
      if lib_
+substrate_
 path not in 
@@ -632,16 +632,187 @@
 (0, lib_
+substrate_path)%0A            lib_usr_path = os.path.join(search_path, 'lib', 'usr')%0A            if lib_usr_path not in sys.path:%0A                sys.path.insert(0, lib_usr_
 path)%0A  

Add new paths to env_setup (doh!)