At 12:50 PM 12/18/01 -0600, Ian Bicking wrote:
>I've got a situation, the solution which I've used I'm not quite happy
>with.  I was wondering if someone else had a thought...
>
>Right now there are at least three ways in which a page can be aborted
>-- it can require a login, you can get a permission denied error, or you
>can do a redirect.  Since I've started doing stuff in awake(), this
>means I have to check in awake() if one of those conditions is true, and
>abort immediately.  Then writeContent() or writeHTML has to abort as
>well.
>
>I found this awkward to do.  I set two instance variables to tell
>whether one of these conditions occurred, so that writeContent or
>writeHTML would abort (with a redirect, writeHTML is aborted, but for
>login or permission denied, just writeContent is aborted).
>
>Normally, I might use a try:except: to capture these situations, or some
>other sort of factoring... but because awake() and respond() are
>completely seperate, I don't know how to deal with this.  I can't
>optionally call (or not call) respond() from awake().  I really hate
>having flag variables, and the logic becomes more and more awkward as I
>add more exceptions to SitePage.
>
>So how have other people dealt with this?

I'm using a flag instance variable that I set in awake(), and I've 
overridden respond() sort of like this:

class SitePage(Page):
     def respond(self, trans):
         if not self.shouldSkipRespond:
             Page.respond(self, trans)

The other option would be to modify WebKit so that there's some pre-defined 
exception that you can raise that will basically stop processing the 
servlet at that point and send whatever response has been accumulated so 
far.   Seems useful to me.  Patches accepted :-)


--

- Geoff Talvola
   [EMAIL PROTECTED]

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

Reply via email to