moksha/middleware/middleware.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
New commits: commit 36b664feabd5cc86937395d50f52590aa4f3a4cd Author: Luke Macken lmacken@redhat.com Date: Thu Mar 18 07:28:06 2010 -0400
Improve the way we attempt to import models from applications.
Before, we tried to do $plugin_name/model, now we're essentially looking for $plugin_controller.py/../model
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py index 919dfcd..8aca064 100644 --- a/moksha/middleware/middleware.py +++ b/moksha/middleware/middleware.py @@ -145,12 +145,14 @@ class MokshaMiddleware(object): 'model': None, }) try: - model = __import__('%s.model' % app_entry.name, - globals(), locals(), + # Try to import the 'model' module alongside its 'controllers' + module = '.'.join(app_class.__module__.split('.')[:-2] + + ['model']) + model = __import__(module, globals(), locals(), [app_entry.name]) moksha._apps[app_entry.name]['model'] = model except ImportError, e: - log.debug(e) + log.debug("Cannot find application model: %r" % module)
def load_wsgi_applications(self): log.info('Loading moksha WSGI applications')