Notes: Cannot use Javascript or iframes. In fact I can't trust the client browser to do just about anything but the ultra basics.
I'm rebuilding a legacy PHP4 app as a MVC application, with most of my research currently focused with the Pylon's framework.
One of the first weird issues I've run into and one I've solved in the past by using iframes or better yet javascript is displaying a dynamic collection of "widgets" that are like digest views of a typical controller's index view.
Best way to visualize my problem would be to look at Google's personalized homepage. They solve the problem with Javascript, but for my scenario javascript and pretty much anything above basic XHTML is not possible.
One idea I started working on was to have my Frontpage controller poll a database or other service for the currently activated widgets, then taking a list of tuples/dicts, dynamically instantiate each controller and build a list/dict of render sub-views and pass that to the frontpage view and let it figure things out.
So with peusudo code:
Get request goes to WSGI
WSGI calls pylons
Pylons routes to Frontpage.index()
Frontpage.index()
myViews = list()
for WidgetController in ActiveWidegets():
myViews.append(subRender(WidgetController, widgetView))
c.subviews = myViews
render(frontpage.mako)
Weird bits about subRender
- Dynamically imports controllers via
__import__
(currently hardcoded to project's namespace :( ) - Has a potential to be very expensive (most widget calls can be cached, but one is a user panel)
I feel like there has to be a better way or perhaps a mechanism already implemented in WSGI or better yet Pylons to do this, but so far the closest I've found is this utility method: http://www.pylonshq.com/docs/en/0.9.7/modules/controllers_util/#pylons.controllers.util.forward but it seems a little crazy to build N
instances of pylons on top of pylons just to get a collection views.