On Tue, 16 Nov 2004 17:21:38 -0500, Eric Radman wrote:
> I've been working on porting several apps over to the WSGI
> framework, and found minor differences in session handling that
> require code correction:
>
> The current WSGI implementation returns None for uninitialized
> Session variables, whereas WebKit would dump without a try...except
> pair.
>
> Using Webware/WebKit:
>
>
> session =3D self.session()
> try:
> id =3D session['userid']
> except:
> id =3D None
> if id is None:
> """ Error """
> else
> """ Generate Page """
>
>
> Using WSGIKit:
>
>
> session =3D self.session()
> id =3D session._values['userid']
> if id is None:
> """ Error """
> else
> """ Generate Page """
>
>
> This is fine, but session[] always returns None, so I have to use
> _values[]. Is this a bug or intended behavior?
Intended. In cases where Webware objects provide dictionary-like access=
(foo['bar']), they act like Python dictionaries: a KeyError is raised if=
the key does not exist. And typically a get() or getFoo() method is=
provided which can accept a default value to return if the key does not=
exist.
I don't see the point in making something look like a Python dictionary, but=
act differently.
-Chuck
|