Oh wow, do I feel stupid. The problem was indeed on the template side, not the controllers. I had the same named subfolder in the templates folder but had failed to put an empty __init__.py file in it. I had simply assumed that the problem was with the controller, not the template. For some reason, I thought that since Genshi doesn't create pyc files like Kid does, they don't need an __init__.py file in the same folder.
Anyway, thank you so much for the help. It's working just fine now. On Oct 28, 12:07 am, "Mike C. Fletcher" <[email protected]> wrote: > Min wrote: > > I hate to bump my own topic, but this is a pretty pressing problem for > > me. Surely someone out there has used subfolders in the controllers > > folder in a TG2 project? > > Haven't myself, but some things to check: > > * you have *not* named your top-level module "load_forecasting" > (same-name packages as children often cause import issues) > o that is, your package is not > > load_forecasting.controllers.load_forecasting.Index_LoadForecasting > * you can import the module from "paster shell development.ini" > * your template file really is there with proper __init__'s all the > way down to it... > > from what I can see, the decorator is trying to find your *template* > file and is failing on that lookup from pkg_resources(). > > Good luck, > Mike > > > > > On Oct 22, 11:10 am, Min <[email protected]> wrote: > > >> I quickstarted a TG2 project, with the intent of having it replace a > >> TG1 project that I had worked on. The TG1 project used a lot of > >> controllers, so I had organized them by subfolders under the project/ > >> controllers/ folder and imported them from root.py (ie from > >> project.controllers.subfolder.subcontrollermodule import > >> subcontroller). > > >> I tried to do the same thing with TG2, but I'm getting an ImportError > >> when I try to access the page. The full traceback is below. > > >> Basically, I have a subfolder under controllers named > >> load_forecasting. Under it are 2 python files: a blank __init__.py > >> file and Index_LoadForecasting.py, latter of which contains the > >> Index_LoadForecastingController class, which subclasses > >> BaseController. > > >> In root.py under the controllers directory, I import > >> Index_LoadForecastingController from > >> load_forecasting.Index_LoadForecasting, then instantiate it with > >> load_forecast= Index_LoadForecastingController() under the > >> RootController. > > >> When I run paster to serve the site, it works fine, and I get the > >> standard TG2 quickstart page when I go tohttp://localhost/. But when > >> I go tohttp://localhost/load_forecast/, it's only then that I get > >> this error. > > >> If anyone has any idea why this isn't working, or what changed between > >> TG1 and TG2 to make it happen, I'd be very grateful. > > >> Also, I can import from other controller modules inside the > >> controllers folder and see them just fine. The problem only occurs > >> when I try to import from a controller module placed inside a > >> subfolder. > > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\weberror-0.10.1- > >> py2.5.egg\\weberror\\evalexception.py', line 431 in respond > >> app_iter = self.application(environ, detect_start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\configuration.py', line 655 in wrapper > >> return app(environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\configuration.py', line 555 in remover > >> return app(environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\repoze.tm2-1.0a4- > >> py2.5.egg\\repoze\\tm\\__init__.py', line 19 in __call__ > >> result = self.application(environ, save_status_and_headers) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\repoze.who-1.0.15- > >> py2.5.egg\\repoze\\who\\middleware.py', line 107 in __call__ > >> app_iter = app(environ, wrapper.wrap_start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\ToscaWidgets-0.9.7.2- > >> py2.5.egg\\tw\\core\\middleware.py', line 36 in __call__ > >> return self.wsgi_app(environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\ToscaWidgets-0.9.7.2- > >> py2.5.egg\\tw\\core\\middleware.py', line 59 in wsgi_app > >> resp = req.get_response(self.application) > >> File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1325 in > >> get_response > >> File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1293 in > >> call_application > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\ToscaWidgets-0.9.7.2- > >> py2.5.egg\\tw\\core\\resource_injector.py', line 67 in _injector > >> resp = req.get_response(app) > >> File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1325 in > >> get_response > >> File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1293 in > >> call_application > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\beaker-1.3-py2.5.egg\ > >> \beaker\\middleware.py', line 81 in __call__ > >> return self.app(environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\beaker-1.3-py2.5.egg\ > >> \beaker\\middleware.py', line 160 in __call__ > >> return self.wrap_app(environ, session_start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\routes-1.10.3-py2.5.egg > >> \\routes\\middleware.py', line 130 in __call__ > >> response = self.app(environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\ > >> \pylons\\wsgiapp.py', line 125 in __call__ > >> response = self.dispatch(controller, environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\ > >> \pylons\\wsgiapp.py', line 324 in dispatch > >> return controller(environ, start_response) > >> File 'C:\\workarea\\python\\PyEMMT\\FrontEnd\\Analytics3\\analytics3\ > >> \lib\\base.py', line 32 in __call__ > >> return TGController.__call__(self, environ, start_response) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\ > >> \pylons\\controllers\\core.py', line 221 in __call__ > >> response = self._dispatch_call() > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\ > >> \pylons\\controllers\\core.py', line 172 in _dispatch_call > >> response = self._inspect_call(func) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\ > >> \pylons\\controllers\\core.py', line 107 in _inspect_call > >> result = self._perform_call(func, args) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\controllers.py', line 857 in _perform_call > >> self, controller, params, remainder=remainder) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\controllers.py', line 182 in _perform_call > >> response = self._render_response(controller, output) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\controllers.py', line 358 in _render_response > >> template_name=template_name) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\render.py', line 141 in render > >> return render_function(template_name, template_vars, **kwargs) > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\render.py', line 165 in render_genshi > >> template_extension='.html') > >> File 'c:\\workarea\\tg2env\\lib\\site-packages\\turbogears2-2.0.3- > >> py2.5.egg\\tg\\util.py', line 153 in get_dotted_filename > >> result = resource_filename(package, basename) > >> File 'build/bdist.linux-i686/egg/pkg_resources.py', line 840 in > >> resource_filename > >> File 'build/bdist.linux-i686/egg/pkg_resources.py', line 160 in > >> get_provider > >> ImportError: No module named load_forecasting > > -- > ________________________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://www.vrplumber.com > http://blog.vrplumber.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

