Ian wrote:
>Someone else brought up this technique, so maybe someone has a good
>trick for how it should work.
>
>I want to do the technique where some actions give a message back to
>the user -- many times these actions immediately redirect to a more
>useful page, which should then display the results.  So I can store
>the messages in a session variable, and clear them out when I later
>display them.
>
>However, sometimes I don't redirect after the action, and I'd like
>those messages to then display at the top of the page.
>
>So, if I do the standard write-start-page, write-page, write-end-page,
>then I can't do this, because the start of the page is where I want
>those status messages, but they don't get generated until the second
>step.
>
>I could require that anything that will display an immediate status
>message should do so in awake, but that seems too difficult.  I'd
>almost prefer to reorganize Page if it really is necessary.

I've also run into situations where this would be useful, but I've just 
worked around them.  Here's an idea.  Ordinarily your writeContent() method 
will look something like:

         def writeContent():
                 self.writeBeginning()
                 self.writeMiddle()
                 self.writeEnd()

But suppose you want to re-arrange the order in which these are 
processed.  You could do something like:

         def writeContent():
                 middle = self.capture(self.writeMiddle)
                 self.writeBeginning()
                 self.write(middle)
                 self.writeEnd()

where self.capture is a helper method that causes its argument to be 
executed, but all self.write() and self.writeln() are captured and returned 
as a string instead of being sent out.

I leave the implementation of self.capture() up to the reader :-)  Also, 
I'm curious if people think this is a good approach.


--

- Geoff Talvola
   [EMAIL PROTECTED]

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to