Skip to content

Commit

Permalink
First try at updating the last_compilation date of our bundle.
Browse files Browse the repository at this point in the history
But it is not enough.
Added ideas in comments.  I like none of those ideas.
  • Loading branch information
mauritsvanrees committed Sep 8, 2020
1 parent 3d3efd0 commit e15cd7d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/collective/easyform/profiles/default/registry.xml
Expand Up @@ -66,7 +66,8 @@
<value key="compile">False</value>
<value key="csscompilation">++resource++easyform.css</value>
<value key="depends">plone</value>
<value key="last_compilation">2019-04-24 15:10:00</value>
<!-- Please keep this in sync with upgrades.update_last_compilation -->
<value key="last_compilation">2020-09-08 17:52:00</value>
<value key="resources">
</value>
<value key="merge_with">default</value>
Expand Down
4 changes: 4 additions & 0 deletions src/collective/easyform/upgrades/1007.zcml
Expand Up @@ -13,6 +13,10 @@
import_steps="actions"
run_deps="false"
/>
<gs:upgradeStep
title="Update last_compilation of bundle"
handler=".update_last_compilation"
/>
</gs:upgradeSteps>

</configure>
29 changes: 29 additions & 0 deletions src/collective/easyform/upgrades/__init__.py
@@ -0,0 +1,29 @@
def update_last_compilation(context):
# Let's do the imports inline, so they are not needlessly done at startup.
# Should not really matter, but oh well.
from datetime import datetime
from plone.registry.interfaces import IRegistry
from zope.component import getUtility
from Products.CMFPlone.interfaces import IBundleRegistry

registry = getUtility(IRegistry)
records = registry.forInterface(IBundleRegistry, prefix="plone.bundles/easyform")
# Technically we only need year, month and day.
# But keep this in sync with registry.xml.
records.last_compilation = datetime(2020, 9, 8, 17, 52, 0)
# TODO: run the combine-bundles import step or its handler
# Products.CMFPlone.resources.exportimport.bundles.combine.
# But that only does something when there is a registry.xml,
# so I don't think it works for an upgrade step.
#
# But this is a wrapper around
# Products.CMFPlone.resources.browser.combine.combine_bundles
# which we could call directly, but then we need to do the same
# extra handling of the response contenttype.
#
# We could also re-apply our whole registry.xml,
# by doing an upgradeDepends with plone.app.registry and combine-bundles,
# but that restores our factory defaults, which we should not do.
#
# Easiest is to add an upgrade profile.
# I always consider that overkill, but so be it.

0 comments on commit e15cd7d

Please sign in to comment.