Damjan wrote: > > The Apache Software Foundation and The Apache HTTP Server Project are > > pleased to announce the 3.2.5 Beta release mod_python. > http://www.modpython.org/live/mod_python-3.2.5b/doc-html/hand-pub-alg-auth.html > > says "Since functions cannot be assigned attributes,..." > > But that's not true (at least in 2.3 and 2.4): > > >>> def f(): > ... return 'a' > ... > >>> f.__auth__ = {1:'one'}
The documentation was originally written when mod_python supported 2.1 and 2.2. :-) Anyway, whether it can now be done is irrelevant as the next part of the documentation states: Note that this technique will also work if __auth__ or __access__ is a constant, but will not work is they are a dictionary or a list. Thus I suspect (but can't confirm right now), that your example will not work anyway as __auth__ defined within the scope of the function as a dictionary will not be seen as a constant as required. Overall, I would not recommend relying on nesting __auth__ or __access__ within the scope of a published function like this as the code which supports this feature is somewhat fragile. http://issues.apache.org/jira/browse/MODPYTHON-43 It is possible that now that mod_python requires at least mod_python 2.3 that new features in the language may be able to be utilised to improve this feature of mod_python. BTW, you are better off bringing up issue like this about mod_python on the mod_python mailing list instead of the general Python group. Graham -- http://mail.python.org/mailman/listinfo/python-list