Can you define an entry point in your Plone product to run a script as if it was called by bin/instance run

左心房为你撑大大i 提交于 2019-12-05 16:23:08

As of Zope 2.13, you can register scripts for the zopectl.command entry point. These will be treated as new commands on the bin/instance controller script.

For example, the following will tie callables in your egg to commands:

[zopectl.command]
mybatch = example.egg.commands:mybatch

Your callable will be passed the root-level application object, and the remaining command line arguments:

def mybatch(app, args):
    site = app.mysiteid
    # remember to set up your site correctly (create request, call hooks, etc)

Use the args to implement command-line switches for your script.

See the Configuring and Running Zope documentation; note that your command names cannot use dashes (-) in the name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!