-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage problem: can't delay configuration until after model class declaration. #22
Comments
Hi, sorry for the delay, was quite busy with my other project. In development, I'm calling configure() in my init.py that runs the paster script. In production, I actually bubble it way up into the WSGI script that I use for deployment. |
Ok that's what I figured. However, as I was working to replace some of the stuff I already had in place, and start integrating minimongo, I realized that my requirements were already taking me down a path that was somewhat parallel but different enough that I needed to create my own abstraction layer instead. It's unfortunately far enough as to no longer really be a fork any more.
|
Didn't actually realize one could delay configuration like that. This would be handy for swapping collections/dbs for unit testing purposes. Should I omit the hosts from my Model declarations and rely on a later call to |
I'm having a problem figuring out where/when to call minimongo.configure() in my Pyramid app, to make sure that my minimongo class actually have a valid connection to the database.
The whole metaclass thing is causing the connection to be created when the module is imported and the class declaration is parsed, which is way before I've had a chance to read my setting files and get valid values for host and database.
It seems that I can't write an example like this in a single file:
I get the following error:
How exactly can I use minimongo with a deferred configuration call? I'd like to be able to define my models wherever I want, and as long as the call to configure happens before the class is instanciated, everything should be fine, no?
The text was updated successfully, but these errors were encountered: