1.4.
Hello World
Up one level
Open the UML tool of your choice. Make a new UML model and give it a name
HelloWorld. Then add a class diagram (most UML tools do this automatically).
Choose the tool for class creation and add a class to the diagram. Give it a
name such as "HelloType" and add an attribute HelloText with type
String. The helloworld3.zargo (Plone 3.0) / helloworld25.zargo (Plone 2.5) was created with ArgoUML
and contains the type as described above.
Generating the product
Save/export your model as an XMI file with the name MyFirstExample.xmi (or in an XMI-container format like .uml, .zargo or .zuml). Then go to the command line and execute:
$ archgenxml helloworld.zargo
ArchGenXML will begin code generation. When it completes, you will have a new
folder HelloWorld on your file system. Its contents looks like:
HelloWorld/ |-- Extensions | |-- Install.py | `-- __init__.py |-- __init__.py |-- config.py |-- configure.zcml |-- hellotype.py |-- interfaces.py |-- profiles | |-- cssregistry.xml | |-- factorytool.xml | |-- import_steps.xml | |-- jsregistry.xml | |-- skins.xml | |-- types | | `-- HelloType.xml | `-- types.xml |-- profiles.zcml |-- refresh.txt |-- setuphandlers.py |-- skins | |-- helloworld_images | |-- helloworld_styles | `-- helloworld_templates `-- version.txt
Installing and using the generated product
Move the whole folder HelloWorld to your Zope/Plone 3 instance's Products
folder. Restart Zope, open Plone in a browser and log in as Manager. Choose
Plone Setup from the personal bar and choose Add/Remove Products. A new
product HelloWorld should now appear in the list of products
available for install. Choose it and click install. Go to your personal
folder. In the list of addable items you'll find the new product as an
addable content type. Add a test instance to see if it works.
Thats the trick. By the way: the title is always part of the schema. But you can hide it or recycle it later, don't worry
I got this in my event.log when i try to install in Plone3.0.5
Traceback (innermost last):
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 364, in installProduct
- __traceback_info__: ('HelloWorld',)
Module Products.ExternalMethod.ExternalMethod, line 231, in __call__
- __traceback_info__: ((<PloneSite at /lifetest>,), {'reinstall': False}, (False,))
Module C:\Programmer\Plone3\Data\Products\HelloWorld\Extensions\Install.py, line 139, in install
Module Products.GenericSetup.tool, line 218, in setImportContext
Module Products.GenericSetup.tool, line 225, in setBaselineContext
Module Products.GenericSetup.tool, line 230, in applyContextById
Module Products.GenericSetup.tool, line 910, in _getImportContext
KeyError: 'Unknown context ""'
Does not work helloworld3.zargo on Plone
My configuration is:
---------------------
Plone Version Overview
* Plone 3.0.6
* 2.1.1
* Zope (Zope 2.10.5-final, python 2.4.4, win32)
* Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
* PIL 1.1.6
My ArchGenXML version is:
>archgenxml --version
archgenxml-script.py Version 2.0
And the log report this :
------------------------------
2008-03-24T15:43:39 ERROR Application Couldn't install test
Traceback (most recent call last):
File "C:\Archivos de programa\Plone 3\Zope\lib\python\OFS\Application.py", line 786, in install_product
initmethod(context)
File "C:\Archivos de programa\Plone 3\Data\Products\test\__init__.py", line 124, in initialize
import HelloType
File "C:\Archivos de programa\Plone 3\Data\Products\test\HelloType.py", line 22, in ?
from Products.HelloWorld.config import *
>> archgenxml helloworld.zargo
* Plone 3.0.6
* 2.1.1
* Zope (Zope 2.10.5-final, python 2.4.4, win32)
* Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
* PIL 1.1.6
* ArchGenXML 2.0 (Beta release 11)
* Windows Server 2003