Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-23 Thread Martijn Faassen

Johan Carlsson wrote:


Anyone had any success with ZCatalog in Zope 3?


Sure. I'm not sure what the problem is but I see you get a lot of 
replies. We (Infrae) certainly got it working without having to patch 
anything.


Um, the setup code we use it something like:

def _registerUtility(context, class_, interface, name=u''):
if not name:
cname = class_.__name__
else:
cname = name
if name and name in context:
raise ValueError, u'Utility %s already registered!' % name
utility = class_()
context[cname] = utility
registration = UtilityRegistration(name, interface, utility)
key = context.registrationManager.addRegistration(registration)
zapi.traverse(context.registrationManager, key).status =  ActiveStatus
return utility

in setup code...

from zope.app.intid.interfaces import IIntIds
from zope.app.catalog.interfaces import ICatalog
from zope.app.intid import IntIds
from zope.app.catalog.catalog import Catalog

_registerUtility(default, IntIds, IIntIds)
_registerUtility(default, Catalog, ICatalog, u'my_catalog')

and then to make indexes registered, something like:

from zope.app import zapi
from zope.app.catalog.field import FieldIndex

catalog = zapi.getUtility(ICatalog, u'my_catalog')
catalog['something'] = FieldIndex('something', ISomeInterface)

_registerUtility is rather messy but it works..

Anyway, once you do get the catalog working, you may want to check out 
hurry.query, which makes querying the Zope 3 catalog a lot easier (in my 
opinion):


http://codespeak.net/svn/z3/hurry/trunk

Regards,

Martijn
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-23 Thread Johan Carlsson

Martijn Faassen wrote:

Johan Carlsson wrote:



Anyone had any success with ZCatalog in Zope 3?



Sure. I'm not sure what the problem is but I see you get a lot of 
replies. We (Infrae) certainly got it working without having to patch 
anything.


Um, the setup code we use it something like:

def _registerUtility(context, class_, interface, name=u''):
if not name:
cname = class_.__name__
else:
cname = name
if name and name in context:
raise ValueError, u'Utility %s already registered!' % name
utility = class_()
context[cname] = utility
registration = UtilityRegistration(name, interface, utility)
key = context.registrationManager.addRegistration(registration)
zapi.traverse(context.registrationManager, key).status =  ActiveStatus
return utility

in setup code...

from zope.app.intid.interfaces import IIntIds
from zope.app.catalog.interfaces import ICatalog
from zope.app.intid import IntIds
from zope.app.catalog.catalog import Catalog

_registerUtility(default, IntIds, IIntIds)
_registerUtility(default, Catalog, ICatalog, u'my_catalog')

and then to make indexes registered, something like:

from zope.app import zapi
from zope.app.catalog.field import FieldIndex

catalog = zapi.getUtility(ICatalog, u'my_catalog')
catalog['something'] = FieldIndex('something', ISomeInterface)

_registerUtility is rather messy but it works..


