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


[Zope3-Users] Generations - a missed use case? (Evolving an application for the first time)

2005-11-18 Thread Jeff Shell
I have an application where I'm trying to use 'zope.app.generations'
for the first time. And after much pulling of hair and looking at the
core code, I found what may be a missed scenario.

Basically, we deployed this application for a customer and now they
want some changes. It changes the schema of one item to store values
in tuples instead of strings. I wrote an evolve module, 'evolve1.py'
in myapp.generations, made the schema manager, registered it as a
utility, bla bla bla. But my code seemed like it would never run.

I'd run the debuzope script and look at the database
root['zope.app.generations'], and there was 'myapp' with the value of
1. I'd keep deleting that key and committing the transaction, but my
code would still never run. I tried running it manually using
pdb.run() to step through it and make sure that it was finding the
right objects and doing its job. My code was fine. So I looked at the
code in zope.app.generations.generations and found this interesting
tidbit:

for key, manager in findManagers():
generation = generations.get(key)

if generation == manager.generation:
continue

if generation is None:
# This is a new database, so no old data

if IInstallableSchemaManager.providedBy(manager):
try:
manager.install(context)
except:
transaction.abort()
logging.getLogger('zope.app.generations').exception(
Failed to install %s,
key)
raise

generations[key] = manager.generation
transaction.commit()
continue

 (the code continues from there

There's one problem here - in my situation, it's NOT A NEW DATABASE.
There is old data that needs to be evolved, but there's no record of a
generation for this application because there was no need for a schema
manager until now.

I really like the concept and general implementation of the schema
manager, but this scenario is driving me crazy. I could write an
'install' script, but that doesn't really cover this situation. After
install is run, the database marks the application generation. This
makes sense for new applications installing themselves - there's no
old data to update, so if the application is at generation 5, for
example, it doesn't need to be evolved to '5' if all of the data
that's installed or used is already in generation 5 form. (ie - if I
were deploying my application fresh today, my fields would already be
tuples instead of strings).

But my situation, where I already have a deployed application, is not
covered by this. I *could* write an 'install' script for the schema
manager that did this first evolution that I need to do. But then that
installer would have to be updated with all of the future evolutions
as well - since in theory, I could update an application from before
the schema manager and need to bring it up to generation 5 or 8 from
essentially 0.

It seems like the Schema Manager needs an 'evolve from 0' option, with
'0' being set by the evolution script of no previous evolution was
found but (somehow) existing data could be detected. The other
solutions seem to be:

* Write an install script that then manually calls all of the evolvers
to bring things up to the current generation.
* Always put a schema manager in your application, with the starting
generation of 0, so that you can upgrade in the future.

Neither option seems quite tenable - like a bad hack that goes against
the Zope 3 concepts. You shouldn't need a schema manager utility until
you need it, and having a script that manually does
'evolve1.evolve(context); evolve2.evolve(context)'... seems like it
goes against the sort of problem that the generations system is trying
to solve.

Is there something about the schema manager/generations system that I missed?
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users