[Zope3-Users] generations and utilities

2006-01-31 Thread Paolo Invernizzi

Hello,

I've developed a content object for zope and I'm using the install.py 
script in a generation package to install some prebuild content 
instances in a folder, and everything works well.


I'm now trying to add a Catalog plus IntIds to do some search... but I'm 
doing  something wrong...


I cannot find the right way to install an IntIds (at least!) in the 
global site (I don't care about local sites) and populate the 
application via a generation install.py


Must I move the IntIds and Catalog instantiation/registration outside 
the script?


def evolve(context):
Install an articles folder full of pre-made articles

root = context.connection.root()
app = root['Application']

# app is a ISite...
assert ISite.providedBy(app)

# get the sitemanager
sitemanager = app.getSiteManager()
default = sitemanager['default']

# add an intids
intids = IntIds()
default['intids'] = intids
intids_reg = UtilityRegistration('', IIntIds, intids)
default.registrationManager.addRegistration(intids_reg)
intids_reg.status = ActiveStatus

# add a catalog
catalog = Catalog()
default['catalog'] = catalog
catalog_reg = UtilityRegistration('', ICatalog, catalog)
default.registrationManager.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus

# This bangs with
#  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/interface/adapter.py, 
line 481, in subscribers

# subscribers = [subscription(*objects)
# File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/catalog/catalog.py, 
line 130, in indexAdded

# index.__parent__.updateIndex(index)
# File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/catalog/catalog.py, 
line 68, in updateIndex

# uidutil = zapi.getUtility(IIntIds)
# File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/__init__.py, 
line 257, in getUtility

# raise ComponentLookupError(interface, name)
# zope.component.interfaces.ComponentLookupError: (InterfaceClass 
zope.app.intid.interfaces.IIntIds, '')

#catalog['title'] = FieldIndex('title', IArticle)

print ===
print Installing prebuild articles...
print ===

app['articles'] = articles = Articles()
... etc etc...


Thanks!

Paolo



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


Re: [Zope3-Users] generations and utilities

2006-01-31 Thread Gary Poster


On Jan 31, 2006, at 11:16 AM, Paolo Invernizzi wrote:


Hello,

I've developed a content object for zope and I'm using the  
install.py script in a generation package to install some prebuild  
content instances in a folder, and everything works well.


I'm now trying to add a Catalog plus IntIds to do some search...  
but I'm doing  something wrong...


This smells like an unhelpful exception, swallowing the real problem  
down deeper in the code.  I bet it's just that you haven't added the  
key reference package or something like that.  Have you included  
zope.app.keyreference in your ZCML?


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


Re: [Zope3-Users] Re: generations and utilities

2006-01-31 Thread Gary Poster


On Jan 31, 2006, at 11:48 AM, Paolo Invernizzi wrote:

Do you mean if there's a zope.app.keyreference-configure.zcml in  
the instance/etc?


Yes, it's a standard zope 3.2.0 created instance...


Ah well, sorry.  Your recipe looks fine.  If I were in your shoes my  
next lazy attempt would be to try committing the transaction with the  
intids and catalog before adding the indexes.  Beyond that I'd have  
to start digging.


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


[Zope3-Users] Re: generations and utilities

2006-01-31 Thread Paolo Invernizzi

Gary Poster wrote:


Your recipe looks fine.  If I were in your shoes my 
next lazy attempt would be to try committing the transaction with the 
intids and catalog before adding the indexes.


Ok, I added  the transaction... still bangs, the full traceback is at 
the end...
Note that if I don't add Indexes, zope3 starts, full of articles. But 
when I add the index via TTW and reindex, the articles that I added in 
the install.py script aren't indexed (so the IIntIds was not active 
during the install.py), BUT if I add further articles TTW, the added are 
 indexed...