Thanks Martijn,
From a quick glans at your code the notisable difference is
that I don't call zapi.getUtility(ICatalog, u'my_catalog') to get the
catalog, that just might do the trick. (I jsut grab the catalog from the 
container: c['catalog'].

I'll let you know when I get a chance to test it.

Does you code for adding catalogs and adding fields get called
in the same request?
Mine does, it gets called right after each other, and I'm thinking
in the lines of that there is something that doesn't get setup in
the correct order, which is why I think getUtility might work better.

Anyway, once you do get the catalog working, you may want to check out 
hurry.query, which makes querying the Zope 3 catalog a lot easier (in my 
opinion):


http://codespeak.net/svn/z3/hurry/trunk


I'll check it out :-)

Cheers,
johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-21 Thread Dominik Huber

Johan Carlsson wrote:





Right after that I do this:


catalog = Catalog()
for index_name, index_attribute, idx_if, attr_call, index_type 
in indexes:

idx = index_type(index_attribute, idx_if, attr_call)
catalog[index_name] = idx
tools['catalog'] = catalog
catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
rm.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus


change the order and it will work:

   catalog = Catalog()
   tools['catalog'] = catalog
   catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
   rm.addRegistration(catalog_reg)
   catalog_reg.status = ActiveStatus
   # add the indexes after the catalog is set to the tools
   for index_name, index_attribute, idx_if, attr_call, index_type
in indexes:
   idx = index_type(index_attribute, idx_if, attr_call)
   catalog[index_name] = idx



regards,
Dominik

begin:vcard
fn:Dominik Huber
n:Huber;Dominik
email;internet:[EMAIL PROTECTED]
tel;work:++41 56 534 77 30
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-21 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:





Right after that I do this:


catalog = Catalog()
for index_name, index_attribute, idx_if, attr_call, index_type 
in indexes:

idx = index_type(index_attribute, idx_if, attr_call)
catalog[index_name] = idx
tools['catalog'] = catalog
catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
rm.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus



change the order and it will work:

   catalog = Catalog()
   tools['catalog'] = catalog
   catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
   rm.addRegistration(catalog_reg)
   catalog_reg.status = ActiveStatus
   # add the indexes after the catalog is set to the tools
   for index_name, index_attribute, idx_if, attr_call, index_type
in indexes:
   idx = index_type(index_attribute, idx_if, attr_call)
   catalog[index_name] = idx


That seemed resonablu, unfortunately it didn't help.

Thanks anyway,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Hi again,

The ComponentLookupError have re appeared!

 Error type: zope.component.interfaces.ComponentLookupError
 Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

What happend was that I had a IntId utitlity in the root site (renamed 
to '') that answered the request when I added the Indexes in a sub site.


So the question is how do I rename the IntId utility programmatically
or why doesn't the following code ad a utility (maybe it's not
registered correctly to be use right after it's been added but needs
some events to trigger first???


First I do this:

intids = IntIds()
tools['intid'] = intids

#I thought this was equal to rename the intid-util to ''!?
intids_reg = UtilityRegistration('', IIntIds, intids)

rm.addRegistration(intids_reg)
intids_reg.status = ActiveStatus


Right after that I do this:


catalog = Catalog()
for index_name, index_attribute, idx_if, attr_call, index_type 
in indexes:

idx = index_type(index_attribute, idx_if, attr_call)
catalog[index_name] = idx
tools['catalog'] = catalog
catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
rm.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus



This is all called from an event handler, like Dominik pointed out I 
should do it.




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Johan Carlsson wrote:

Hi again,

The ComponentLookupError have re appeared!

  Error type: zope.component.interfaces.ComponentLookupError
  Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

What happend was that I had a IntId utitlity in the root site (renamed 
to '') that answered the request when I added the Indexes in a sub site.


So the question is how do I rename the IntId utility programmatically
or why doesn't the following code ad a utility (maybe it's not
registered correctly to be use right after it's been added but needs
some events to trigger first???


So, with som testing I figured out that the name is set to ''
but it doesn't get accessible right away:

zapi.getAllUtilitiesRegisteredFor(IIntIds) returns an empty tuple.

Is there some kind of flush-call or commit-call that needs to be executed?

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Johan Carlsson wrote:

Dominik Huber wrote:


Johan Carlsson wrote:



I've tried this, it doesn't remove the NotYet problem though!??


Our framework relies on that concept and it is still working ;)
Did you assert  to add the catalog to the sitemanagement folder before 
adding its indexes?


I found the error, in the AddView I had to remove the security context
to be able to setup things, I don't need that in the event handler.
The removed security context appears to have been the reason for the
NotYet problems.

Thanks for kicking me in the right direction :-)



Looks like I was wrong on the NotYet too.
It doesn't work in a event handler either :-(

Ivos patch is still the only thing that works.

/Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Johan Carlsson wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.


My bad, ComponentLookupError is what I get if I don't have setup an
IntIds utility, if I have set one up (currently mine is named IntIds
in the tools folder of the root site manager) I get:

