[ZPT] "structure" and TAL interpretation

Jean-Michel Hiver jhiver at mkdoc.com
Fri Jul 23 13:27:05 EDT 2004


Fred Drake wrote:
> On Fri, 23 Jul 2004 16:19:20 +0100, Fergal Daly <fergal at esatclear.ie> wrote:
> 
>>So I think the docs don't correspond with the current behaviour at all.
>>Presumably anyone using this found it by accident or by reading the code,
> 
> 
> Agreed.  The current behavior is an undocumented extension, so is
> generally a bad idea.  My concern about simply fixing it is that it's
> been there a while and someone could actually be relying on it.  ;-( 
> It's *really* obscure, but people use lots of obscure things in Zope
> 2.

Well, there's almost always ways to improve things without breaking 
backwards compatibility...

Just an idea of a 'heuristic':

* if the returned value doesn't have markup that looks like XML (i.e. it 
must contain at least one '<' and one '>', then the possiblity of using 
tal: statements is ruled out.

* if the returned value contains the URI 
http://xml.zope.org/namespaces/tal, then you're pretty sure it's 
something that needs evaluating.

* if the returned value does not contain the URI
http://xml.zope.org/namespaces/tal, then you can look at what the 
current prefix is, and see if there are anything that looks like "tal:" 
(or whatever the current prefix is). If there isn't, then you know it's 
not something that needs evaluating.

* if the string indeed looks like XML and looks like it's got tal stuff 
in it, then the odds are that it needs to be evaluated. So evaluate it.

All the stuff above requires is being able to search a substring within 
a string. And well, that should be pretty fast.

Does this make sense?
Or is it already what you're doing?


More information about the ZPT mailing list