[Product-Developers] Registering Local Utilities

5 Messages Forum Options Options
Embed this topic
Permalink
Nathan Van Gheem
[Product-Developers] Registering Local Utilities
Reply Threaded MoreMore options
Print post
Permalink
Hello,

    I am having trouble when trying to register a local utility.  It seems that I can't get the data to persist when the product is reinstalled.  How could I go about making the data persistent? 


Any help would be much appreciated. 


Thanks,
Nathan

_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers
Nathan Van Gheem
[Product-Developers] Re: Registering Local Utilities
Reply Threaded MoreMore options
Print post
Permalink
Certainly someone else has come across this issue.  Is this just a limitation of local utilities?  The utility is registered and work fine.  I can restart the server and the data is still there.  It is just on reinstall that I lose it.  The probably is that it re-creates the tool.

I am creating a zope 3 style product with this and it seems like there are no setup handlers to manage a reinstall of a product.  Is this correct?  I have methods registered in the "import_steps.xml" file, but haven't figured out how to register handlers for before the local utility is reinstalled.

Does anyone know of a way to manage reinstalls of local utilities so I can migrate the data and mitigate this problem?

Thanks,
Nathan

On Thu, Jun 12, 2008 at 5:44 PM, Nathan Van Gheem <vangheem@...> wrote:
Hello,

    I am having trouble when trying to register a local utility.  It seems that I can't get the data to persist when the product is reinstalled.  How could I go about making the data persistent? 


Any help would be much appreciated. 


Thanks,
Nathan


_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers
Martin Aspeli-2
[Product-Developers] Re: Registering Local Utilities
Reply Threaded MoreMore options
Print post
Permalink
Nathan Van Gheem wrote:
> Certainly someone else has come across this issue.  Is this just a
> limitation of local utilities?

I think it's a bug in the componentregistry import GenericSetup handler.

>  The utility is registered and work
> fine.  I can restart the server and the data is still there.  It is just
> on reinstall that I lose it.  The probably is that it re-creates the tool.

Yeah, I think so.

> I am creating a zope 3 style product with this and it seems like there
> are no setup handlers to manage a reinstall of a product.  Is this
> correct?  I have methods registered in the "import_steps.xml" file, but
> haven't figured out how to register handlers for before the local
> utility is reinstalled.

What do you want to do with a custom handler?

> Does anyone know of a way to manage reinstalls of local utilities so I
> can migrate the data and mitigate this problem?

If you can, try to find out what the problem is and supply a patch. :)

Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book


_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers
Martin Aspeli-2
[Product-Developers] Re: Registering Local Utilities
Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Nathan Van Gheem
Nathan Van Gheem wrote:
> Certainly someone else has come across this issue.  Is this just a
> limitation of local utilities?  The utility is registered and work
> fine.  I can restart the server and the data is still there.  It is just
> on reinstall that I lose it.  The probably is that it re-creates the tool.

I think the problem is in Products.GenericSetup.components - in
_initUtilities it does

              elif factory is not None:
                 self.context.registerUtility(factory(), provided, name)

without first checking of a utility with this name for this interface
already exists.

I'd say that by default, it should not overwrite utilities like that,
though perhaps there should be a purge="true" option on the <utility />
statement to get this behaviour if required.

Perhaps a post to zope-cmf about this?

Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book


_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers
Nathan Van Gheem
Re: [Product-Developers] Re: Registering Local Utilities
Reply Threaded MoreMore options
Print post
Permalink

Martin Aspeli wrote,
I am creating a zope 3 style product with this and it seems like there are no setup handlers to manage a reinstall of a product.  Is this correct?  I have methods registered in the "import_steps.xml" file, but haven't figured out how to register handlers for before the local utility is reinstalled.

What do you want to do with a custom handler?

I wanted to grab the info in the local utility before it was uninstalled and set the values back on install.

Martin Aspeli wrote,
I think the problem is in Products.GenericSetup.components - in _initUtilities it does

            elif factory is not None:
               self.context.registerUtility(factory(), provided, name)

without first checking of a utility with this name for this interface already exists.

This is not the problem.  I stepped through the code and at this point, the component is no longer registered.  I'll post to zope-cmf and see what I come up with.  Thanks

On Fri, Jun 13, 2008 at 5:25 PM, Martin Aspeli <optilude@...> wrote:
Nathan Van Gheem wrote:
Certainly someone else has come across this issue.  Is this just a limitation of local utilities?  The utility is registered and work fine.  I can restart the server and the data is still there.  It is just on reinstall that I lose it.  The probably is that it re-creates the tool.

I think the problem is in Products.GenericSetup.components - in _initUtilities it does

            elif factory is not None:
               self.context.registerUtility(factory(), provided, name)

without first checking of a utility with this name for this interface already exists.

I'd say that by default, it should not overwrite utilities like that, though perhaps there should be a purge="true" option on the <utility /> statement to get this behaviour if required.

Perhaps a post to zope-cmf about this?


Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book


_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers


_______________________________________________
Product-Developers mailing list
Product-Developers@...
http://lists.plone.org/mailman/listinfo/product-developers