[Zope] session data object question

2009-03-11 Thread Dvir Bar-lev
Hi 

 

I was wondering if there is a way to connect the creation of a session
object to a button push.

I'll explain in more detail:

 

I have a log in from called login_form, and I have a dtml method called
looged_in that is called when we push the submit button in the log in
form.

What I did is the following, in the log_in_form I get a session data
object only if it exsists and I check how much time passed and act
accordingly, in the looged_in method I create the data session oblject
ans set the start time.

Unfortuantly that is not good for me because if a user refreshes the
page it resets the time in the session object, I was wondering if there
is a way for me to know if I can reset the session data time only when
the user clicks the submit button and not as a result of a refresh call.

 

I tried looking on the web and in the zope book but I couldn't find
anything.

___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Andrew Milton
+---[ Dvir Bar-lev ]--
| Hi
| 
|  
| 
| I was wondering if there is a way to connect the creation of a session object
| to a button push.
| 
| I?ll explain in more detail:
| 
|  
| 
| I have a log in from called login_form, and I have a dtml method called
| looged_in that is called when we push the submit button in the log in form.
| 
| What I did is the following, in the log_in_form I get a session data object
| only if it exsists and I check how much time passed and act accordingly, in 
the
| looged_in method I create the data session oblject ans set the start time.
| 
| Unfortuantly that is not good for me because if a user refreshes the page it
| resets the time in the session object, I was wondering if there is a way for 
me
| to know if I can reset the session data time only when the user clicks the
| submit button and not as a result of a refresh call.

Name the submit button and check for the name of the button in the request.

input type=submit name=theButton value=Press Me

theButton will appear in REQUEST (and REQUEST.form) if the button was
pressed.


-- 
Andrew Milton
a...@theinternet.com.au
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Dvir Bar-lev
Hi

I have a button like that but the the problem is that it also has this
value if I refresh the page, what I mean Is this, I put in the logged_in
page:

dtml-if Request.has_key('theButton')
Do something
/dtml-if

And it has the key even if I refresh the page.

I also tried to put dtm-var theButton to see if it keeps this value
after we refresh the page and it does.
What I need is a way to know if we loaded the page as a result of
pressing the button or as a result of refreshing the page, as I need to
do different things in each case.

-Original Message-
From: Andrew Milton [mailto:a...@theinternet.com.au] 
Sent: Wednesday, March 11, 2009 10:15 AM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] session data object question

+---[ Dvir Bar-lev ]--
| Hi
| 
|  
| 
| I was wondering if there is a way to connect the creation of a session
object
| to a button push.
| 
| I?ll explain in more detail:
| 
|  
| 
| I have a log in from called login_form, and I have a dtml method
called
| looged_in that is called when we push the submit button in the log in
form.
| 
| What I did is the following, in the log_in_form I get a session data
object
| only if it exsists and I check how much time passed and act
accordingly, in the
| looged_in method I create the data session oblject ans set the start
time.
| 
| Unfortuantly that is not good for me because if a user refreshes the
page it
| resets the time in the session object, I was wondering if there is a
way for me
| to know if I can reset the session data time only when the user clicks
the
| submit button and not as a result of a refresh call.

Name the submit button and check for the name of the button in the
request.

input type=submit name=theButton value=Press Me

theButton will appear in REQUEST (and REQUEST.form) if the button was
pressed.


-- 
Andrew Milton
a...@theinternet.com.au
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Dvir Bar-lev
I also tried to change the value of theButton key like so:

dtml-if REQUEST.has_key('submit') 
  dtml-if REQUEST.get('submit') == 'Login'
dtml-call REQUEST.set('submit', 'LoggedIn')
  /dtml-if 
   /dtml-if

But if refresh the button it still thinks it has the value Login instead
of the value LoggedIn :(

-Original Message-
From: zope-boun...@zope.org [mailto:zope-boun...@zope.org] On Behalf Of
Dvir Bar-lev
Sent: Wednesday, March 11, 2009 10:33 AM
To: zope@zope.org
Subject: Re: [Zope] session data object question

Hi

I have a button like that but the the problem is that it also has this
value if I refresh the page, what I mean Is this, I put in the logged_in
page:

dtml-if Request.has_key('theButton')
Do something
/dtml-if

And it has the key even if I refresh the page.

I also tried to put dtm-var theButton to see if it keeps this value
after we refresh the page and it does.
What I need is a way to know if we loaded the page as a result of
pressing the button or as a result of refreshing the page, as I need to
do different things in each case.

-Original Message-
From: Andrew Milton [mailto:a...@theinternet.com.au] 
Sent: Wednesday, March 11, 2009 10:15 AM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] session data object question

+---[ Dvir Bar-lev ]--
| Hi
| 
|  
| 
| I was wondering if there is a way to connect the creation of a session
object
| to a button push.
| 
| I?ll explain in more detail:
| 
|  
| 
| I have a log in from called login_form, and I have a dtml method
called
| looged_in that is called when we push the submit button in the log in
form.
| 
| What I did is the following, in the log_in_form I get a session data
object
| only if it exsists and I check how much time passed and act
accordingly, in the
| looged_in method I create the data session oblject ans set the start
time.
| 
| Unfortuantly that is not good for me because if a user refreshes the
page it
| resets the time in the session object, I was wondering if there is a
way for me
| to know if I can reset the session data time only when the user clicks
the
| submit button and not as a result of a refresh call.

Name the submit button and check for the name of the button in the
request.

input type=submit name=theButton value=Press Me

theButton will appear in REQUEST (and REQUEST.form) if the button was
pressed.


-- 
Andrew Milton
a...@theinternet.com.au
___
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 )
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Andrew Milton
+---[ Dvir Bar-lev ]--
| Hi
| 
| I have a button like that but the the problem is that it also has this
| value if I refresh the page, what I mean Is this, I put in the logged_in
| page:

That is highly unlikely, unless you are refreshing AFTER you submit the
form, in which case you are essentially re-submitting the form.

I would suggest setting a cookie with a timestamp.

-- 
Andrew Milton
a...@theinternet.com.au
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Dvir Bar-lev
Yep I refresh after, I'll try to work with cookies than, tx

-Original Message-
From: Andrew Milton [mailto:a...@theinternet.com.au] 
Sent: Wednesday, March 11, 2009 11:13 AM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] session data object question

+---[ Dvir Bar-lev ]--
| Hi
| 
| I have a button like that but the the problem is that it also has this
| value if I refresh the page, what I mean Is this, I put in the
logged_in
| page:

That is highly unlikely, unless you are refreshing AFTER you submit the
form, in which case you are essentially re-submitting the form.

I would suggest setting a cookie with a timestamp.

-- 
Andrew Milton
a...@theinternet.com.au
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Lennart Regebro
On Wed, Mar 11, 2009 at 09:32, Dvir Bar-lev dvi...@puresight.com wrote:
 What I need is a way to know if we loaded the page as a result of
 pressing the button or as a result of refreshing the page, as I need to
 do different things in each case.

There is no difference between a refresh and a normal page load.

-- 
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
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 )


Re: [Zope] session data object question

2009-03-11 Thread Andrew Milton
+---[ Lennart Regebro ]--
| On Wed, Mar 11, 2009 at 09:32, Dvir Bar-lev dvi...@puresight.com wrote:
|  What I need is a way to know if we loaded the page as a result of
|  pressing the button or as a result of refreshing the page, as I need to
|  do different things in each case.
| 
| There is no difference between a refresh and a normal page load.

Unless you refresh after the form submit :-)

Of course if the broken design posted to a handler script instead of to
itself, a lot of problems could be side-stepped :-)

-- 
Andrew Milton
a...@theinternet.com.au
___
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 )