I really donno what/where to dig ;-(


# app is a ISite...
assert ISite.providedBy(app)

# get the sitemanager
sitemanager = app.getSiteManager()
default = sitemanager['default']

# add an intids
intids = IntIds()
default['intids'] = intids
intids_reg = UtilityRegistration('', IIntIds, intids)
default.registrationManager.addRegistration(intids_reg)
intids_reg.status = ActiveStatus

# add a catalog
catalog = Catalog()
default['catalog'] = catalog
catalog_reg = UtilityRegistration('', ICatalog, catalog)
default.registrationManager.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus

# Commit the transaction before adding the indexes
transaction.commit()

catalog['title'] = FieldIndex('title', IArticle)

Traceback (most recent call last):
  File bin/runzope, line 48, in ?
run()
  File bin/runzope, line 44, in run
main([-C, CONFIG_FILE] + sys.argv[1:])
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/twisted/main.py, 
line 74, in main

service = setup(load_options(args))
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/twisted/main.py, 
line 143, in setup

notify(zope.app.appsetup.interfaces.DatabaseOpened(db))
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/event/__init__.py, 
line 23, in notify

subscriber(event)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/event/dispatching.py, 
line 66, in dispatch

for ignored in subscribers(event, None):
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/__init__.py, 
line 181, in subscribers

return sitemanager.subscribers(objects, interface)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/site.py, 
line 89, in subscribers

return self.adapters.subscribers(required, provided)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/interface/adapter.py, 
line 481, in subscribers

subscribers = [subscription(*objects)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/appsetup/bootstrap.py, 
line 151, in bootStrapSubscriber

zope.event.notify(interfaces.DatabaseOpenedWithRoot(db))
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/event/__init__.py, 
line 23, in notify

subscriber(event)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/event/dispatching.py, 
line 66, in dispatch

for ignored in subscribers(event, None):
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/__init__.py, 
line 181, in subscribers

return sitemanager.subscribers(objects, interface)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/site.py, 
line 89, in subscribers

return self.adapters.subscribers(required, provided)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/interface/adapter.py, 
line 481, in subscribers

subscribers = [subscription(*objects)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/generations/generations.py, 
line 430, in evolveMinimumSubscriber

evolve(event.database, EVOLVEMINIMUM)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/generations/generations.py, 
line 372, in evolve

manager.install(context)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/generations/generations.py, 
line 147, in install

evolver.evolve(context)
  File 
/Users/arathorn/sandbox/zope/lib/python/articles/generations/install.py, 
line 74, in evolve

catalog['title'] = FieldIndex('title', IArticle)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/container/sample.py, 
line 86, in __setitem__

setitem(self, self.__data.__setitem__, key, object)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/container/contained.py, 
line 595, in setitem

notify(event)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/event/__init__.py, 
line 23, in notify

subscriber(event)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/app/event/dispatching.py, 
line 66, in dispatch

for ignored in subscribers(event, None):
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/__init__.py, 
line 181, in subscribers

return sitemanager.subscribers(objects, interface)
  File 
/Users/arathorn/local/Zope-3_2_0/lib/python/zope/component/site.py, 
line 89, in subscribers

return self.adapters.subscribers(required, provided)
  File 

Re: [Zope3-Users] Re: generations and utilities

2006-01-31 Thread Gary Poster


On Jan 31, 2006, at 12:23 PM, Paolo Invernizzi wrote:


Gary Poster wrote:
Your recipe looks fine.  If I were in your shoes my next lazy  
attempt would be to try committing the transaction with the intids  
and catalog before adding the indexes.


Ok, I added  the transaction... still bangs, the full traceback is  
at the end...


Heh, ok, I'll try just one more one-second diagnosis then. ;-)

Are you setting the site?

old_site = zope.app.component.hooks.getSite()
zope.app.component.hooks.setSite(object)
try:
# ...add the utilities and indexes in here...
finally:
zope.app.component.hooks.setSite(old_site)

If that doesn't do it, then we'll see if somebody else can suggest

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


[Zope3-Users] Group membership based on authenticator

2006-01-31 Thread Marko Mikulicic

Hello,

I've created a pluggable authentication utility instance with a  
principal folder and a group folder.
I've managed to manually map users created in the principal folder to  
a single group and then grant roles to this group


Is it possible to assign membership to the group based only on the  
principal folder (id or prefix)


I've found that I could do:

subscriber
   for=zope.app.authentication.interfaces.IPrincipalCreated
   handler=.mytest.principalCreated
   /

and then if the prefix of the event.principal.id is what I like  
then add some group to it, but I don't like the solution

Is it possible to do it with the managemente interface?

I'm new to zope3 and I have problems finding docs about this.

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