Hey Mike, I think it would be great to standardize on this sort of library for Pyramid.
I am now currently coding my first Pyramid app, but I am separating some biolerplate/common code in a separate library that I can reuse with all my coming applications. In this library, there is code that needs to point to my DeclarativeBase (and sometimes the scoped session too) I use in my application. But since I want the app depending on the library and not the opposite, I needed a way to reference the base and session. So to clarify again, the function of SQLAHelper is to help me reference my declarative base(s) (or session) via SQLAhelper.get_base() in the library code, without a direct reference to the app? And if so, how does this work, does it do that by looking into the thread or what? My second question is about the use of a second engine. I looked at SQLAHelper docs and found it supports a default engine plus additional engines. Now I use one database but there is only one place where I can need to look at a second database. What is the best practice here? Do I use for the new database models the same DeclarativeBase as the 1st database models and use the SQLAHelper bind method for these models, or do I give them a separate Base (but how will get_base() then work???) ? If SQLAHelper addresses these issues (and assure me that SQLAHelper will be the standard way of managing this issue in Pyramid), I might as well make SQLAHelper a dependency of my library or apps and recode these parts immediately. Cheers, Ahmed On Dec 26, 5:46 pm, Mike Orr <[email protected]> wrote: > SQLAHelper 1.0 is released. It's a simple module serving as a > container for a SQLAlchemy contextual session, declarative base, and > engines. This avoids circular dependencies between model modules, and > allows cooperating third-party libraries to use the application's > Session and Base (which must exist when tables are defined). It's > used by Akhet, and was originally part of the pyramid_sqla scaffold > that Akhet came out of. > > Version 1.0 is mostly a documentation update. A ``set_base()`` > function is added to customize the declarative base. An out-of-date > demo was deleted. > > I haven't said much about SQLAHelper in recent months, so many users > may not be aware that it exists. This has led to other packages that > do approximately the same thing. There was one mentioned here a few > days ago (but I can't find the original message saying what it's > called), and Ptah has a similar feature built-in. But this kind of > thing only works if all packages agree on where the Session and Base > are located. So ChrisM and I would like to standardize on SQLAHelper > as the base package for this. So please try it out, and if you find > any omissions that prevent it from being suitable as a common > dependency between applications and third-party libraries, please let > me know. > > -- > Mike Orr <[email protected]> -- 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.
