2009년 6월 13일 (토) 오전 11:09, Mike Orr <[email protected]>님의 말:

>
> On Fri, Jun 12, 2009 at 5:12 PM, 오현성<[email protected]> wrote:
> > Hi there!
> >
> > I'm new to Pylons and Python, though I've used PHP, Rails, PostgreSQL etc
> a
> > little bit in the past.
> >
> > I'm currently working through the Definitive Guide to Pylons, and I've
> run
> > into problems in Chapter 8 (Starting the SimpleSite tutorial,
> > http://pylonsbook.com/en/1.0/starting-the-simplesite-tutorial.html ).
> When I
> > run paster setup-app development.ini, I get the following error:
>
>
> > <snip>
>
>
>  > sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured
> on
> > mapper Mapper|Tag|tag or this Session
> >
> > I've tried making various small changes to model.__init__.py and
> > websetup.py, but got the same error each time. I'm not entirely sure how
> to
> > interpret it. This kind of error seems to be fairly common, but I haven't
> > found identical errors or solutions on Google or anywhere yet. Any help
> > would be much appreciated.
>
> It's looking for an engine to execute the commit on.  It looks first
> in the session, then in the metadata.  So your model.init_model()
> should set up the session using bind=engine.  As it shows on page 172:
>
> sm = orm.sessionmaker(autoflush=True, autocommit=False, bind=engine)
>
> I think in SA 0.5 you can omit all the arguments except bind, but
> that's not pertinent to your immediate problem.
>
> The second question is whether init_model(engine) is being called in
> myapp.config.environment.load_environment(), as it should be.
>
> The third question is whether myapp.websetup.setup_app is calling
> load_environment() like my sample application here is.  If so, then
> you should be able to put
>    log.debug("Engine is %s", meta.Session.bind)
> after that line and have it print out an engine.
>
> All three of these have to be in place in order to avoid this error.
> setup-app is not that widely used, so it's possible there's an
> inconsistency in the documentation somewhere.


Thank you! The problem was in websetup.py, which I hadn't set up correctly.
A strong dose of caffeine helped find that.

Actually, I'm impressed by the quality of the documentation so far - both
the book and the documentation on the Pylons website. I've found very few
errors until now, and there are a lot of really useful examples.


> By the way, there is another way to configure the session which came
> into vogue after the book was written.  You don't have to worry about
> it now but just so you're aware of it in case you encounter it, it's
> to move the sm and Session assignments to the meta module (without a
> bind argument), and then to modify the Session in place in
> init_model():
>
>    meta.Session.configure(bind=engine)
>
> This helps in some edge situations where you want to refer to a
> session in a global expression (after the model has been imported but
> before init_model has been called), but is not strictly necessary.
>
> --
> Mike Orr <[email protected]>



I notice that there are some differences between the example in the book and
the default configuration. I might look into that a little more when I've
got the basics sorted out.


Richard

>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to