Editing buildout.cfg in Plone from a browser

220 Views Asked by At

I am editing a website using the Plone 4 CMS. The Plone instance I am currently using is hosted by a server to which I don't have access (i.e. I can't FTP this server and edit PHP files).

Although I don't own the server which is hosting this website, I would like to access the buildout.cfg file. Is there a way to edit this file by just logging in on my Plone website, or do I need to have the credentials to manipulate the whole instance of the site with FTP?

When I log in, I can go to a page called Site Setup (screenshot provided). Can I perhaps solve my problem from this page?

Screenshot of the "Site Setup" page

2

There are 2 best solutions below

0
GhitaB On BEST ANSWER

You can't. The buildout.cfg file is used for installing / building your application. So, when you are in Site setup you already are using the running application you want to reconfigure.

You will edit your buildout.cfg then you will run ./bin/develop rb to rebuild it, then you will (re)start the instance of your application. This is when, for example, you will see new add-ons available for activating them from Site setup / Add-ons (the add-ons you added in eggs / zcml / versions sections of your buildout.cfg).

0
Ida On

Theoretically it's possible, the code-example below shows a prototype using a browser-view, which when called:

  • Reads the content of a given page
  • Writes the content to the buildout-config
  • Updates the instance

Practically:

  • You'd need to have access to the file-system, to install an add-on with the browser-view beforehand.
  • One would never want to do this in production, because if errors occur you cannot do much about it then.

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')