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 = self.session()
> try:
> id = session['userid']
> except:
> id = None
> if id is None:
> """ Error """
> else
> """ Generate Page """
>
>
> Using WSGIKit:
>
>
> session = self.session()
> id = 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




-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Webware-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to