Thanks again for all the advice, guys. I've been tooling around with
my code this week and I think I've made significant (mental) progress
on this issue of building complicated UIs out smaller, well-
encapsulated, reusable pieces. I'll give a full report on that later -
folks may find it useful - but first I'd like to address a new
question that has come up in my explorations:

How do you know when to build middleware?

Let's take authentication as an example. I find myself building a proj/
lib package for handing lots of common authentication operations. The
authentication process makes heavy use of certain parameters of the
request that, by-and-large, the rest of the application doesn't care
about. I started thinking about having my proj/lib code store the
relevant parameters and then delete them from the request. That's what
got me thinking about middleware; permanently modifying the request is
something that middleware - not application code - tends to do.

The fact is that the meat of the application is altogether agnostic to
the authentication process, forcing me to wonder if the authentication
code should "live" inside the application at all. For encapsulation
purposes, it would seem like moving it to middeware makes sense. "Want
to change the auth protocol? Just replace the middleware." Sounds
great, but I'm worried that there may be some GOTCHAs hiding around
the corner.

Any thoughts?

~br

On Aug 6, 10:17 pm, Tim Black <[email protected]> wrote:
> On 08/06/2010 10:53 PM, BrianTheLion wrote:> How should all of the code 
> between HTTP and HTML - and there's
> > a lot of it; the majority, in fact - be encapsulated? How can we best
> > make it reusable?
>
> I think what you want--though I'm not sure--is to make custom
> ToscaWidgets.  http://toscawidgets.org/ Each widget contains its own
> template, JS/CSS, and display logic
> <http://turbogears.org/2.0/docs/main/ToscaWidgets/Creation.html#typica...>.
> You can make a widget to display one photo in a gallery, and make a
> parent widget that wraps up & displays a list of those photo widgets,
> then a parent widget that displays the photo gallery and a sidebar, and
> make your whole page a compound widget
> <http://turbogears.org/2.0/docs/main/ToscaWidgets/Creation.html#compou...>
> full of widgets.
>
> Tim Black

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to