Generating products outside of the Products.* namespace with ArchGenXML
I'm a die hard in regards to ArchGenXML usage. The number of things to know about when creating new content types for Plone is just too high. Package structure, Zope package registration, content types registration, QuickInstaller registration, GenericSetup profiles, skins registration, workflows, etc. I can go in and do changes to the code, and add to it, but generating it from scratch is a gigantic task, especially for my use case, where I need to start a new project with about 7 content types.
Now to the problem: ArchGenXML assumes (and hardcodes in its templates) the Products.* prefix for your package. I don't have any problems with it, but my employer uses a different package structure so for uniformity I need to follow their standards. 15 minutes of poking and changing through agx enabled me to change it so it would generate GS xml files with the proper namespace (based on a new model level TGV named "namespace" that I have created). After assessing the difficulty of the task and being under time pressure, I've decided to go the dumb route, which I'm documenting below:
My generation script is something like this:
./archgenxml -c archgenxml.cfg myproduct.zuml #rename Products.myproduct to ns.myproduct find myproduct/* -type f -print | xargs sed -i 's/Products\.myproduct/ns\.myproduct/g' #in the xml type profiles, replace myproduct by ns.myproduct find myproduct/* -type f -print | xargs sed -i 's/>myproduct</>ns\.myproduct</g' #in the profiles.zcml, rename the profile to ns.myproduct find myproduct/* -type f -print | xargs sed -i 's/title=\"myproduct\"/title=\"ns\.myproduct\"/g'
Notice the sed lines, which change the source code to point to "ns.myproduct" instead of "Products.myproduct". Now there's just two more problems, which are actually AGX bugs:
- the FilesystemDirectoryViews registered for the skin are incorect, so you'll need to insert this in ns/myproduct/__init__.py
from Products.CMFCore import utils from Globals import package_home from os.path import dirname ppath = utils.ProductsPath utils.ProductsPath.append(dirname(package_home(product_globals))) DirectoryView.registerDirectory('skins', product_globals) utils.ProductsPath = ppath
- trying to get AGX to output the code inside a two level deep folder doesn't work (it crashes), so you'll need to move this script file and the model just above the "myproduct" folder, inside the "ns" namespace.
That's about it. Hopefully I'll find the time to fix the two bugs and add the namespace improvement in the next week. Still need to do the review for Plone for Education, which I have received for free from the publisher.