#Splat routes with final fixed route segments

18 messages · Page 1 of 1 (latest)

stuck ginkgo
#

I have a use case that right now it's not supported by TSR. I work with a CMS that uses a concept that is called "object traversal" to retrieve the objects stored in the CMS database.

The objects are stored in an objects/documents DB that is able to store them in a hierarchically way (as a file system, with parent/child structure). So they map the way it's stored directly with the natural organization of a website:

/folder/nested-folder/page

in the DB, the folder object is the parent of nested-folder and this one, will be parent of page.

so when the user calls that URL, it traverses the tree until it gets to the page content, then that content is rendered.

We can match this via "splat" routes, all fine.

Then, the tricky part. The traversal concept also accepts the idea of "views" or actions applied to the content objects. Then the edit view becomes:

/folder/nested-folder/page/edit

I noticed this can't be achieved, nor in TSR, nor in any other modern router. We are using RR5, which supported this back then, but I noticed that RR6 does not support it either.

Is that something that it's sensible to add as a feature? is it difficult to achieve?

Thanks for in advance!

vernal sandal
#

can you please create a github issue so this feature request does not get lost here?

stuck ginkgo
#

@vernal sandal sure

#

the frontier between an issue and a feature request is thin sometimes

vernal sandal
#

true

#

you are also welcome to submit a PR that implements this, even if it is just to get this started a bit faster

stuck ginkgo
#

I'd love to, that's why I asked if it would be hard to achieve (because it's not supported in any modern router)

#

if it's doable, having some directions would be great too, just to get started

vernal sandal
#

I can imagine that there might be situations where route matching is ambiguous

#

but we will only know when someone tries it out

stuck ginkgo
#

yeah, it forces you to have "reserved words", so your content can't be named "edit"

vernal sandal
#

maybe @forest forge has tried this before, any comments on this?

stuck ginkgo
#

but the traversal concept is a powerful one, in the Plone/Zope community we've been using it since 20 years ago, in the backend server side Python implementation of the CMS

#

and we are also using it in Volto our React based UI for Plone (using RR5, right now). We need to run from our current (legacy) architecture which is using Razzle and other legacy tools, and we are evaluating options.

forest forge
#

So in terms of TSR, this would be possible, and would mean the segment matching logic would need to be updated to allow for some kind of look behind on a splat route. Eg, first match the splat, then if the splat has children, use the suffix of the splat to continue matching

forest forge
#

This would effectively turn the splat functionality into a more generic multi segment matching utility

#

And that’s how I would implement it