Re: Setting componentCommentLevel within a document

Jacob Smullyan <[email protected]> Wed, 14 Sep 2005 20:22:41 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Wed, Sep 14, 2005 at 04:50:48PM -0700, Gregory Brauer wrote:
> Jacob Smullyan wrote:
> >One way:
> >
> >  import SkunkWeb.Configuration as C
> >  oldLevel=C.componentCommentLevel
> >  C.componentCommentLevel=newLevel
> >  # do whatever ....
> >  try:
> >     doWhatever()
> >  finally:
> >     C.componentCommentLevel=oldLevel
> >
> >
> >Note that this will affect any components called by doWhatever().
> 
> Ok, thanks.
> 
> If I fail to set C.componentCommentLevel back to oldLevel, will all
> future pages served end up with newLevel?

Yes, for that process alone.  So you don't want that to happen!  The
try/finally idiom should definitely be used in such a case.

Does this come up because the component in question isn't producing
content of type text/html?  Perhaps the comments should only be
generated when that content type is currently in effect.  

I've also had this issue in the following situation, in text/html
content-type:

   <:spool somestuff:>
      <:component whatever.comp:>
   <:/spool:>
   <:set somestuff `somestuff.strip()`:>
   <:if `somestuff`:>
      <:#:>etc.<:/#:>

In this case, I want to take some action contingent upon whether
"somestuff" is non-blank.  But "nonblank" isn't a markup-aware
concept, so it will produce the wrong results if component comments
aren't turned off.

js

-- Jacob Smullyan


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php