Re: 2.2 equivalents for transform.expr() and transform.dynamic()?

"Jonathan Ellis" <[email protected]> Mon, 09 Apr 2007 20:02:25 -0700
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
a bug all right -- try it now with r1348

sorry about that :)

-J

On Mon, 9 Apr 2007 19:22:03 -0400, "Philip Semanchuk"
<[email protected]> said:
> 
> On Apr 9, 2007, at 4:17 PM, Jonathan Ellis wrote:
> 
> > On Mon, 9 Apr 2007 13:18:24 -0400, "Philip Semanchuk"
> > <[email protected]> said:
> >> Thanks. I looked through the response module and I can see how this
> >> works now that you've pointed me to it. I found that I had to add a
> >> dummy flush() method to my class, too, so I ended up with something
> >> like this:
> >>
> >> [[\
> >> class MyOut:
> >>    def __init__(self, out):
> >>      self.out = out
> >>      self.writeStatic = out.write
> >>      self.writeExpr = self.write
> >>    def write(self, s):
> >>      self.out.write(Utf8ify(ReplaceHtmlSpecials(s)))
> >>    def flush(self):
> >>      pass
> >>
> >> response.addFilter(MyOut)
> >> ]]
> >>
> >> However this isn't the equivalent of what I'm doing with the transform
> >> module. The filter above transforms *all* output whereas I only want 
> >> to
> >> run my functions on dynamic output.
> >
> > that should be the difference between writeStatic and writeExpr.  If 
> > not
> > it sounds like a bug.
> 
> I've spent a lot of time looking through response.py, spyce.py, 
> spyceCompile.py, etc. and I can't figure out what's going wrong here. 
> Maybe I'm doing something wrong? It looks like MyOut's writeStatic() 
> and writeExpr() are never called directly; only write is called 
> directly. For instance, using this version of MyOut, I see only !w! and 
> !/w! added to the output stream:
> 
> class MyOut:
>      def __init__(self, out):
>          self.out = out
> 
>      def writeStatic(self, s):
>          self.out.write("!s!" + s + "!/s!")
> 
>      def writeExpr(self, s):
>          self.out.write("!e!" + s + "!/e!")
> 
>      def write(self, s):
>          self.out.write("!w!" + s + "!/w!")
> 
>      def flush(self):
>          pass
> 
> 
> This is despite the fact that this Spyce code --
>     <p>[[="<Dimmesdale!>"]]</p>
> 
> -- compiles to this:
>      response.writeStatic('\n\n<p>')
>      response.writeExpr('<Dimmesdale!>')
>      response.writeStatic('</p>\n\n</body>\n</html>\n')
> 
> 
> Suggestions?
> 
> Thanks
> Philip
> 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV