class Edit(Page):
def writeContent(self):
# display the form
# where <form action="doEdit">
# and pull data from session if it's thereclass doEdit(Page):
def awake(self, transaction):
Page.awake(self, transaction)
# process the data in self.request().fields()
# on error:
# set session to values from Edit.py
# self.sendRedirect('Edit')
# on succeed:
# clear session, and
# self.sendRedirect('Display')class Display(Page):
def writeContent(self):
# display the object in questionThe reason I like to do it this way (and maybe there's a better solution to it) is that if I put all of this functionality into one servlet using actions and the _action_=<action> keyword in the form, then that posted form data is still there in the browser and once a person has edited the data and is viewing their changes, they can hit refresh/reload and the browser will want to repost the data.
The problem, though, is that IE gives us problems like you mentioned in that it is very unreliable when setting cookies and doing redirects at the same time.
Does anyone else have a successful pattern they use when dealing with this?
--Tracy
On Friday, November 21, 2003, at 08:47 AM, Max Ischenko wrote:
I (and probably other) have struggled a nasty problem occurred when WebKit used as an application server behind a IIS. Here I'd like to give a simple solution for those interested and (may be) to be included in the next Webware release.
Problem description: When you put some data on your session object and redirects to another WebKit page you don't find the data. In fact, you could discover that you have another (brand new) session object!
Explanation: This is due to the fact how WebKit implements session support and how IIS handles redirects (HTTP 303). When new session is created, WebKit sets cookie _SID_ and pass it along with response (which happened to be a redirect). But unfortunately, IIS don't pass the redirect to browser. It does "internal redirect" and goes for the url specified in it. While doing this the _SID_ cookie is lost and WebKit starts another new session as it doesn't see the SID.
Solution: Pass _SID_ in a URL instead of a cookie so that it wont lost. WebKit would check the query string as well when looking for > SID.
Here is how I do it (in my custom Page class):
def injectIntoUrl(url, name, value): "Injects a parameter with specified name and value into URL." if '?' in url: return "%s&%s=%s" % (url, name, value) else: return "%s?%s=%s" % (url, name, value)
class SitePage(Page): # ... def sendRedirectAndEnd(self, url): sid = self.session().identifier() url = injectIntoUrl(url, '_SID_', sid) Page.sendRedirectAndEnd(self, url)
Hmm. Just realized that is not a perfect solution if redirect can go outside WebKit, so an improvement is wellcomed.
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
