Thanks for your help. I really appreciate it.

After looking at this some more, self.request.dbsession.future is always 
False regardless of what I've tested.

However, I did find self.request.dbsession.bind._is_future.

If I use the code below in __init__.py:main() before settings is passed to 
Configurator():

settings['sqlalchemy.future'] = True

then in one of my view methods, self.request.dbsession.bind._is_future is 
True. Otherwise, self.request.dbsession.bind._is_future is False.

So, if this is the correct flag SQLAlchemy sets/uses, it appears to be 
making the trip all the way into the view, which is what I wanted to 
validate.

On Tuesday, July 27, 2021 at 6:41:11 PM UTC-4 the...@luhn.com wrote:

> It looks like the `future` flag on Engine and the `future` flag on Session 
> are two separate things.  So you need to add `future=True` to either 
> sessionmaker or the Session constructor.
>
> — Theron
>
>
>
> On Jul 27, 2021, at 7:50 AM, Nate J <nate...@gmail.com> wrote:
>
> Hi List,
>
> How should I set the the future argument to True in the call to 
> create_engine()?
>
> From https://docs.sqlalchemy.org/en/14/tutorial/engine.html:
> The Engine is created by using create_engine(), 
> specifying the create_engine.future flag set to True so that we make full 
> use of 2.0 style usage:
> >>> from sqlalchemy import create_engine
> >>> engine = create_engine("sqlite+pysqlite:///:memory:
> ", echo=True, future=True)
>
> What I’ve tried that doesn’t appear to be working is adding it to settings 
> in myproject/__init__.py:main():
>
> def main(global_config, **settings):
>     """Return a Pyramid WSGI application."""
>     settings['sqlalchemy.future'] = True
>     ...
>
> Later, after starting Pyramid, I see it passed to create_engine() in my 
> debugger.
>
> In sqlalchemy.engine.create.py:engine_from_config():
> options is: {'future': True, '_coerce_config': True}
> And then:
> return create_engine(url, **options)
>
> However, if I look at its value in a class’ view, I see future is False, 
> i.e.:
>
> def __init__(self, request):
>     self.request = request
>
> @view_config(route_name=’test', renderer=‘/test.mako')
> def test(self):
>     # From here, self.request.dbsession.future is False.
>     …
>
> I presume it should be True at this point.
>
> Has anyone seen this or set this flag and used it successfully?
>
> Thanks
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to pylons-discus...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pylons-discuss/48FCE954-14C5-4695-92EC-9CB8582ED990%40gmail.com
>  
> <https://groups.google.com/d/msgid/pylons-discuss/48FCE954-14C5-4695-92EC-9CB8582ED990%40gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/5b2d3834-d32d-46c7-af7f-986d9bb6848dn%40googlegroups.com.

Reply via email to