Hi, I've got the following problem: I want to keep several choices users make during a site visit persistent in memory during their session. Not all of those fields appear on each page or are needed, but the values should still be available all the time so they can be used for various selections. Now I could simply use hidden input fields and carry the values over and over from one page to another, but that seems quite an awkward way to do this. So I store them as Session data, which works fine so far except for if a user opens several browser windows, which however happens quite often. In that case, changes done in one window affect the selection in another window, as there is only one shared session object obviously. Does anyone have an idea what the best way would be to handle this? I'd like to automatically keep values valid that are selected at random times for seperate windows and their subwindows, without affecting values stored for other windows. And all of that hopefully without major changes to various places in the DTML and script files... Thanks in advance, Michael Rinner
There is probably a more elegant solution, but this might work: Create a dictionary on the user_folder (a property field on this folder is stored in RAM for fast access). Store the users HTTP_X_FORWARDED_FOR ip address as the 'key' for the dictionary (display REQUEST and you will see that this field doesn't change if the user spawns several browsers from the same pc/internet connection, however it will change if the user comes from different pc/internet connections). You can then see if any given user is already registered, and you can store a list containing the fields you want to save as the 'value' for the dictionary key. HTH Jonathan ----- Original Message ----- From: Michael.Rinner@cellzome.com To: zope@zope.org Sent: March 12, 2004 9:52 AM Subject: [Zope] Keeping data throughout a session Hi, I've got the following problem: I want to keep several choices users make during a site visit persistent in memory during their session. Not all of those fields appear on each page or are needed, but the values should still be available all the time so they can be used for various selections. Now I could simply use hidden input fields and carry the values over and over from one page to another, but that seems quite an awkward way to do this. So I store them as Session data, which works fine so far except for if a user opens several browser windows, which however happens quite often. In that case, changes done in one window affect the selection in another window, as there is only one shared session object obviously. Does anyone have an idea what the best way would be to handle this? I'd like to automatically keep values valid that are selected at random times for seperate windows and their subwindows, without affecting values stored for other windows. And all of that hopefully without major changes to various places in the DTML and script files... Thanks in advance, Michael Rinner ------------------------------------------------------------------------------ _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Read the manual about session variables. I think that's what you need. On Fri, 12 Mar 2004, Small Business Services wrote:
There is probably a more elegant solution, but this might work:
Create a dictionary on the user_folder (a property field on this folder is stored in RAM for fast access).
Store the users HTTP_X_FORWARDED_FOR ip address as the 'key' for the dictionary (display REQUEST and you will see that this field doesn't change if the user spawns several browsers from the same pc/internet connection, however it will change if the user comes from different pc/internet connections).
You can then see if any given user is already registered, and you can store a list containing the fields you want to save as the 'value' for the dictionary key.
HTH
Jonathan ----- Original Message ----- From: Michael.Rinner@cellzome.com To: zope@zope.org Sent: March 12, 2004 9:52 AM Subject: [Zope] Keeping data throughout a session
Hi,
I've got the following problem:
I want to keep several choices users make during a site visit persistent in memory during their session. Not all of those fields appear on each page or are needed, but the values should still be available all the time so they can be used for various selections.
Now I could simply use hidden input fields and carry the values over and over from one page to another, but that seems quite an awkward way to do this. So I store them as Session data, which works fine so far except for if a user opens several browser windows, which however happens quite often. In that case, changes done in one window affect the selection in another window, as there is only one shared session object obviously.
Does anyone have an idea what the best way would be to handle this? I'd like to automatically keep values valid that are selected at random times for seperate windows and their subwindows, without affecting values stored for other windows. And all of that hopefully without major changes to various places in the DTML and script files...
Thanks in advance,
Michael Rinner
------------------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
(Michael, What follows is not aimed at you, but you were the straw and I'm doing my camel impersonation.) All, I've noticed quite a few HTML formatted emails being sent to this list (and other of the Zope lists) lately. <rant> DOES NO-ONE READ THE FOOTER OF EMAIL ON THIS LIST! </rant> I quote: "Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )" Notice the relevant part - "** No cross posts or HTML encoding! **". This isn't just a personal rant. This topic has been discussed at length on this list, and a consensus was formed - No HTML mail. There are people who I know will not answer your questions if you send HTML formatted mail. So turn it off and you get more responses. OK, normal service will now resume. Phil
(loose the html mail please!) Michael.Rinner@cellzome.com wrote:
Now I could simply use hidden input fields and carry the values over and over from one page to another, but that seems quite an awkward way to do this. So I store them as Session data, which works fine so far except for if a user opens several browser windows, which however happens quite often. In that case, changes done in one window affect the selection in another window, as there is only one shared session object obviously.
You're trying to beat HTML into doing something it's nto designed to do ;-)
Does anyone have an idea what the best way would be to handle this?
Your best bet is to have a "window id" which you send out and then maintain in a hidden input of request path variable which identifies which window is which and use that to create dictionaries in the session for each window... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (5)
-
Chris Withers -
Dennis Allison -
Michael.Rinner@cellzome.com -
Phil Harris -
Small Business Services