Error type: zope.app.keyreference.interfaces.NotYet
Error object: zope.app.catalog.field.FieldIndex object at 0x03CBE8B0


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Ivo van der Wijk
On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:

 Anyone had any success with ZCatalog in Zope 3?

 I'm trying to add indexes to the catalog
 but I get an ComponentLookupError:

 Error type: zope.component.interfaces.ComponentLookupError
 Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

 I'm not sure how to setup the IntIds utility, what I've done so far
 is just add one and give it an random name.


I managed to create a working Catalog/IntId setup in cubic, along with
actual indexing/searching (and a quick'n'dirty port of TextIndexNG3).

I can't remember details right now (been to long), but you could take
a peak at the code at

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/

Specifically,

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/cubicportal.py
and
https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/catalog/catalog.py

might give you some directions.

Regards,

  Ivo

--
Drs. I.R. van der Wijk / m3r Consultancy B.V.
Linux/Python/Zope/Plone and Open Source solutions
PO-box 51091, 1007 EB Amsterdam, The Netherlands
Email: ivo at m3r.nl
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.




I managed to create a working Catalog/IntId setup in cubic, along with
actual indexing/searching (and a quick'n'dirty port of TextIndexNG3).

I can't remember details right now (been to long), but you could take
a peak at the code at

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/

Specifically,

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/cubicportal.py
and
https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/catalog/catalog.py

might give you some directions.


Excellent,
Probably exactly what I need :-)
I'll have a look.
Thanks,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (InterfaceClass zope.app.intid.interfaces.IIntIds, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.




I managed to create a working Catalog/IntId setup in cubic, along with
actual indexing/searching (and a quick'n'dirty port of TextIndexNG3).

I can't remember details right now (been to long), but you could take
a peak at the code at

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/

Specifically,

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/cubicportal.py
and
https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/catalog/catalog.py

might give you some directions.


The code you gave me shows the same showed the same problem as Jürgen 
pointied out, the IntId needs to have '' as id.

Thanks,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

And thanks both of you for really fast replies :-)
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Ivo van der Wijk
On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:


 The code you gave me shows the same showed the same problem as Jürgen
 pointied out, the IntId needs to have '' as id.

I remember having some real issues with IntId / Catalog, I doubt if
they ever really got fixed. Check the patch in INSTALL.txt:

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/doc/INSTALL.txt

It once used to work for me, at least :)


--
Drs. I.R. van der Wijk / m3r Consultancy B.V.
Linux/Python/Zope/Plone and Open Source solutions
PO-box 51091, 1007 EB Amsterdam, The Netherlands
Email: ivo at m3r.nl
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:



The code you gave me shows the same showed the same problem as Jürgen
pointied out, the IntId needs to have '' as id.



I remember having some real issues with IntId / Catalog, I doubt if
they ever really got fixed. Check the patch in INSTALL.txt:

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/doc/INSTALL.txt

It once used to work for me, at least :)


Ah, thanks for the heads up.
Johan



--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Gary Poster


On Nov 17, 2005, at 9:05 AM, Johan Carlsson wrote:


Johan Carlsson wrote:

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson [EMAIL PROTECTED] wrote:


The code you gave me shows the same showed the same problem as  
Jürgen

pointied out, the IntId needs to have '' as id.




I remember having some real issues with IntId / Catalog, I doubt if
they ever really got fixed. Check the patch in INSTALL.txt:

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/doc/ 
INSTALL.txt


It once used to work for me, at least :)

Ah, thanks for the heads up.


Now I see, that's exactly what been bitting my butt all along.

The patch fixes the problem!


Hm.  A very quick look at the patch concerns me a bit.  Am I right  
that, if you apply the patch, then requests that are currently  
raising a NotYet for you will instead silently fail, not cataloging  
what you requested?  That seems undesirable to me.  I'd prefer the  
exception.


If I'm on the right track here, then the extentcatalog in the  
zc.catalog package in the sandbox probably is one of possibly many  
other better solutions than the patch.  It postpones cataloging to  
the end of the transaction, which I believe will remove the NotYet  
exceptions *and* successfully catalog your data.


Apologies if my quick patch read is off base.

Gary___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Gary Poster wrote:


