Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

Strange property behaviour - why? (zope 2.10/Five)

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


piotr_chamera at poczta

May 13, 2008, 4:50 AM

Post #1 of 4 (316 views)
Permalink
Strange property behaviour - why? (zope 2.10/Five)

Hello,

I don't understand property behawiour in code bellow (I am not
experienced programmmer, so I could missed something obivious).

In example bellow: "list_items1" works as I expected - it returns
list of objects from catalog but "list_items2" fails - I get Attribute
Error or if it finds "items" through acquisition it returns this object.

But, if I uncomment line "return [1,2,3]" in code below, then both
functions return the same value - list [1,2,3].

Search of "catalog" by acquisition messes with class attribute lookup?

<code>
class Storage (SimpleItem):
""" see IStorage interface """

implements(IStorage)

title = FieldProperty(IStorage['title'])
description = FieldProperty(IStorage['description'])

def _get_items(self):
""" Return list of items in storage (unsorted). """
#return [1,2,3]
return [x.getObject() for x in self.catalog(storage=self.title)]

items = property(_get_items)

def list_items1(self):
""" test """
return self._get_items()

def list_items2(self):
""" test """
return self.items
</code>

Piotr Chamera
_______________________________________________
Zope maillist - Zope[at]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 )


suresh_vv at yahoo

May 13, 2008, 6:35 AM

Post #2 of 4 (298 views)
Permalink
Re: Strange property behaviour - why? (zope 2.10/Five) [In reply to]

Piotr Chamera wrote:

>
> def list_items2(self):
> """ test """
> return self.items

try to remove acquisition wrapper before you access items?

Suresh

_______________________________________________
Zope maillist - Zope[at]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 )


piotr_chamera at poczta

May 13, 2008, 7:14 AM

Post #3 of 4 (298 views)
Permalink
Re: Re: Strange property behaviour - why? (zope 2.10/Five) [In reply to]

Suresh V. pisze:
> Piotr Chamera wrote:
>> def list_items2(self):
>> """ test """
>> return self.items
> try to remove acquisition wrapper before you access items?
But this function returns no value, it fails to find "items" attribute
in self and tries to find it through acquisition :(

--
Piotr Chamera
_______________________________________________
Zope maillist - Zope[at]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 )


piotr_chamera at poczta

May 14, 2008, 4:44 AM

Post #4 of 4 (287 views)
Permalink
Re: Strange property behaviour - why? (zope 2.10/Five) [In reply to]

> I don't understand property behawiour in code bellow (I am not
> experienced programmmer, so I could missed something obivious).
I have found related bug at https://bugs.launchpad.net/zope2/+bug/143756
with solution for my problem.

--
Piotr Chamera
_______________________________________________
Zope maillist - Zope[at]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 )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.