Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Lorenzo Gil Sanchez
Hi Darryl El mié, 26-07-2006 a las 00:48 +1200, Darryl Cousins escribió: > Hi Lorenzo, > > Cool. Where is the `contained` imported from? There is some magic there > because I couldn't get the test to work when creating the FieldIndex in > your createIndexes method without it. from zope.app.conta

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Darryl Cousins
Hi Lorenzo, Cool. Where is the `contained` imported from? There is some magic there because I couldn't get the test to work when creating the FieldIndex in your createIndexes method without it. Thanks, Darryl On Tue, 2006-07-25 at 13:55 +0200, Lorenzo Gil Sanchez wrote: > Hi Darryl, > > this is

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Lorenzo Gil Sanchez
Hi Darryl, this is how I ended implementing it: class FilterableContainer(BTreeContainer): implements(IFilterableContainer) def __init__(self, catalog=None): super(FilterableContainer, self).__init__() self.catalog = contained(LocalCatalog(), self, 'catalog') def c

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Darryl Cousins
Hi All, I was thinking about that del(self.field) that I threw in. Wouldn't that remove the object too and therefore the key reference? Apparently not (in the test anyway):: >>> class TestField(Persistent): ... id = u'' ... def __init__(self, id): ... self.id = i

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Darryl Cousins
Hi Lorenzo, I got this test to work:: >>> class TestField(Persistent): ... pass >>> class TestCase(Persistent): ... def __init__(self): ... self.fieldkey = KeyReferenceToPersistent(TestField()) >>> t = TestCase() Traceback (most recent call last):

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Lorenzo Gil Sanchez
No worries, in fact I actually tried the same aproach and hit the same problem Thanks anyway Lorenzo El mar, 25-07-2006 a las 22:16 +1200, Darryl Cousins escribió: > Hi again, > > I was a too hasty. Because it is the FieldIndex that is missing the > _p_oid attribute, and the fix I offered is fo

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Darryl Cousins
Hi again, I was a too hasty. Because it is the FieldIndex that is missing the _p_oid attribute, and the fix I offered is for the container. Sorry about that. I need more thinking. Regards, Darryl On Tue, 2006-07-25 at 22:10 +1200, Darryl Cousins wrote: > Hi Lorenzo, > > The key reference adap

Re: [Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Darryl Cousins
Hi Lorenzo, The key reference adapter can only get a key reference **after** the object is added to the database (because it uses _p_oid). The problem could be fixed with a subscriber to IObjectAddedEvent:: def FilterableContainerInitializationHandler(object, event): """Initialize contai

[Zope3-Users] adding indexes in a __init__ method

2006-07-25 Thread Lorenzo Gil Sanchez
Hi, I have a special Folder content. When an instance of this class is created I want to create a catalog and an index in its __init__ method. Something like: class FilterableContainer(BTreeContainer): implements(IFilterableContainer) def __init__(self): super(FilterableContaine