I just wasted around 5 hours trying to figure out how to run a job that would use pylons models/config. I finally did it so I'm submitting this script here and hoping that it will be somehow integrated into pylons and the documentation. I hope that as a result it will save other peoples time and make pylons a better experience.
Regards,
from sqlalchemy import * import leisurenow.models as model from paste.deploy import appconfig, config, CONFIG import sys
Maybe I'm just not getting it, but this looks really complicated for what it's trying to achieve (not the fault of the OP but more so because of the paste config stuff).
database.py import appconfig.py engine = create_engine(appconfig.dburi) # tables defined here
model.py import database #model classes defined here model.meta.connect(database.engine)
Then if you need to use any of this in a script, it's as simple as importing any of these modules into your script. Just plain python. Nothing special.
> I just wasted around 5 hours trying to figure out how to run a job > that would use pylons models/config. I finally did it so I'm > submitting this script here and hoping that it will be somehow > integrated into pylons and the documentation. I hope that as a result > it will save other peoples time and make pylons a better experience.
> Regards,
> from sqlalchemy import * > import leisurenow.models as model > from paste.deploy import appconfig, config, CONFIG > import sys
Well, for one thing you didn't do CONFIG.push_process_config(...), so not everything would work.
For another thing - if you change the pylons DB config then you have to edit your script and change it there too - so that's evil.
And the third thing is that it took quiet some time to figure this out for me so I think that if there was a script like this in the project out of the box - then it could save some people a lot of time and stress with pylons.
Regards,
On 30 Cze, 04:52, Contact 42 <contactm...@gmail.com> wrote:
> Maybe I'm just not getting it, but this looks really complicated for > what it's trying to achieve (not the fault of the OP but more so because > of the paste config stuff).
> database.py > import appconfig.py > engine = create_engine(appconfig.dburi) > # tables defined here
> model.py > import database > #model classes defined here > model.meta.connect(database.engine)
> Then if you need to use any of this in a script, it's as simple as importing any of these modules into your script. Just plain python. Nothing special.
> Huy
> > Hello,
> > I just wasted around 5 hours trying to figure out how to run a job > > that would use pylons models/config. I finally did it so I'm > > submitting this script here and hoping that it will be somehow > > integrated into pylons and the documentation. I hope that as a result > > it will save other peoples time and make pylons a better experience.
> > Regards,
> > from sqlalchemy import * > > import leisurenow.models as model > > from paste.deploy import appconfig, config, CONFIG > > import sys
WSobczuk wrote: > Well, for one thing you didn't do CONFIG.push_process_config(...), so > not everything would work.
I'm not sure what you mean. I'm not using paste config though.
> For another thing - if you change the pylons DB config then you have > to edit your script and change it there too - so that's evil.
I don't use the pylons db config. My appconfig.py is my config file. I am not evil...promise.
> And the third thing is that it took quiet some time to figure this out > for me so I think that if there was a script like this in the project > out of the box - then it could save some people a lot of time and > stress with pylons.
As I said in my earlier post, I am not saying that your script is not useful for pylons/paste config, but I am questioning the whole pylons config thing.
It doesn't sit well with me when i have to boot strap the entire web framework just because I want reuse my models/database code.
> On 30 Cze, 04:52, Contact 42 <contactm...@gmail.com> wrote:
>> Maybe I'm just not getting it, but this looks really complicated for >> what it's trying to achieve (not the fault of the OP but more so because >> of the paste config stuff).
>> database.py >> import appconfig.py >> engine = create_engine(appconfig.dburi) >> # tables defined here
>> model.py >> import database >> #model classes defined here >> model.meta.connect(database.engine)
>> Then if you need to use any of this in a script, it's as simple as importing any of these modules into your script. Just plain python. Nothing special.
>> Huy
>>> Hello,
>>> I just wasted around 5 hours trying to figure out how to run a job >>> that would use pylons models/config. I finally did it so I'm >>> submitting this script here and hoping that it will be somehow >>> integrated into pylons and the documentation. I hope that as a result >>> it will save other peoples time and make pylons a better experience.
>>> Regards,
>>> from sqlalchemy import * >>> import leisurenow.models as model >>> from paste.deploy import appconfig, config, CONFIG >>> import sys
> Well, for one thing you didn't do CONFIG.push_process_config(...), so > not everything would work.
> For another thing - if you change the pylons DB config then you have > to edit your script and change it there too - so that's evil.
> And the third thing is that it took quiet some time to figure this out > for me so I think that if there was a script like this in the project > out of the box - then it could save some people a lot of time and > stress with pylons.
> Regards,
Actually, I was hoping for something like this a few hours before you posted it. Thanks a bunch!