On Sun, Apr 11, 2010 at 09:07:17PM -0400, Rick Harding wrote: > I'm trying to load up my controllers/models and such into my sphinx > docs for my app. I can include them fine, but it won't actually load > the pages due to: > > (WARNING/2) autodoc can't import/find module > 'qmail_app.controllers.root', it reported error: "'pop(): dictionary > is empty'", please check your spelling and sys.path > > This is because it doesn't have a config instance to pull the SA > config data for the models. Is there a trick anyone has to deal with > this?
When you create a new Pylons project using a recent-ish Paster template,
it sets things up so that the config dict is not needed at import time,
which is very sane in my opinion.
E.g. my current hobby project has this in model/meta.py (not including
comments):
from sqlalchemy import MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
__all__ = ['Session', 'engine', 'metadata']
engine = None
Session = scoped_session(sessionmaker())
metadata = MetaData()
and this in model/__init__.py:
def init_model(engine):
meta.Session.configure(bind=engine)
meta.engine = engine
and this in config/environment.py:
def load_environment(global_conf, app_conf):
...
engine = engine_from_config(config, 'sqlalchemy.')
init_model(engine)
...
I can import my models and controllers without having to set up
sqlalchemy.
HTH,
Marius Gedminas
--
System going down at 5 this afternoon to install scheduler bug.
signature.asc
Description: Digital signature
