moksha/middleware/connector.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
New commits:
commit a80e70c2f174edcc73e53392a3a053ccb238e8d1
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sun Dec 13 19:36:08 2009 -0500
Make the moksha.api.connectors.get_connector method work outside of WSGI
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 9632b98..48ef971 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -170,7 +170,16 @@ class MokshaConnectorMiddleware(object):
def _get_connector(name, request=None):
# TODO: having a connection pool might be nice
- c = MokshaConnectorMiddleware._connectors[name]
+ if name in MokshaConnectorMiddleware._connectors:
+ c = MokshaConnectorMiddleware._connectors[name]
+ else:
+ # Look for it on the entry-point
+ for conn_entry in pkg_resources.iter_entry_points('moksha.connector'):
+ if conn_entry.name == name:
+ conn_class = conn_entry.load()
+ conn_class.register()
+ conn_path = conn_entry.dist.location
+ c = {'connector_class': conn_class}
if not request:
from pylons import request
Show replies by date