Re: [Cheetahtemplate-discuss] what to do with varNotFound_handler
Brought to you by:
rtyler,
tavis_rudd
From: Chuck E. <Chu...@ya...> - 2001-08-09 15:57:21
|
At 11:10 PM 8/8/2001 -0700, Tavis Rudd wrote: >Hi, >I'm going to play the devil's advocate and argue against >varNotFound_handler for the time-being, although I think I >like it. I'll play Cheetah-users' advocate. :-) >* Why do you consider it necessary? Because in both my publishing systems (I have 2 now: A whiz bang one for the consulting job and a homebrew one), I want the system to do it's best to spew me my web site. And because down the line, I will discover other useful things to do with this hook to enhance my applications. >* Why is it a neat 'feature'? As a hook, I can do even more. For example, I could generate a report stating what documents had problems and what variables weren't found. I could even provide links to the documents complete with an anchor to take me straight to the error. >* In what real-world situations would it be useful? You still get to see your page (eg output), even if it's not perfect. That's useful for demos, bootstrapping, show the boss your work-in-progress, ... Plus you will get bugged on the list every 4 weeks by a newbie who asks "How can I customize what happens when [a] a variable is not found and [b] a variable value is None?" :-) >* Isn't it safer for an explicit exception to be >raised, as it would be in Python when a var is referrenced >before it is declared? Publishing!=Programming. When I'm perusing the draft version of my site, one "not found error" is not a deal breaker. Each app should be able to make this decision. >* Should it work with $placeholders that contain normal >Python syntax (brackets, slices, etc.) as well? That would be nice for consistency reasons. >*What happens when the varNotFound is inside a $funcCall() >or an #if $test directive? Should varNotFound only be used >with the top-level $placeholder tags that are outside >#directives? I could certainly live with the hook being only for the purposes of output/substitution. #if's and $func()s can be wary of the issue by using hasName(). On the other hand, invoking hasName() for every $var in every template is tedious and then begs for either a Cheetah enhancement or a Cheetah-preprocessor. BTW You obviously thought this was a good idea at some point because you were the one who put it in. ;-) -Chuck |