sábado, 26 de abril de 2008

BadRequest error running the import steps of a selected profile from a product with several profiles

I had to add an action to a content type named "Attachment" for a Plone 3 product. That is just adding the action in the profiles/default/types/Attachment.xml generated by ArchGenXML 2.0. But there is a problem. That file has no special sections for custom code, so it will be overwritten every time we regenerate the product from our model.

My first attempt was to create another profile, called attachment, where I will put the modifications, and running the step from the Install.py. That is:

  • create a profiles/attachment/types/Attachment.xml and include there the action I need to add in a proper xml structure.

  • register the profile in the main configure.zcml (archgenxml will create a profiles.zcml for this purpose)
<!-- ##code-section profiles.zcml-top #fill in your manual code here -->
<genericsetup:registerProfile
name="attachment"
title="MyProduct-customized-profile"
directory="profiles/attachment"
description="Customized extension profile for MyProduct."
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<!-- ##/code-section profiles.zcml-top -->

  • put this code in Extensions/Install.py
from Products.CMFCore.utils import getToolByName

def afterInstall(self, reinstall, product):
portal_setup = getToolByName(self, 'portal_setup')
portal_setup.runAllImportStepsFromProfile('profile-Products.MyProduct:attachment')


But when I installed the product, I got:

BadRequest: The id "import-all-profile-Products.MyProduct_attachment-20080426230436.log" is invalid - it is already in use.


I was importing the steps of a profile that QuickInstaller had already imported. But my product wasn't completely installed yet...

The problem is that QuickInstaller imported the attachment profile not because it imports every step, but because it imports the first registered profile in alphabetical order. At least, that's what I concluded, because, after moving profiles/attachment to profiles/extra, and renaming attachment for extra in the previous fragments of code, it worked.

The default profile wasn't imported. And looking at the installable products on QuickInstaller Control Panel page, the attachment product was listed, instead of the MyProduct profile that used to be there.

So, should I use only names that follows 'default' in lexicograpic order for additional profiles? I would expect that QuickInstaller only executed the default profile. Maybe I missed something... This was the first time I added a second profile.

1 comentario:

Anónimo dijo...

Online Casino 2021 | kadangpintar.com
and win real money on online febcasino casino 2021. Check our deccasino list of top casinos and kadangpintar read our online casino 2021 reviews.