(Fwd) Re: [mod_python] How to pass values

Graham Dumpleton grahamd at dscpl.com.au
Fri Jan 26 16:19:51 EST 2007


Use some standard debugging techniques yourself to try and work it out.

On 26/01/2007, at 10:44 PM, export at hope.cz wrote:

> Graham,
> Thank you for your reply.
> I have
>
> def inputfilter(filter):
> filter.req.myflag = True

Add:

   filter.req.log_error('inputfilter')

> ...
> ...
>
> so, as you can see the first command in input filter
> is filter.req.myflag = True
> but yet, I can not access the req.myflag
> in my request handler.
> When I try
> req.write(`req.myflag`)

Add before this:

   req.log_error('handler')

In other words, use the logging system to dump information into the  
Apache
log files to see if the input filter is actually being called. It  
would look like it
isn't. What have you done so far to confirm it is?

Graham

> I will receive the same error:
>
> AttributeError: 'mp_request' object has no attribute 'myflag'
>
> What shall I try to solve the problem. Do you have any idea?
> Thank you
> Lad
>
>> Your input filter can't have been called then, or not the part  
>> where you
>> assigned the attribute. If the variable may not be there in all
>> situations,
>> then use:
>>
>> if hasattr(req, 'myflag'):
>> if req.myflag:
>> ..
>>
>> Graham
>>
>> On 26/01/2007, at 7:09 PM, export at hope.cz wrote:
>>
>>> Graham ,
>>> Thank you for your reply and help.
>>> I tried the way you suggested but I received the error
>>>
>>> AttributeError: 'mp_request' object has no attribute 'myflag'
>>>
>>> Can you please help?
>>> Thank you
>>> Lad.
>>>
>>>
>>>>
>>>> On 26/01/2007, at 2:45 AM, export at hope.cz wrote:
>>>>
>>>>> Depending on a value being calculated in input filter,
>>>>> I will have to make a decission in request handler.
>>>>> What is a way to find out the value of the variable from input
>>>>> filter in request handler?
>>>>
>>>> I believe this was mentioned before.
>>>>
>>>> In filter, set an attribute on the request object:
>>>>
>>>> def inputfilter(filter):
>>>> ...
>>>> filter.req.myflag = True
>>>> ...
>>>>
>>>> In the request handler, you can then access that variable.
>>>>
>>>> def handler(req):
>>>> ...
>>>> if req.myflag:
>>>> ...
>>>> ...
>>>>
>>>> Graham
>>>
>>
>>
>
>
> ------- End of forwarded message -------


More information about the Mod_python mailing list