Question

OK, before 1.4 release we had paster where we can add our own commands, for example for drop cache or load database initial data. Right now, how I understand, pyramid deal with Console Scripts but documentation is poor about this new feature. I want load initial database data. In old-style I write separate command for paster and register it when I will can load data like this:

paster loaddbdata

How I can do that now?

Was it helpful?

Solution

Pyramid provides the pyramid.paster.bootstrap() to make it easy to create a script with your application. Turning a script into a command isn't done through any complicated construct provided by Pyramid, but rather you should just use setuptools entry points. This involves adding a [console_scripts] section to your setup.py entry_points, re-running develop, and your script should be installed into the bin directory.

setup(
   # ...
   entry_points={
    'paste.app_factory': [
        'main = myapp:main',
    ],
    'console_scripts': [
        'myscript = myapp.scripts.myscript:main',
    ],
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top