[mod_python] Accesshandler and normal handler... how they working ?

durumdara durumdara at gmail.com
Mon Nov 20 09:56:04 EST 2006


Hi !

Aha !!!
As I see that when NO FILENAME PRESENTED the accesshandler not started 
and sharing across request object not working.
http://localhost
This time the handler is started only, the accesshandler not.

    Mod_python error: "PythonHandler __zeuswebhandler"

    Traceback (most recent call last):

      File "C:\Python24\lib\site-packages\mod_python\apache.py", line 299, in HandlerDispatch
        result = object(req)

      File "c:/web/zeusweb/htdocs\__zeuswebhandler.py", line 6, in handler
        RequestObject = req.Object

    AttributeError: 'mp_request' object has no attribute 'Object'

dd


Jim Gallacher wrote:
> durumdara wrote:
>> Hi !
>>
>> I have an access handler, and a normal python handler in my site.
>> I use directories, and some of them are need protection. I use my login
>> method to enable user access.
>>
>> The access handler is check the needed rights to any object. It get user
>> data from Session.
>> When access granted, it finished it's working.
>> When access denied, it send http403 error, and I catch this with custom
>> error documents (ssi).
>>
>> But I want to know something - the background of access handler.
>>
>> 1.)
>> The access handler is existing in same Thread as Handler ?
>
> Yes.
>
>> So I want to know. Is modpy do this:
>> get url, server info, etc.
>> build request + other objects
>> get thread
>> result = thread.startaccesshandler(req)
>> if not result:
>>  gotoerrorhandler
>> else:
>>  result = thread.handler(req)
>> ....
>> or it use another technology ?
>
> Unless I'm misunderstanding your question, you don't need to mess with 
> threads. You are always dealing with the same request object, 
> regardless of which phase, and there is one process or thread per 
> request.
>
> Take a look at the mod_python documentation for PythonAuthenHandler, 
> as well as my reply to Richard Lewis today on a similar question.
>
>> 2.)
>> Can I exchange some data across them ?
>
> Yes.
>
> def authenhandler(req):
>     req.foo = 'something for later'
>     ...
>
>
> def handler(req):
>     req.write(req.foo)
>     ...
>
>
>> In this time I use file based right table(s).
>> Every file in this table has right property.
>> I need to load this table in the accesshandler to check grants.
>> And later, in the menu building I also need to load this table to check
>> grants (the menus are not accessable by user are hided).
>> Can I share these infos ? Can I write to the request object, and this
>> object is hold these infos to get them in normal handler ?
>
> Yes.
>
>> 3.)
>> Can I force the access handler to redirect request ?
>
> Yes.
>
>> Example: the user click on menu that preserved for special users. I
>> don't want to redirect to error pages. Can I redirect to my special
>> page, 
>
> Yes.
>
> Jim
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20061120/abab0827/attachment-0001.html


More information about the Mod_python mailing list