[mod_python] "TypeError: argument 2 must be a mapping" and other things

Daniel Winkler mailings at danielwinkler.de
Wed Sep 21 10:40:21 EDT 2005

Hi Jorey,

thanks for you quick help.

> > from mod_python import psp
> > import dirigent
> What's in dirigent?
"Dirigent" is the German word for conductor. A brief overview of the
project: Several conductors (and their helpers) of several choirs
(=Chor) should be able to manage and plan their rehearsals (? sorry, I
am not a native English speaker) etc.
The module "dirigent" contains code to check the incoming request and
identify the calling user. (Authentication is done via SSL certs; no
sessions, because I wanted something "stateless") The current user id
should be stored in "dirigent.id". It should be resolved only once per
request and there is only one single user per request, so I thought I
could store this globally ...

> Things like this will work consistently in the interpreter, but not in 
> all apache MPMs. Do you really need to alter this module attribute in 
> place? I'd look for an alternative, as it's not reliable across 
> environments. Can you simply store it in a normal variable within the 
> function, and return it or process it further?
Yes, I guess I can rearrange this. I thought a global variable could
reduce the calling overhead.

> > def _acltest_ok(chorID, dirigentID):
> Try setting defaults here, just in case:
> def _acltest_ok(chorID = 0, dirigentID = 0):
> But I'm getting the sense that dirigentID may be the suspect. It's 
> interesting that you're trying to set dirigent.id globally, but don't 
> attempt to take advantage of it here. While I'm not advocating it, why 
> aren't you importing dirigent.id directly, instead of passing it as an 
> argument?
Mh, yes, you are right. The idea behind was to leave this more general
so I can check the access control information of other conductors, too,
not only the current user. But as mentioned above, I will try to avoid
the global storage.

> Also, your logic is a little circuitous, and you've mixed ways of 
> dealing with what you expect to be the same variables.
Yes, might be. Maybe it's better to write it new from scratch than
trying to adapt my old PHP code that was written with a slightly
different approach ...

> Just some suggestions, I hope they are helpful.
Thank you very much.

More information about the Mod_python mailing list