Trigger cron style jobs in Plone sites without passwords

For some time the plone.recipe.zope2instance added support to execute scripts in the context of a full "Zope 2 environment", by using it such as 

bin/instance run /path/to/script

This can be used to launch Python scripts with full support of the Zope machinery, connected to the Zeo server, etc. The script can be generated as a console script from any Plone addon. Here's a small snippet to be used to get a "fully integrated" Plone site:

HOST = ''
PLONE_PATH = '/Plone'    # physical Path of Plone website

def get_plone_site():
    import Zope2
    app =
    from Testing.ZopeTestCase import utils
    utils._Z2HOST = HOST

    path = PLONE_PATH.split('/')
    plone = path[-1]

    app = utils.makerequest(app)
    app.REQUEST['PARENTS'] = [app]
    app.REQUEST.other['VirtualRootPhysicalPath'] = path
    from zope.globalrequest import setRequest

    from AccessControl.SpecialUsers import system as user
    from AccessControl.SecurityManagement import newSecurityManager
    newSecurityManager(None, user)

    _site = app[plone]
    site = _site.__of__(app)

    from import setSite

    return site

def main():
    site = get_plone_site()

Now the "main" function can be registered as console script in the of the package

      # -*- Entry points: -*-
      myscript = my.package.scripts:main

 Note: There's also clockserver support in Zope, you can configure as:

    # starts a clock which calls /foo/bar every 30 seconds
    method /foo/bar
    period 30
    user admin
    password 123

What I don't like about this: it involves saving passwords in config files, which is not very maintainable. Also, the run-based method can be called "on demand", for example by scripts watching a RabbitMQ queue, etc.