durusmail: quixote-users: [PATCH] Sessions -- dbm & id is None
[PATCH] Sessions -- dbm & id is None
[PATCH] Sessions -- dbm & id is None
2003-05-27
2003-06-19
[PATCH] Sessions -- dbm & id is None
Mark Bucciarelli
2003-06-22
On Wednesday 18 June 2003 10:23 pm, Greg Ward wrote:
> On 27 May 2003, Mark Bucciarelli said:
> > if you try to delete a dbm mapping entry by passing in a key that
> > is None, you raise a TypeError.
>
> Sorry, do you mean that this:
>
>   foo = dbm.open(...)  # or whatever
>   foo[None] = 1
>   del foo[None]
>
> raises TypeError?  If so, that's clearly a bug in the dbm module,
> and not really Quixote's problem.  If not, what *do* you mean?

yes, keys in dbm modules must be strings.

if someone uses the shelve module for session persistence, and a
client has cookies turned off, quixote tries to delete the session
associated with the key None (and raises an untrapped TypeError).

actually, just catching the exception is fixing the symptom and not
the cause--the real question is why doesn't quixote recognize that if
a session key is None then there is no session data to delete.

--
Mark Bucciarelli, www.hubcapconsulting.com
    He who receives an idea from me, receives instruction himself
without lessening mine; as he who lights his taper at mine receives
light without darkening me.   -- Thomas Jefferson


reply