diff options
| author | ianb <devnull@localhost> | 2005-05-16 03:49:12 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-16 03:49:12 +0000 |
| commit | c552be340632df607536f4db4507d059f46ddcf4 (patch) | |
| tree | fcdb694457cbb5a24952b5dea3f45d86588dc5fa | |
| parent | e8c47309821205d08c4e552169ed80ff782c7411 (diff) | |
| download | paste-c552be340632df607536f4db4507d059f46ddcf4.tar.gz | |
Added framework plugins
| -rw-r--r-- | examples/console/server.conf | 1 | ||||
| -rw-r--r-- | examples/todo_sql/server.conf | 1 | ||||
| -rw-r--r-- | examples/todo_wareweb/server.conf | 2 | ||||
| -rw-r--r-- | paste/app_templates/wareweb_zpt/template/server.conf | 1 | ||||
| -rw-r--r-- | paste/app_templates/webkit_zpt/template/server.conf | 1 | ||||
| -rw-r--r-- | paste/default_config.conf | 1 | ||||
| -rw-r--r-- | paste/frameworks/__init__.py | 1 | ||||
| -rw-r--r-- | paste/frameworks/default_framework.py | 17 | ||||
| -rw-r--r-- | paste/frameworks/wareweb_framework.txt | 1 | ||||
| -rw-r--r-- | paste/frameworks/webkit_framework.txt | 1 | ||||
| -rwxr-xr-x | paste/server.py | 30 | ||||
| -rw-r--r-- | paste/util/plugin.py | 6 | ||||
| -rw-r--r-- | paste/wareweb/conf_setup.py | 5 | ||||
| -rw-r--r-- | paste/webkit/conf_setup.py | 43 |
14 files changed, 89 insertions, 22 deletions
diff --git a/examples/console/server.conf b/examples/console/server.conf index 8a94e0b..8e49daf 100644 --- a/examples/console/server.conf +++ b/examples/console/server.conf @@ -4,6 +4,7 @@ import os app_template = 'webkit_zpt' app_name = 'console' +framework = 'webkit' publish_dir = os.path.join(os.path.dirname(__file__), 'web') sys_path = [os.path.dirname(os.path.dirname(__file__))] diff --git a/examples/todo_sql/server.conf b/examples/todo_sql/server.conf index fa99577..8c090de 100644 --- a/examples/todo_sql/server.conf +++ b/examples/todo_sql/server.conf @@ -4,6 +4,7 @@ import os database = 'sqlite:%s/data.db' % os.path.dirname(__file__) app_template = 'webkit_zpt' +framework = 'webkit' app_name = 'todo_sql' publish_dir = '/var/www/todo_sql/web' sys_path = ['/var/www'] diff --git a/examples/todo_wareweb/server.conf b/examples/todo_wareweb/server.conf index 70d1b49..de40477 100644 --- a/examples/todo_wareweb/server.conf +++ b/examples/todo_wareweb/server.conf @@ -3,6 +3,8 @@ import os app_name = 'todo_wareweb' +app_template = 'wareweb_zpt' +framework = 'wareweb' publish_dir = os.path.join(os.path.dirname(__file__), 'web') sys_path = [os.path.dirname(os.path.dirname(__file__))] diff --git a/paste/app_templates/wareweb_zpt/template/server.conf b/paste/app_templates/wareweb_zpt/template/server.conf index 46cabf4..463cff9 100644 --- a/paste/app_templates/wareweb_zpt/template/server.conf +++ b/paste/app_templates/wareweb_zpt/template/server.conf @@ -4,6 +4,7 @@ import os app_template = $str_template_name app_name = $str_app_name +framework = 'wareweb' root_path = $str_absolute_base_dir publish_dir = os.path.join(root_path, 'web') sys_path = [os.path.dirname(root_path)] diff --git a/paste/app_templates/webkit_zpt/template/server.conf b/paste/app_templates/webkit_zpt/template/server.conf index 33cd9c4..ebe1055 100644 --- a/paste/app_templates/webkit_zpt/template/server.conf +++ b/paste/app_templates/webkit_zpt/template/server.conf @@ -4,6 +4,7 @@ import os app_template = $str_template_name app_name = $str_app_name +framework = 'webkit' publish_dir = os.path.join($str_absolute_base_dir, 'web') sys_path = [$str_absolute_parent] diff --git a/paste/default_config.conf b/paste/default_config.conf index de99ef3..bf9ad00 100644 --- a/paste/default_config.conf +++ b/paste/default_config.conf @@ -2,3 +2,4 @@ index_names = ['index', 'Index', 'main', 'Main'] sys_path = [] +framework = 'default' diff --git a/paste/frameworks/__init__.py b/paste/frameworks/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/paste/frameworks/__init__.py @@ -0,0 +1 @@ +# diff --git a/paste/frameworks/default_framework.py b/paste/frameworks/default_framework.py new file mode 100644 index 0000000..78ed8d8 --- /dev/null +++ b/paste/frameworks/default_framework.py @@ -0,0 +1,17 @@ +def build_application(conf): + if conf.get('publish_dir'): + from paste.webkit import wsgiwebkit + app = wsgiwebkit.webkit(conf['publish_dir'], use_lint=conf.get('lint')) + elif conf.get('publish_app'): + app = conf['publish_app'] + if isinstance(app, (str, unicode)): + from paste.util import import_string + app = import_string.eval_import(app) + else: + # @@ ianb 2005-03-23: This should be removed sometime + if conf.get('webkit_dir'): + print 'The webkit_dir configuration variable is no longer supported' + print 'Use publish_dir instead' + print "You must provide publish_dir or publish_app" + sys.exit(2) + return app diff --git a/paste/frameworks/wareweb_framework.txt b/paste/frameworks/wareweb_framework.txt new file mode 100644 index 0000000..fde9485 --- /dev/null +++ b/paste/frameworks/wareweb_framework.txt @@ -0,0 +1 @@ +paste.wareweb.conf_setup diff --git a/paste/frameworks/webkit_framework.txt b/paste/frameworks/webkit_framework.txt new file mode 100644 index 0000000..93beb1d --- /dev/null +++ b/paste/frameworks/webkit_framework.txt @@ -0,0 +1 @@ +paste.webkit.conf_setup diff --git a/paste/server.py b/paste/server.py index f80cb6e..4b6c49c 100755 --- a/paste/server.py +++ b/paste/server.py @@ -170,24 +170,18 @@ def help(): return help_message % {'program': program} def make_app(conf): - if conf.get('publish_dir'): - app = wsgiwebkit.webkit(conf['publish_dir'], use_lint=conf.get('lint')) - elif conf.get('publish_app'): - app = conf['publish_app'] - if isinstance(app, (str, unicode)): - from paste.util import import_string - app = import_string.eval_import(app) - else: - # @@ ianb 2005-03-23: This should be removed sometime - if conf.get('webkit_dir'): - print 'The webkit_dir configuration variable is no longer supported' - print 'Use publish_dir instead' - print "You must provide publish_dir or publish_app" - sys.exit(2) - # @@: we can't do this when we support making multiple applications - # with this function: - CONFIG.push_process_config(conf) - return config_middleware(app, conf) + framework_name = conf.get('framework', 'default') + framework = plugin.load_plugin_module( + os.path.join(os.path.dirname(__file__), 'frameworks'), + 'paste.frameworks', + framework_name, + '_framework') + app = framework.build_application(conf) + if conf.get('lint'): + import lint + app = lint.middleware(app) + app = config_middleware(app, conf) + return app def restart_with_reloader(conf): if conf['verbose']: diff --git a/paste/util/plugin.py b/paste/util/plugin.py index 442a7a6..450a6e4 100644 --- a/paste/util/plugin.py +++ b/paste/util/plugin.py @@ -50,10 +50,7 @@ def load_plugin_module(dir, dir_package, name, name_extension=''): module_name = parse_txt_plugin(os.path.join(dir, txt_name)) else: module_name = dir_package + '.' + name + name_extension - try: - return import_string.import_module(module_name) - except ImportError, e: - raise PluginNotFound(str(e)) + return import_string.import_module(module_name) def parse_txt_plugin(fn): f = open(fn) @@ -67,6 +64,7 @@ def parse_txt_plugin(fn): raise PluginNotFound( "Plugin file %s contains more than one line that " "could be interpreted as a module name" % fn) + module_name = line if module_name is None: raise PluginNotFound( "Plugin file %s does not contain a module name" % fn) diff --git a/paste/wareweb/conf_setup.py b/paste/wareweb/conf_setup.py new file mode 100644 index 0000000..ccd4751 --- /dev/null +++ b/paste/wareweb/conf_setup.py @@ -0,0 +1,5 @@ +from paste.webkit import conf_setup as webkit_conf_setup + +def build_application(conf): + conf['install_fake_webware'] = False + return webkit_conf_setup.build_application(conf) diff --git a/paste/webkit/conf_setup.py b/paste/webkit/conf_setup.py new file mode 100644 index 0000000..1599997 --- /dev/null +++ b/paste/webkit/conf_setup.py @@ -0,0 +1,43 @@ +import sys +import os +from paste import urlparser +from paste import session +from paste import recursive +from paste import httpexceptions +from paste import lint +from paste import error_middleware + +def build_application(conf): + if not 'publish_dir' in conf: + print 'You must provide a publish_dir configuration value' + sys.exit(2) + directory = conf['publish_dir'] + install_fake_webware = conf.get('install_fake_webware', True) + use_lint = conf.get('lint', False) + if install_fake_webware: + _install_fake_webware() + app = urlparser.URLParser(directory, os.path.basename(directory)) + if use_lint: + app = lint.middleware(app) + app = httpexceptions.middleware(app) + if use_lint: + app = lint.middleware(app) + print session + app = session.SessionMiddleware(app) + if use_lint: + app = lint.middleware(app) + app = recursive.RecursiveMiddleware(app) + if use_lint: + app = lint.middleware(app) + app = error_middleware.ErrorMiddleware(app) + # I'll skip the use of lint on recursive, because it doesn't modify + # its output much at all + return app + +def install_fake_webware(): + fake_webware_dir = os.path.join(os.path.dirname(__file__), + 'FakeWebware') + if fake_webware_dir in sys.path: + return + sys.path.insert(0, fake_webware_dir) +_install_fake_webware = install_fake_webware |
