I am generating an xml file in python, I need to save it to my plone site but am unsure how to.
def generate_sitemap_index_file(self, sites):
""" Generate a google sitemap index file
"""
root = ET.Element("sitemapindex")
for site in sites:
sitemap = ET.SubElement(root, "sitemap")
loc = ET.SubElement(sitemap, "loc")
loc.text = self.aq_parent.absolute_url() + "/googlesitemap/" + site
ET.ElementTree(root).write("sitemap_index.xml")
This function saves the file into my zinstance
folder, but zope isn't aware of it.
I'm unsure you really need to see this file as a Plone content. Probably you simply need to expose the file when calling
http://something/sitemap_index.xml
You can simply add it as a Zope File from ZMI (in this way the file will be available, but will not be a CMS content) or publish it using Apache/NGIX in front of Plone.
You can create a content object called File in Plone. See: http://docs.plone.org/external/plone.api/docs/content.html#create-content
Here an untestet example to give you a guess:
Make sure you have added plone.api in your buildout.cfg eggs part! This script you can run from commandline:
But as a side note, you can let Plone build you a sitemap_index.xml.gz, just enable it in site_setup > main.