# Path: tiddlywebplugins/tiddlyspace/config.py
# PACKAGE_NAME = 'tiddlywebplugins.tiddlyspace'
# TIDDLYWIKI_BETA = resource_filename(PACKAGE_NAME, 'resources/beta.html')
# TIDDLYWIKI_EXTERNAL_BETA = resource_filename(PACKAGE_NAME,
#         'resources/external_beta.html')
# TIDDLYWIKI_EXTERNAL = resource_filename(PACKAGE_NAME,
#         'resources/external.html')
# 
# Path: tiddlywebplugins/tiddlyspace/www.py
# def establish_www(config):
#     """
#     Set up the routes and WSGI Middleware used by TiddlySpace.
#     """
#     replace_handler(config['selector'], '/', dict(GET=home))
#     config['selector'].add('/_safe', GET=safe_mode, POST=safe_mode)
#     add_spaces_routes(config['selector'])
#     add_profile_routes(config['selector'])
#     config['selector'].add('/users/{username}/identities',
#             GET=get_identities)
#     config['selector'].add('/tiddlers[.{format}]', GET=get_space_tiddlers)
#     config['selector'].add('/{tiddler_name:segment}', GET=friendly_uri)
# 
#     if ControlView not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(Negotiate) + 1, ControlView)
# 
#     if DropPrivs not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(ControlView) + 1, DropPrivs)
# 
#     if CSRFProtector not in config['server_request_filters']:
#         config['server_request_filters'].append(CSRFProtector)
# 
#     if ServerSettings not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(ControlView), ServerSettings)
# 
#     if AllowOrigin not in config['server_response_filters']:
#         config['server_response_filters'].insert(
#                 config['server_response_filters'].
#                 index(PrettyHTTPExceptor) + 1, AllowOrigin)


from tiddlyweb.util import merge_config
from tiddlywebplugins.utils import remove_handler
from tiddlywebplugins.tiddlyspace.commands import establish_commands
from tiddlywebplugins.tiddlyspace.config import config as space_config
from tiddlywebplugins.tiddlyspace.www import establish_www
        from werkzeug.contrib.profiler import ProfilerMiddleware
    import tiddlywebplugins.whoosher
    import tiddlywebwiki
    import tiddlywebplugins.logout
    import tiddlywebplugins.virtualhosting  # calling init not required
    import tiddlywebplugins.magicuser
    import tiddlywebplugins.socialusers
    import tiddlywebplugins.mselect
    import tiddlywebplugins.oom
    import tiddlywebplugins.cookiedomain
    import tiddlywebplugins.tiddlyspace.validator
    import tiddlywebplugins.prettyerror
    import tiddlywebplugins.hashmaker
    import tiddlywebplugins.form
    import tiddlywebplugins.reflector
    import tiddlywebplugins.privateer
    import tiddlywebplugins.relativetime
    import tiddlywebplugins.jsonp
        import tiddlywebplugins.dispatcher
        import tiddlywebplugins.dispatcher.listener
    if config.get('use_dispatcher', False):

    establish_commands(config)

    merge_config(config, space_config)

    if config.get('tiddlyspace.enable_profile', False):
        config['server_request_filters'].insert(0, ProfilerMiddleware)

    tiddlywebplugins.whoosher.init(config)
    tiddlywebwiki.init(config)
    tiddlywebplugins.logout.init(config)
    tiddlywebplugins.magicuser.init(config)
    tiddlywebplugins.socialusers.init(config)
    tiddlywebplugins.mselect.init(config)
    tiddlywebplugins.oom.init(config)
    tiddlywebplugins.cookiedomain.init(config)
    tiddlywebplugins.prettyerror.init(config)
    tiddlywebplugins.hashmaker.init(config)
    tiddlywebplugins.form.init(config)
    tiddlywebplugins.reflector.init(config)
    tiddlywebplugins.privateer.init(config)
    tiddlywebplugins.jsonp.init(config)

    if config.get('use_dispatcher', False):
        tiddlywebplugins.dispatcher.init(config)
        tiddlywebplugins.dispatcher.listener.init(config)

    # reset config _again_ to deal with any adjustments from the
    # above init calls

