Re: [Zope] delete a variable from REQUEST

2008-09-30 Thread Tino Wildenhain

Hi,

indrajit926 indra wrote:

Hi,

thanks for ur reply.

My problem is, my code is like

#code code code

if REQUEST['usr_msg']:
  do some operations.
 
#some code related to project


my program control loops with above " if condition".

REQUEST is in same context.

so once REQUEST stores 'usr_msg ' every time when it goes to "if 
condition " , it performs that "do some operations"


Due to above reason i want to delete that "usr_msg" variable from REQUEST


But if you would really manage to delete this from REQUEST, you
would get an exception when trying to use it in the way above.

So, see Peters solution to your problem.

also i cannot put restriction on "usr_msg" ,because it comes from user 
input, and user can give any text to that variable.


If thats some kind of filter chain you probably want to change
it to some private name space within request as you would be
comfortably getting by REQUEST.set('allmystuff',dict())
at the very beginning. You can actually look up form values
from REQUEST.form to distinguish between user input and
data from your program. If you just ask REQUEST, you get
some kind of stacking layers of name spaces where values get
looked up.

Please see the Zope book (online) for description of the API.

Regards
Tino



thanks,
Indrajit.

On Mon, Sep 29, 2008 at 1:36 PM, Tino Wildenhain <[EMAIL PROTECTED] 
> wrote:


Hi,


indrajit926 indra wrote:

Hi All,

Iam relatively new to zope.

I want to delete a variable and it value from REQUEST.I used
python pop() and __delattr__() ,but getting attribute error.


Actually you can't. (Not without writing a product in filesystem
and getting deep into zope). Why would you?

What you could do is to update one of the requests namespace to
give the variable a new value.

Regards
Tino





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce

 http://mail.zope.org/mailman/listinfo/zope-dev )




smime.p7s
Description: S/MIME Cryptographic Signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] delete a variable from REQUEST

2008-09-30 Thread Peter Bengtsson
Just set it to None.


if REQUEST['usr_msg']:
do_something()
REQUEST.set('usr_msg', None)

Then, the next time the condition will be false.

2008/9/30 indrajit926 indra <[EMAIL PROTECTED]>:
> Hi,
>
> thanks for ur reply.
>
> My problem is, my code is like
>
> #code code code
>
> if REQUEST['usr_msg']:
>   do some operations.
>
> #some code related to project
>
> my program control loops with above " if condition".
>
> REQUEST is in same context.
>
> so once REQUEST stores 'usr_msg ' every time when it goes to "if condition "
> , it performs that "do some operations"
>
> Due to above reason i want to delete that "usr_msg" variable from REQUEST
>
> also i cannot put restriction on "usr_msg" ,because it comes from user
> input, and user can give any text to that variable.
>
> thanks,
> Indrajit.
>
> On Mon, Sep 29, 2008 at 1:36 PM, Tino Wildenhain <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> indrajit926 indra wrote:
>>>
>>> Hi All,
>>>
>>> Iam relatively new to zope.
>>>
>>> I want to delete a variable and it value from REQUEST.I used python pop()
>>> and __delattr__() ,but getting attribute error.
>>
>> Actually you can't. (Not without writing a product in filesystem
>> and getting deep into zope). Why would you?
>>
>> What you could do is to update one of the requests namespace to
>> give the variable a new value.
>>
>> Regards
>> Tino
>
>
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>
>



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] delete a variable from REQUEST

2008-09-30 Thread indrajit926 indra
Hi,

thanks for ur reply.

My problem is, my code is like

#code code code

if REQUEST['usr_msg']:
  do some operations.

#some code related to project

my program control loops with above " if condition".

REQUEST is in same context.

so once REQUEST stores 'usr_msg ' every time when it goes to "if condition "
, it performs that "do some operations"

Due to above reason i want to delete that "usr_msg" variable from REQUEST

also i cannot put restriction on "usr_msg" ,because it comes from user
input, and user can give any text to that variable.

thanks,
Indrajit.

On Mon, Sep 29, 2008 at 1:36 PM, Tino Wildenhain <[EMAIL PROTECTED]> wrote:

> Hi,
>
> indrajit926 indra wrote:
>
>> Hi All,
>>
>> Iam relatively new to zope.
>>
>> I want to delete a variable and it value from REQUEST.I used python pop()
>> and __delattr__() ,but getting attribute error.
>>
>
> Actually you can't. (Not without writing a product in filesystem
> and getting deep into zope). Why would you?
>
> What you could do is to update one of the requests namespace to
> give the variable a new value.
>
> Regards
> Tino
>
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] delete a variable from REQUEST

2008-09-30 Thread indrajit926 indra
Hi,

thanks for ur reply.

My problem is, my code is like

if REQUEST['usr_msg']:

On Mon, Sep 29, 2008 at 1:36 PM, Tino Wildenhain <[EMAIL PROTECTED]> wrote:

> Hi,
>
> indrajit926 indra wrote:
>
>> Hi All,
>>
>> Iam relatively new to zope.
>>
>> I want to delete a variable and it value from REQUEST.I used python pop()
>> and __delattr__() ,but getting attribute error.
>>
>
> Actually you can't. (Not without writing a product in filesystem
> and getting deep into zope). Why would you?
>
> What you could do is to update one of the requests namespace to
> give the variable a new value.
>
> Regards
> Tino
>
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] delete a variable from REQUEST

2008-09-29 Thread Tino Wildenhain

Hi,

indrajit926 indra wrote:

Hi All,

Iam relatively new to zope.

I want to delete a variable and it value from REQUEST.I used python 
pop() and __delattr__() ,but getting attribute error.


Actually you can't. (Not without writing a product in filesystem
and getting deep into zope). Why would you?

What you could do is to update one of the requests namespace to
give the variable a new value.

Regards
Tino


smime.p7s
Description: S/MIME Cryptographic Signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )