Am Donnerstag, 2. August 2007 13:37 schrieb Fred Drake:
> On 8/2/07, Hermann Himmelbauer <[EMAIL PROTECTED]> wrote:
> >     mylist = []
> >
> >     @button.buttonAndHandler(_(u'Suchen'), name='suchen')
> >     def handle_suchen(self, action):
> >              self.mylist.append(123)
> >
> > When I output "mylist" in my page template, the number 123 is appended to
> > mylist if I press the "Suchen" button, so if I press it 5 times, the list
> > holds 5 items. When I restart my zope instance, the list is empty again.
>
> The attribute will be "persistent" so long as you don't restart the
> process, *because* it's a class attribute.  Note that the code you
> showed never sets the value of self.mylist, but only mutates the
> existing value.
>
> To not have a semi-persistent self.mylist, do this instead:
>
>     def handle_suchen(self, action):
>              self.mylist = [123]

Thanks for your reply, I was so "Zopified" and concentrated on object 
persistence that I forgot about this really basic Python issue...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to