Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run SetupMultilingualSite after installing PAM #214

Closed
iham opened this issue Mar 3, 2016 · 0 comments · Fixed by #215
Closed

Run SetupMultilingualSite after installing PAM #214

iham opened this issue Mar 3, 2016 · 0 comments · Fixed by #215

Comments

@iham
Copy link
Member

iham commented Mar 3, 2016

Thats my scenario:
I have a package holding GenericSetup configs like registry.xml including language-settings (which languages are used, default language and negotiation for example). Also i want to install dependencies. PAM and others in this case.

So installing my package does the settings correct and also installs PAM. So far so good.

But the LRF and LIF folders are not created. Therefore i had to go to Plone's control panel -> language settings and hit "save" without any changes done to trigger the creation process of PAM.

I found out that i can trigger that after my package installation by using plone.app.multilingual.browser.setup.py's code

setupTool = SetupMultilingualSite()
setupTool.setupSite(<portal>)

inside my setuphandler (using GS 1.8.2+ i can use post_handler on my profile's registry)

I don't think this should be in my package as this seems pretty default to me, to get the language folders and all other stuff set, when having my configs and installing PAM, when building a new portal.

My first thought was: why doesn't PAM run this on installation as it doesn't override/replace any existing content or delete stuff during that process.

plone.app.multilingual
configure.zcml

  <genericsetup:registerProfile
      name="default"
      title="plone.app.multilingual"
      description="Install to enable multilingual content support"
      directory="profiles/default"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      for="Products.CMFPlone.interfaces.IPloneSiteRoot"
      post_handler=".setuphandlers.post_install_default"/>

setuphanders.py

def post_install_default(tool):
    from plone.app.multilingual.browser.setup import SetupMultilingualSite
    from plone.api import portal
    setupTool = SetupMultilingualSite()
    setupTool.setupSite(portal.get())

The other idea by @pbauer: add a second profile depending on the default profile that i can trigger as a dependency in my package then.
configure.zcml

  <genericsetup:registerProfile
      name="setup"
      title="plone.app.multilingual (Setup)"
      description="Install and enable multilingual content support"
      directory="profiles/setup"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      for="Products.CMFPlone.interfaces.IPloneSiteRoot"
      post_handler=".setuphandlers.post_setup"/>

metadata.xml

<?xml version="1.0"?>
<metadata>
  <version>0.1</version>
  <dependencies>
    <dependency>profile-plone.app.multilingual:default</dependency>
  </dependencies>
</metadata>

setuphanders.py

def setup(tool):
    from plone.app.multilingual.browser.setup import SetupMultilingualSite
    from plone.api import portal
    setupTool = SetupMultilingualSite()
    setupTool.setupSite(portal.get())

my metadata.xml would look like that then:

<?xml version="1.0"?>
<metadata>
  <version>0.1</version>
  <dependencies>
    <dependency>profile-plone.app.multilingual:setup</dependency>
  </dependencies>
</metadata>

Any considerations?
Better ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant