2

在我的 Plone 4 应用程序中动态加载 MathJax 时出现性能问题。因此,我在https://github.com/collective/collective.mathjax找到了 Plone 集成,并且,正如我注意到的那样,它分叉了它,效果很好;我包含了当前的 MathJax 2.3 并更改了配置文件以使用“本地”副本。

现在我想知道是否可以通过在Plone QuickInstaller Toolrackcdn.com中安装产品时选择配置文件来在“在线”/“远程”行为(从 加载所有内容)和“默认”行为(使用包含的副本)之间进行选择。

我改变了configure.zcml这样的:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="collective.mathjax">

  <browser:resourceDirectory
      name="mathjax"
      directory="resources/MathJax" />

  <genericsetup:registerProfile
      name="default"
      title="collective.mathjax: default"
      directory="profiles/default"
      description="collective.mathjax default profile: Includes MathJax 2.3."
      provides="Products.GenericSetup.interfaces.EXTENSION" />

  <genericsetup:registerProfile
      name="online"
      title="collective.mathjax: online"
      directory="profiles/online"
      description="collective.mathjax online profile: Load MathJax dynamically from rackcdn.com."
      provides="Products.GenericSetup.interfaces.EXTENSION" />

</configure>

不幸的是,我在 QuickInstaller 中看不到“在线”配置文件,即使在卸载产品并更改版本号之后也是如此。

更新:在控制台输出中,我发现以下文本:

信息 CMFQuickInstallerTool 为产品找到多个扩展配置文件collective.mathjax。使用的配置文件:collective.mathjax:default

是否存在一些根本性的误解,或者我能做些什么让人们选择?

4

3 回答 3

3

Plone Quickinstaller(ZMI 和 Plone UI)只会将一个配置文件显示为“安装”配置文件。被选中的将是第一个找到的(按字母顺序)。

要手动运行配置文件,请转到portal_setupZMI 中的工具,然后转到“导入”选项卡并选择您想要的配置文件(此处提供的顺序一团糟……您可能会发现一个很长的组合框)。在页面末尾选择“导入所有步骤

于 2014-04-14T11:28:29.480 回答
1

实际上,可以在 Quickinstaller 中显示多个“替代”配置文件 - 您只需要通过为自己的(子)包注册每个配置文件来“欺骗”GenericSetup。

所以诀窍是将配置文件定义放在configure.zcml 驻留在不同包(目录)中的不同文件中,并确保在每个文件中包含<five:registerPackage package="."/>指令。configure.zcml

虽然它有效,但我不确定这个技巧有多值得推荐:我在dexterity.membrane包中找到了它,这里用作示例:

configure.zcml首先,“默认”配置文件在包的主目录中完全正常注册dexterity.membrane。没什么特别的 -但请注意它包括content子包

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="dexterity.membrane">

  <!-- Include configuration for dependencies listed in setup.py -->
  <includeDependencies package="." />
  <!-- Grok the package to initialise schema interfaces and content classes -->

  <i18n:registerTranslations directory="locales" />

  <include package=".behavior" />
  <include package=".content" />

  <!-- Register an extension profile to make the product installable -->
  <genericsetup:registerProfile
      name="default"
      title="dexterity.membrane: behaviors"
      description="Configuration for the dexterity.membrane behaviors"
      directory="profiles/default"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />
  <!-- Note that the example profile is registered in the content
       directory.  It is registered in such a way that both profiles
       are visible and can be installed separately.  Any upgrade steps
       for that profile are also defined there. -->

  <genericsetup:upgradeStep
      title="Update profile"
      description="Dummy step to fix profile registration after rename."
      source="1000"
      destination="1001"
      handler="dexterity.membrane.migration.dummy_step"
      profile="dexterity.membrane:default" />

  <adapter name="Title" factory=".indexers.Title" />

  <!-- -*- extra stuff goes here -*- -->

</configure>

这是configure.zcml所述content子包的:除了(第二个)registerPackage指令和第二个配置文件之外,也没有什么特别的:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="dexterity.membrane">

  <!-- make this show up in the quickinstaller separately -->
  <five:registerPackage package="."/>

  <genericsetup:registerProfile
      name="example"
      title="dexterity.membrane: content"
      description="Configuration for the dexterity.membrane example content type"
      directory="../profiles/example"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

</configure>
于 2015-02-05T11:16:44.690 回答
0

从 Ida 和 Keul 的有用评论中做出回答:

  • (不幸的是)没有替代配置文件之间的选择(这使得“配置文件”这个名称在这里有点误导,IMO)。
  • 为了在配置文件之间切换,我最终拥有了不同的分支。过程是这样的:
    • 转到产品目录并切换到所需的分支,例如git checkout <branch name>
    • 重启 Plone(否则它不会注意到变化,除非同时有新的版本号)
    • 重新安装产品;
    • 一切顺利后,更新buildout.cfg以反映更改。
于 2014-04-22T15:35:13.237 回答