I noted that in setuphandlers.py the post_install method is now called by convention.
One thing that doesn't seem to work in the context of a post_install is checking for a marker file.
As I understand it, the marker file was a mechanism to prevent "leaking" of install instructions, effectively ensuring that the code only runs when the specific package installer is invoked.
Does the post_install way avoid the "leakage" issue? By extension, does this mean that we don't need to use mechanisms like marker files when using the the new post_install way?
Background
Thanks to settings in configure.zcml, post_install is the default facility provided by bobtemplates.plone
For reference, this is what I've been looking at:
https://github.com/plone/bobtemplates.plone/blob/master/bobtemplates/plone_addon/src/%2Bpackage.namespace%2B/%2Bpackage.name%2B/configure.zcml.bob
More background:
The code below fails because there is no readDataFile in the context.
def post_install(context):
"""Post install script"""
# Do something at the end of the installation of this package.
if context.readDataFile('acme.marker.txt') is None:
return
api.content.delete(api.content.get('/news'))
When I install my add-on I get the following output
Module acme.site.setuphandlers, line 13, in post_install
AttributeError: readDataFile
It seems that post_install is run in a slightly different context from the traditional setup_various. I added an importstep with setup_various to my configure.zcml and including the code above in setup_various instead of post_install, this worked flawlessly.
Upon reflection, I'm starting to wonder whether what I should have done is just forget about using readDataFile to look for a marker text file and just put everything in a post_install method instead, hence the question.