another way to state this: partials are language from one very (too) narrow use case.The general case is that page CONTAINERS manage output, and decay to one container per page (or the partials sort of idea that were mentioned).Now - controller logic is just engineering logic - implementation of solution / output;Containers, and the protocol to connect output (URI) to a container is view logic...This is important, because this is how outupt to one page (for example for PyCon) can be collected from controller outupt from 2 frameworks (django or web2py)....And this is where this concept shows the boundaries that are appropriate (the other end of the boundary - even if you never want to combine output from elsewhere, the point is still that level of separation is desireable).Come to think of it, another place to look is what do Yahoo Pipes do? That is 3 places to look, and gather ideas: Yahoo Pipes, jsr Portlets, .Net / what dotnetnuke uses to implement application containers...This last piece is where web2py can start: think about how to have "portlets" that can (for example) be connected to web2py application output.
Yarko most systems just use iframes. You can put anything you want
into an iframe.
I think Yarko makes excellent points. I too am looking for the
natural way to express components in Web2py and the code proposed by
Massimo originally did not look general enough. The better job we do
at abstracting this and generalizing it, the more capable the web2py
platform will be.
One of the most interesting approches I have seen is "Seaside" -- the
Smalltalk web app engine. Seaside relies on "continuations" in
Smalltalk to keep state while the user interacts with different
applets on a page. It is unclear to me if continuations are needed to
make this work, or just an easier way to accomplish it. For one
thing, it lets the developer keep objects in his state without needing
to render them as strings and pass them through request and response
vars. (I think.) Here is a description of Seaside. It did "ajax"
before AJAX was invented.
http://scg.unibe.ch/archive/papers/Duca04eSeaside.pdf
Note to self. Things to be fixed:
1) the action needs knowledge on whether it is in a container.
Solution: add a header that says so.
2) the action response needs to be able to reference other containers
in order to trigger actions there. Right now each container is
identified by a unique but random id and there is no way to guess it.
Solution: have the user specify the "name" of each container.
3) if a container contains a form that selft submit and then redirect
the content to a another action that also has a form. This second form
will not work properly. Solution 1: the programmer needs to specify
the [SQL]FORM(_action=) but this is a problem form legacy code that
you want to ajaxify. Solution 2: have the jDiv code automatically
determine the action from context.
4) right now every container has a link (that triggers the loading of
the content) and a div with the content. To what extent should this be
customizable? For example, you may want the container to have a top
bar with additional buttons. Should this customization be a feature of
the current container class (jDiv) or should the class be subclassed?
This opens a big can of worms since the "frame" of the components
needs to have some standard hooks in order to expose functions like
"reload the content", "close it", etc. (what else?).