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

export at hope.cz export at hope.cz
Fri Jan 26 06:44:20 EST 2007


Graham,
Thank you for your reply.
I have

def inputfilter(filter):
filter.req.myflag = True
...
...

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`)
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