Wyatt Baldwin
unread,Jul 30, 2011, 1:08:47 PM7/30/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to paste...@googlegroups.com
I would like to be able to load a PasteDeploy config file from within a Python package. The easiest way I could see to accomplish this was to add a new loader. Here's a simple example that illustrates what I want to do:
# base.ini in package MyFramework
[app:main]
use = egg:SomeEgg
a = 1
b = 2
# app.ini
[app:main]
use = configfrompackage:MyFramework:base.ini
b = 4
I whipped a rough patch that accomplishes this. If there's any interest in adding something like this, I'll polish this up and submit a pull request with at least one new test.
diff -r 9921ad7ac983 paste/deploy/loadwsgi.py
--- a/paste/deploy/loadwsgi.py Wed May 25 00:34:47 2011 +0300
+++ b/paste/deploy/loadwsgi.py Sat Jul 30 09:42:40 2011 -0700
@@ -322,6 +322,15 @@
_loaders['config'] = _loadconfig
+def _loadconfigfrompackage(object_type, uri, path, name, relative_to,
+ global_conf):
+ package, rel_path = path.split(':', 1)
+ path = pkg_resources.resource_filename(package, rel_path)
+ return _loadconfig(object_type, uri, path, name, relative_to, global_conf)
+
+_loaders['configfrompackage'] = _loadconfigfrompackage
+
+
def _loadegg(object_type, uri, spec, name, relative_to,
global_conf):
loader = EggLoader(spec)