October 27, 2016
Hot Topics:

Painting Web Applications

  • April 20, 2007
  • By Sean Kelly
  • Send Email »
  • More Articles »

Generating the Code

Now that you've painted your DVD class, you're ready to generate the code that implements the DVD Collection product. First, you need to export your model into a format that the ArchGenXML tool can read. The standard format for the interchange of models is called XMI, which stands for XML Metadata Interchange. Most UML tools have a menu item that let you export your model as XMI. With ArgoUML, it's on the "File" menu. Export the model to a file called dvd.xmi and save it in a convenient directory.

If you recall from the last article, a Plone product is a directory under the Products directory in which the server is installed. In that article, you created a directory called DVDCollection and populated it with files and subdirectories by hand. This time, you'll let the ArchGenXML tool do it for you. So, if you still have the old DVDCollection directory, you need to get rid of it:

  1. Start your Plone server.
  2. Log in as your administrative user.
  3. Click "site setup" and then click "Add/Remove Products."
  4. Check the box next to your old "DVDCollection" product and click Uninstall.
  5. Stop your Plone server.
  6. Delete the DVDCollection directory under the Products directory.

This will make Plone and the Products directory ready to accept your new, automatically-generated DVDCollection.

Now, open a command prompt or terminal window (depending on your operating system) and navigate to the Products directory. Once there, run ArchGenXML on the dvd.xmi file. Windows users would do something like the following:

C:>cd "c:Program FilesPlone 2DataProducts"
C:Program FilesPlone 2DataProducts>ArchGenXML.py c:dvd.xmi

Mac OS X, Linux, and other Unix users would do something similar to below:

% cd/Applications/Plone-2.5.2/Instance/Products
% ArchGenXML.py ~/dvd.xmi

ArchGenXML reads the XMI file and determines what classes and schema to generate, creating them and all of the boilerplate necessary for a new Plone product. (You can re-run ArchGenXML as often as you like with newer versions of the XMI file; it will update the files as necessary to keep the product up-to-date.)

As when you hand-made the product (in the last article), ArchGenXML creates a specific set of files and subdirectories that Plone (and its underlying application server) expect. There is just one small thing you need to do by hand: place the icon for the DVD class, dvd.gif, into the DVDCollection/skins/DVDCollection subdirectory. If you don't have a copy of it from the last article, help yourself to this one: .

You're in the home-stretch now! All that remains is to try it out!

Trying It Out

Restart your Plone server now and log in as an administrator. Click "site setup" and then click "Add/Remove Products." The automatically generated DVDCollection product should appear in the list of products available for installation. Check the box next to it and click the "Install" button.

Now, head over to your home folder by clicking "my folder" in the blue personal bar. Then, click the green "add item" menu and choose to add a new DVD. Fill in the form and click Save. For example, here I'm entering the details for DVD #41 on my shelf:

That's it! You've now created a new product with a single content type and made it a web application without even firing up your favorite text editor. As before with the hand-made version, you can search for this DVD using Plone's LiveSearch or advanced search, see it in folder listings, and update its attributes. All the features such as template generation, form generation, validation, and so forth are still there.

Was this really less work? Maybe not in the case of a product with just a single content type. But, painting your web applications and generating the code with ArchGenXML really pays off when you start subclassing content types, add aggregation relationships, add composition, take advantage of references, and use workflow. Painting all of these things is a lot easier and less error-prone than typing it all in. Including these object-oriented concepts will turn this "toy" DVD collection application into a real heavy duty web application. But, that will have to wait until next month!

For more information on ArchGenXML, do check out the following links:

About the Author

Sean Kelly routinely fools his clients in the media, medical, and aerospace industries into believing he's an insanely efficient web application developer—when all he really does is paint out the web applications, add a few icons, and take an early lunch prominently featuring martinis. He's available for hire, if the preceding statement hasn't scared anyone off.

He lives in a house that he also paints (but with actual brushes and pigments) with his wife and daughter, who are genuinely concerned about his practice of doing touch-up around the place after a martini-heavy lunch.

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel