[Zope] Re: HappySession

Hung Jung Lu hungjunglu@hotmail.com
Fri, 01 Sep 2000 07:56:19 PDT


>From: Diego Rodrigo Neufert <diego@magicwebdesign.com.br>
>...
>too... well, in the standard html header I call call a method that do a 
>call in
>all my sessions....

Okie, now I see why you get the Transaction error problem. After an 
exception is raised, Zope aborts the http request transaction, and any 
attempt to further use Zope objects that are transaction-aware will cause an 
error. In the next release of HappySession I will try to detect whether the 
transaction has ended, and return some meaningless result like None. But the 
real thing is, after the exception happens, SESSION object should not be 
called again.

If you really need to call SESSION in your standard_html_header, then please 
do two things:

(1) Please use a standard_error_message, and it should start with something 
like:

  <dtml-if "not error_message and error_type == 'SessionNotFoundError'">
    <dtml-return session_not_found_html>
  </dtml-if>

  <!--#var standard_html_header-->

  <!--#if error_message-->
   <!--#var error_message-->
  <!--#else-->
   ....

(2) In your session_not_found_html, please do NOT use <dtml-var 
standard_html_header>. Instead, write another DTML and call it 
session_ended_html_header, and use it instead. Inside your 
session_ended_html_header, please do NOT call the SESSION object.

>I have two SESSION objects, one in the root of zope and
>other in the opt folder of zope.... look how I call the SESSIONS....
>in standard_html_header
><dtml-call callSession>
>
>The callSession method:
><dtml-call SESSION>
><dtml-call opt.SESSION>

(Hmmm... multiple SESSION objects... in typical situations usually one 
single SESSION object should be enough. Notice that two SESSION objects mean 
two separate storage. Although HappySession is designed to handle multiple 
SESSION objects sharing the same key cookie, the expiration time might be a 
tricky issue... I do not recommend multiple SESSION objects.)

The thing I don't understand is why you need to make explicit call to the 
SESSION objects. Ohh...! I see, you probably think that SESSION objects need 
to be initialized? OK, unlike FSSession or SQLSession, HappySession's 
SESSION objects do NOT need to be initialized! You don't need to make an 
explicit call to SESSION in your standard_html_header. HappySession is smart 
enough to initialize itself whenever you touch it the first time using any 
of its methods. No explicit initialization call needed.

(I'll add an observation on this in the help file in the future.)

---------------------

In short, I think that by simply removing your callSession method and its 
reference in standard_html_header, you will be fine and happy! :)

regards,

Hung Jung

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.