# Path: tiddlywebplugins/tiddlyspace/config.py
# PACKAGE_NAME = 'tiddlywebplugins.tiddlyspace'
# TIDDLYWIKI_BETA = resource_filename(PACKAGE_NAME, 'resources/beta.html')
# TIDDLYWIKI_EXTERNAL_BETA = resource_filename(PACKAGE_NAME,
#         'resources/external_beta.html')
# TIDDLYWIKI_EXTERNAL = resource_filename(PACKAGE_NAME,
#         'resources/external.html')
# 
# Path: tiddlywebplugins/tiddlyspace/www.py
# def establish_www(config):
#     """
#     Set up the routes and WSGI Middleware used by TiddlySpace.
#     """
#     replace_handler(config['selector'], '/', dict(GET=home))
#     config['selector'].add('/_safe', GET=safe_mode, POST=safe_mode)
#     add_spaces_routes(config['selector'])
#     add_profile_routes(config['selector'])
#     config['selector'].add('/users/{username}/identities',
#             GET=get_identities)
#     config['selector'].add('/tiddlers[.{format}]', GET=get_space_tiddlers)
#     config['selector'].add('/{tiddler_name:segment}', GET=friendly_uri)
# 
#     if ControlView not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(Negotiate) + 1, ControlView)
# 
#     if DropPrivs not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(ControlView) + 1, DropPrivs)
# 
#     if CSRFProtector not in config['server_request_filters']:
#         config['server_request_filters'].append(CSRFProtector)
# 
#     if ServerSettings not in config['server_request_filters']:
#         config['server_request_filters'].insert(
#                 config['server_request_filters'].
#                 index(ControlView), ServerSettings)
# 
#     if AllowOrigin not in config['server_response_filters']:
#         config['server_response_filters'].insert(
#                 config['server_response_filters'].
#                 index(PrettyHTTPExceptor) + 1, AllowOrigin)


# Path: tiddlywebplugins/tiddlyspace/plugin.py
from tiddlyweb.util import merge_config
from tiddlywebplugins.utils import remove_handler
from tiddlywebplugins.tiddlyspace.commands import establish_commands
from tiddlywebplugins.tiddlyspace.config import config as space_config
from tiddlywebplugins.tiddlyspace.www import establish_www
        from werkzeug.contrib.profiler import ProfilerMiddleware
    import tiddlywebplugins.whoosher
    import tiddlywebwiki
    import tiddlywebplugins.logout
    import tiddlywebplugins.virtualhosting  # calling init not required
    import tiddlywebplugins.magicuser
    import tiddlywebplugins.socialusers
    import tiddlywebplugins.mselect
    import tiddlywebplugins.oom
    import tiddlywebplugins.cookiedomain
    import tiddlywebplugins.tiddlyspace.validator
    import tiddlywebplugins.prettyerror
    import tiddlywebplugins.hashmaker
    import tiddlywebplugins.form
    import tiddlywebplugins.reflector
    import tiddlywebplugins.privateer
    import tiddlywebplugins.relativetime
    import tiddlywebplugins.jsonp
        import tiddlywebplugins.dispatcher
        import tiddlywebplugins.dispatcher.listener

    if config.get('use_dispatcher', False):

    establish_commands(config)

    merge_config(config, space_config)

    if config.get('tiddlyspace.enable_profile', False):
        config['server_request_filters'].insert(0, ProfilerMiddleware)

    tiddlywebplugins.whoosher.init(config)
    tiddlywebwiki.init(config)
    tiddlywebplugins.logout.init(config)
    tiddlywebplugins.magicuser.init(config)
    tiddlywebplugins.socialusers.init(config)
    tiddlywebplugins.mselect.init(config)
    tiddlywebplugins.oom.init(config)
    tiddlywebplugins.cookiedomain.init(config)
    tiddlywebplugins.prettyerror.init(config)
    tiddlywebplugins.hashmaker.init(config)
    tiddlywebplugins.form.init(config)
    tiddlywebplugins.reflector.init(config)
    tiddlywebplugins.privateer.init(config)
    tiddlywebplugins.jsonp.init(config)

    if config.get('use_dispatcher', False):
        tiddlywebplugins.dispatcher.init(config)
        tiddlywebplugins.dispatcher.listener.init(config)

    # reset config _again_ to deal with any adjustments from the
    # above init calls

    merge_config(config, space_config)