[Web-SIG] Standardized template API

Phillip J. Eby pje at telecommunity.com
Fri Feb 3 04:07:58 CET 2006


At 07:07 PM 2/2/2006 -0600, Ian Bicking wrote:
>Phillip J. Eby wrote:
>>At 01:48 PM 2/2/2006 -0500, Michael Bayer wrote:
>>
>>>Can those of us who
>>>have worked less with "the high end" see some real examples of what
>>>they need, and how they will be marginalized by a template adapter
>>>API?
>>
>>Have you ever used PHP?  ASP?  DTML?  Specifically, have you ever used 
>>them to generate any content-type other than HTML?  This is a trivial 
>>example of a use case that a vars'n'strings approach doesn't support, 
>>without basically reinventing a new protocol that duplicates WSGI.
>
>Yes, I've used them, and they work pretty much like the example WSGI app
>I gave.  There are functions -- callbacks from our perspective -- that
>let you set the headers.  All the output is sent on to the browser, or
>perhaps returned as a string.  Though usually there is no "return"
>value, it is all sent to the browser -- for instance, if you wanted to
>capture the output of a PHP template included from another template, I
>believe you have to essentially redirect output, run the other PHP
>script, then restore output and get the text that was captured.  There's
>no particular support for capturing other information, like headers that
>were set.  This sounds like a dumb design, you say?  Sure, but we can be 
>dumb-design-compatible!
>
>DTML allows capturing, but no special support for headers or metadata.
>And I guess it has the concept of a return value, but I suppose I've
>never understood or used that, since Python Scripts existed by the time
>I started using DTML, and they handled those kinds of cases better.

I don't understand what you're trying to say here at all.  What's all this 
stuff about return values?  My only reference to return values was WSGI 
application return iterables, which are an implementation detail and 
nothing to do with some sort of template return value.


>I dunno, I just don't get it when it comes to template-as-WSGI-apps.
>And if it's gettable, I kinda feel like I should get it.  So I'm not sure 
>it's going to make sense to people.

Trying to keep it as simple as possible:

Step 1.  Pretend that Apache could run DTML pages from .dtml files, using 
the Zope request/response API to look at request contents, or a PHP/ASP API 
for manipulating headers or request data.

Step 2.  Take away Apache and replace it with WSGI.  Take away DTML and the 
Zope API, and replace it with your choice of template language and 
associated request/response API.

Voila.  You can now run arbitrary active resources in any framework that 
supports WSGI embedding.  And that would include frameworks like 
TurboGears, they'd just be putting additional data in the WSGI request fed 
to the template engine.



More information about the Web-SIG mailing list