Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to launch a Paster shell with some modules pre-imported?

Is it possible to run "paster shell blah.ini" (or a variant thereof) and have it automatically load certain libraries?

I hate having to always type "from foo.bar import mystuff" as the first command in every paster shell, and would like the computer to do it for me.

like image 742
mike Avatar asked Nov 05 '22 21:11

mike


1 Answers

An option to try would be to create a sitecustomize.py script. If you have this in the same folder as your paster shell, the python interpreter should load it up on startup.

Let me clarify, sitecustomize.py, if found, is always loaded on startup of the interpreter. So if you put it where it can be found, ideally somewhere that is only found when the paster shell starts, then you should be able to add your imports to it and have them be ready.

This is probably your best bet. If the paster shell is a packaged app (a la py2exe) it should still work.

See also:

http://www.rexx.com/~dkuhlman/pylons_quick_site.html#using-an-ipython-embedded-shell http://pylonshq.com/project/pylonshq/ticket/428

like image 74
Christopher Avatar answered Nov 14 '22 23:11

Christopher