Capture XML Output From Rapido Function

As per the below link:

There is an issue with MultiLingual on Plone 5 in which the site map XML file is empty.

I have been messing around with Rapido and have almost got a working site map, I am just having an issue with actually capturing the outputted XML from my Rapido element.

Here's my code & what not:

Folder Structure

++theme++ --|-rapido ----|-sitemap ------|-blocks --------|-sitemap.html --------| --------|-sitemap.yaml
The .html file just has {sitemap} in it, nothing else.


elements: sitemap: type: ACTION

When I change type: in the YAML file to BASIC I get the following output:

So then changing type: in the sitemap.yaml file back to ACTION and instead calling this URL:

This redirects me to<insert my XML above here, minus the HTML parts>

In summary

I'm trying to get an on-the-fly rendered sitemap - whenever the URL is called, I've got the XML part fine, however capturing and displaying the XML in the browser is proving to be difficult. Is this do-able and if so, how?

Final note

For some reason this thing hasn't rendered my code properly, I hope you can make sense of the above but let me know if you need more information.


Edit 1:

I've had to replace the code sections for Pastie links because the editor seems to be having difficulty with my Python and XML.

You were almost good, you were right about calling the element URL instead of the block URL.
Just declare your element as BASIC (not ACTION, because actions used the returned value as an URL redirection, whereas elements just render the value), and should work (I tried it, it works on my machine).

Note: you can remove your HTML file, it is not used here.

@danboggins I'm working on a PR to rapido to make it a little more intuitive to do a change like you are doing.

It would let you use a url like and a single with something like

def on_display(context):
   return ('text/xml','<xml...')

or maybe

def on_display(context):
   return '<xml...'

No elements, yaml or html template needed.

It would also be nice @ebrehault if there was a concept of a default block so we could have a url like

A default block could be nice but how would we guess what it does?
If we make a block for handling different content rules for instance, calling the block means nothing.

@ebrehault maybe just have blocks/init,py ? Same as any other block except the view url is shorter. Although I guess that could be confusing as you might expect code in to be run on every request?
I'm not sure what you mean by content rules.

I mean actual Plone content rules, we can trigger a rapido element call from a content rule (like: everytime we publish a News Item in such folder, then do "that", "that" being custom code implemented in a rapido element), see
I also plan to use Rapido to be able to implement vocabularies for instance.

So when a block contains such element, or elements to return JSON only, there is no purpose in rendering it, that's why I am nt sure about this default block rendering thing.

Thanks @ebrehault that fixed it!

@ebrehault The idea I have is that if you have a very simple usecase such as a single function to return some json, creating apps then blocks then elements seems very "scafoldy". Which developers seem to hate. It feels unnecessary. So the idea is you can use on_init in a block if you don't want to create elements via yaml. and your url goes from @@rapido/sitemap/blocks/sitemap/sitemap to @@rapido/sitemap/blocks/sitemap

and if you want shorter urls then you can put that on_display inside an block (or maybe called something else) so you can use an even shorter url of @@rapido/sitemap.

But it doesn't stop you referencing rapido code from content rules etc. You just might have to make the UI a little smarter you can point to either a element, a block or an app, rather than blocks only.

@ebrehault btw, I have an idea how we could shorten the urls even more by creating dynamic first class views. ie so we can have @@sitemap. I think it's possible.

ok I see
yes it makes sense

Yes it is possible, during the sprint we have add an event in plone.resource so we can now be aware of something has been created in the theme, and so we can for instance register a view (or a mosaic title, or a vocabulary, etc.)

Plone Foundation Code of Conduct