[Zope] Persistent variable in Python Script? Is this a feature or a bug?
Maik Jablonski
maik.jablonski@uni-bielefeld.de
Tue, 9 Apr 2002 10:26:34 +0200
On Tue, 09 Apr 2002 16:03:50 +0800 iap@y2fun.com wrote:
> Given a Python Script A which only returns an array
> ========
> return ('a')
> ========
>
> Then call A in another Python Script B with parameter list: b=[]
>
> ========
> b.append(container.A())
> return b
> ========
>
> Then request B in browser. Guess what happened?
> ['a']
> correct!
> But what if you "reload" B again and again?
> You will get
> ['a','a','a',........]
>
> Well, why this happen? A feature or A bug?
Zope stores non-persistent objects until the next restart in the memory... so
appending something to a list will give you more and more list-items...
> I thought that the parameter should be cleared at each new request.
> How to get a "local" parameter without this persistent feature?
Don't use b=[] in the parameter-list... instead:
b=[]
b.append(container.A())
return b
greetings, maik.
--
maik jablonski http://www.sachunterricht-online.de
universitaet bielefeld http://www.zfl.uni-bielefeld.de
zentrum fuer lehrerbildung tlph://+49.(0).521.106.4234