Hm.  A very quick look at the patch concerns me a bit.  Am I right  
that, if you apply the patch, then requests that are currently  raising 
a NotYet for you will instead silently fail, not cataloging  what you 
requested?  That seems undesirable to me.  I'd prefer the  exception.


If I'm on the right track here, then the extentcatalog in the  
zc.catalog package in the sandbox probably is one of possibly many  
other better solutions than the patch.  It postpones cataloging to  the 
end of the transaction, which I believe will remove the NotYet  
exceptions *and* successfully catalog your data.


In my case I'm not interested in cataloging anything, there reason is
I'm just adding new fields to a newly created catalog and there
aren't any object to catalog just yet.

I'm guessing Ivo has similare problems because he also are creating
the catalog programmetically.

I'm doing this as a part of a custom add view that defines a
overrided createAndAdd(self, data), I think Ivo does it
in a more CMF like fashion (just after quick glans on his code).

I don't have the faintest idea what NotYet is supposted to be
raise for? Accutally I'm haveing problems finding the code
that does this because the traceback is Zope 3 cryptic and
I don't have a debugger setup either.

(I was hoping not having to care about the innerworks of the catalog,
but that maybe is too much too hope for ;-)

Johan





--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Hi Johan
Your problem is that the catalog is not locatable itself during the 
addition of its indexes (- state within the create and add method), 
therefore the location of the indexes cannot be located and the 
NotYetError is raised. You can move your code to an 
ObjectAddedEvent-subscriber for your object.


 subscriber
 for=.IYourObject zope.app.container.interfaces.IObjectAddedEvent
 handler=.addCatalogAndIndex
 /

handler pseudo code:

def addCatalogAndIndex(obj, event):
   sm = zapi.getNextSiteManager(obj)
   catalog = Catalog()
   addLocalUtility(sm, 'XY', ICatalog, catalog)
   catalog[name] = Index(name, IAnyInterface)


Ok, that's by the way how Ivo does it (I've just read).

Thanks,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Hi Johan
Your problem is that the catalog is not locatable itself during the 
addition of its indexes (- state within the create and add method), 
therefore the location of the indexes cannot be located and the 
NotYetError is raised. You can move your code to an 
ObjectAddedEvent-subscriber for your object.


 subscriber
 for=.IYourObject zope.app.container.interfaces.IObjectAddedEvent
 handler=.addCatalogAndIndex
 /

handler pseudo code:

def addCatalogAndIndex(obj, event):
   sm = zapi.getNextSiteManager(obj)
   catalog = Catalog()
   addLocalUtility(sm, 'XY', ICatalog, catalog)
   catalog[name] = Index(name, IAnyInterface)


I've tried this, it doesn't remove the NotYet problem though!??

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



I've tried this, it doesn't remove the NotYet problem though!??



Our framework relies on that concept and it is still working ;)
Did you assert  to add the catalog to the sitemanagement folder before 
adding its indexes?


I found the error, in the AddView I had to remove the security context
to be able to setup things, I don't need that in the event handler.
The removed security context appears to have been the reason for the
NotYet problems.

Thanks for kicking me in the right direction :-)
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Tom Dossis

Dominik Huber wrote:


 subscriber
 for=.IYourObject zope.app.container.interfaces.IObjectAddedEvent
 handler=.addCatalogAndIndex
 /

handler pseudo code:

def addCatalogAndIndex(obj, event):
   sm = zapi.getNextSiteManager(obj)
   catalog = Catalog()
   addLocalUtility(sm, 'XY', ICatalog, catalog)
   catalog[name] = Index(name, IAnyInterface)

Regards,
Dominik



From the apidoc for IWriteContainer.__setitem__(name, object)
it states..

''If an add event is generated and the object can be adapted to 
IObjectAddedEvent, then the adapter's addNotify method is called with 
the event.''


This could be alternative way to implement the the subscriber solution 
above.  However, from looking at the code (Zope3.1) it doesn't seem to 
to what the apidoc claims.


Does anybody know if this is still intended?

-Tom
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users