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
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
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
participants (2)
-
Piotr Chamera -
Suresh V.