从浏览器编辑Plone中的buildout.cfg

问题描述 投票:1回答:2

我正在使用Plone 4 CMS编辑网站。我目前使用的Plone实例由我无法访问的服务器托管(即我无法FTP此服务器并编辑PHP文件)。

虽然我不拥有托管此网站的服务器,但我想访问buildout.cfg文件。有没有办法通过登录我的Plone网站来编辑这个文件,或者我是否需要凭据来操纵FTP的整个网站实例?

当我登录时,我可以转到名为Site Setup的页面(提供屏幕截图)。我可以从这个页面解决我的问题吗?

Screenshot of the "Site Setup" page

content-management-system plone buildout diazo
2个回答
1
投票

你不能。 buildout.cfg文件用于安装/构建您的应用程序。因此,当您进入站点设置时,您已经在使用要重新配置的正在运行的应用程序。

你将编辑你的buildout.cfg然后你将运行./bin/develop rb来重建它,然后你将(重新)启动你的应用程序的实例。例如,您将看到可用于从站点设置/加载项(您在buildout.cfg的eggs / zcml / versions部分中添加的加载项)激活它们的新加载项。


2
投票

理论上它是可能的,下面的代码示例显示了使用浏览器视图的原型,在调用时:

  • 读取给定页面的内容
  • 将内容写入buildout-config
  • 更新实例

几乎:

  • 您需要访问文件系统,才能预先安装浏览器视图的附加组件。
  • 人们永远不会想要在生产中这样做,因为如果发生错误,那么你就无法做很多事情。

import os
from Products.Five.browser import BrowserView


class View(BrowserView):

    def __call__(self):

        # Let's assume these paths exist:
        instance_path = '/path/to/instance'
        buildout_config_path = instance_path + 'buildout.cfg'
        page_path_in_site = 'front-page'

        # Read buildout-config of page in site:
        page = self.context[page_path_in_site]
        config_content = page.getText()

        # Write buildout-config to filesystem:
        with open(buildout_config_path, 'w') as fil:
            fil.write(page.getText())

        # Run buildout, so changes in config take effect:
        os.system(instance_path + 'buildout')

        # Restart server, so python- and zcml-files get
        # (re-)compiled, respectively loaded:
        os.system(instance_path + 'bin/instance restart')
© www.soinside.com 2019 - 2024. All rights reserved.