collective / rapido.core

2 stars 2 forks source link

urls are wrong when using diazo without AJAX #20

Open djay opened 8 years ago

djay commented 8 years ago

User problem

If you replace a block using diazo e.g.

   <replace css:content-children="#content-core" if-path="census">
        <include css:content="form" href="@@rapido/myapp/block/top" />
    </replace>

The urls generated are relative to the subrequest ie @@rapido/myapp/block. This means any absolute paths, actions etc all end up going the direct rapido view. Using AJAX fixes this but you don't always want to use ajax.

Options

Smart request

The rapido view could manipulate the request based on how its called. If its a subrequest it could switch the requests such that request = request.parent_request. Diazo blocks will not only build html with urls that work better, but it will be easier to get at the request data submitted.

Perhaps this can be turned off or on based an a request var e.g. @@rapido/myapp/block/myblock?use_parent_request=1. Or perhaps this can be done in diazo itself e.g.

<include css:content="form" use_parent_request="true" href="@@rapido/myapp/block/top" />
ebrehault commented 8 years ago

Playing with the current request is most part of time very dangerous and produce unexpected bad behaviors soon or later. I picked the AJAX approach because it is clearly the safer one. I will try to think about a solid alternative on the backend side.

Note: it will definitely not be done with Diazo as subrequests are produced by the XSLT engine itself, and I really don't plan to do C++ hacks here :)