Randomness (RE: [Zope-dev] CoreSessionTracking 0.8)
Chris McDonough
chrism@digicool.com
Fri, 25 May 2001 16:50:04 -0400
Hi Joachim,
I'm confused as to the utility of this bit of code.
You loop over the items in the REQUEST.form dict, putting them all into
session storage except for 'file'.
Then you loop over all the items in the session data object, putting
them into the REQUEST.other dict.
Why the first step? What if I did:
http://yoursite/amethod?bag=YES&farb=FOO
I'd have both bag and farb in my session data object? Would this be
sufficient instead:
<dtml-let data="SESSION.getSessionData()">
manage="REQUEST.get('manage_content') or
data.get('manage_content')">
<dtml-unless manage>
<dtml-call "data.set('manage_content','NO')">
</dtml-unless>
<dtml-in "data.keys()">
<dtml-let si=sequence-item>
<dtml-call "REQUEST.set(si, data[si])">
</dtml-let>
</dtml-in>
</dtml-let>
I'm also confused why you're using YES and NO to represent a boolean
instead of just checking that a key exists or is true.
Aside from that, the code looks fine to me. Your problem is consistent
with Bjorn's iasmuch as it seems that your session data object gets
cleared inappropriately... but I can't make this happen on my copy of
Zope and CST. :-( Maybe after I look at Bjorn's site, I'll have a few
more clues. Bjorn also provided some additional data that is helpful as
well. I'll try to synthesize this stuff and come up with some sort of
answer next week (I'll be away for the weekend).
- C
Joachim Werner wrote:
>
> > > I know, but that's why the errors are called "random": They are not easy
> to
> > > replicate ...
> >
> > I understand.
>
> I don't know if this helps a bit: It's the code used in KONTENTOR for
> putting the session into the REQUEST namespace. I think it is not the most
> elegant way of doing this, but it seems to work, except for the times it
> doesn't ;-)
>
> The actual problem I can trace (we don't have a shopping cart) is that the
> manage_content variable falls back to "NO" without a reason. Please tell me
> that the problem is in our code, not in the CST:
>
> <dtml-let data="SESSION.getSessionData()">
> <dtml-unless "data.has_key('manage_content')">
> <dtml-call "data.set('manage_content','NO')">
> </dtml-unless>
> <dtml-in "REQUEST.form.keys()">
> <dtml-let si=sequence-item>
> <dtml-unless "si=='file'">
> <dtml-call "data.set(si, REQUEST[si])">
> </dtml-unless>
> </dtml-let>
> </dtml-in>
> <dtml-in "data.keys()">
> <dtml-let si=sequence-item>
> <dtml-call "REQUEST.set(si, data[si])">
> </dtml-let>
> </dtml-in>
> </dtml-let>
>
> Cheers
> Joachim
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )