ArchGenXML / UML and Plone

43
ArchGenXML / UML and Plone Plone Regional Symposium New Orleans, LA July 22, 2005 Nate Aune Jazkarta Consulting www.jazkarta.com

description

July 22, 2005. Using the Poseidon UML modeling tool and ArchGenXML, this presentation shows how to create a Plone product in a matter of minutes without writing a single line of code. The example used is ArtistSite, a model of artists, bands and recordings which is then transformed into a Plone product. Presented at the North America Plone Symposium in New Orleans, LA. (7/22/2005)

Transcript of ArchGenXML / UML and Plone

Page 1: ArchGenXML / UML and Plone

ArchGenXML / UMLand Plone

Plone Regional SymposiumNew Orleans, LA

July 22, 2005

Nate AuneJazkarta Consultingwww.jazkarta.com

Page 2: ArchGenXML / UML and Plone

Who am I?

• Developer and owner, Jazkarta Consulting (www.jazkarta.com)

• Musician - saxophonist and composer (www.nateaune.com/music/)

• Founder of Plone4Artists project (www.plone4artists.org)

Page 3: ArchGenXML / UML and Plone

Overview

• What is Archetypes?

• What is UML?

• What is ArchGenXML?

• Build a model using UML

• Transform the model into a Plone

• Questions?

Page 4: ArchGenXML / UML and Plone

What is Archetypes?

• Framework for developing Plone products

• Automatically creates view and edit pages

• Maintains unique object IDs

• Creates references between objects

Page 5: ArchGenXML / UML and Plone

Archetypes framework

• Field validation

• Standard security setup

• Alternate storage options

• Data transformation capabilities

Page 6: ArchGenXML / UML and Plone

Archetypes architecture

• Schema

• Field

• Widget

• Field

• Widget

• ...

Page 7: ArchGenXML / UML and Plone

Example Archetype: Artist

schema= Schema((StringField('title'),ImageField('photo'),LinesField('instrument'),

))

class Artist(BaseContent)schema = BaseSchema + schema

registerType(Artist,PROJECTNAME)

Page 8: ArchGenXML / UML and Plone

Widgetsschema= Schema((

StringField('title', widget=StringWidget( label=’Artist name’,

size=20), ),

ImageField('photo', widget=ImageWidget( label=’Headshot’), ),

LinesField('instrument', widget=MultiSelectionWidget( label=’Instruments’), multiValue=1, ),))

Page 9: ArchGenXML / UML and Plone

What is UML?

• UML = Uniform Modeling Language

• Standard widely-adopted graphical language

• Describes the artifacts of software systems

• Focus on conceptual representations

Page 10: ArchGenXML / UML and Plone

Artist: Described in UML

Page 11: ArchGenXML / UML and Plone

Poseidon UML tool

Page 12: ArchGenXML / UML and Plone

What is ArchGenXML?

• Command line utility

• Auto-generates code from a UML model

• No round-trip support yet

• Custom code is preserved upon regeneration

Page 13: ArchGenXML / UML and Plone

Why use ArchGenXML? (part 1)

• You want to save time

• You are a lazy programmer

• You don’t like to reinvent the wheel

• You don’t like copying and pasting code

• You make heavy use of references and interfaces

Page 14: ArchGenXML / UML and Plone

Why use ArchGenXML? (part 2)

• You have big projects with many different content types

• You want or need a well-documented interface to your product

• You like structured model- and pattern-driven software development

• You want to maintain your project in the future without getting a headache

Page 15: ArchGenXML / UML and Plone

UML to Archetypes using ArchGenXML

schema= Schema((StringField('title', widget=StringWidget( label=’Artist name’,

size=20), ),

ImageField('photo', widget=ImageWidget( label=’Headshot’), ),

LinesField('instrument', widget=MultiSelectionWidget( label=’Instruments’), multiValue=1, ),))

Page 16: ArchGenXML / UML and Plone

UML speak to AT speak

• product

• content type

• method

• field

• property

• package

• class

• operation

• attribute

• tagged value

Page 17: ArchGenXML / UML and Plone

In practice

• 1) Save your model to the Products dir

• 2) Run the ArchGenXML script

• 3) Restart Zope

• 4) Install the newly generated product

svn co svn://svn.plone4artists.org/trunk/ArtistSite

Page 18: ArchGenXML / UML and Plone

Running the script$ cd /var/local/zope/instance1/Products$ ArchGenXML/ArchGenXML.py -o ArtistSite ArtistSite.zumlArchGenXML 1.4 devel 4(c) 2003 BlueDynamics GmbH, under GNU General Public License 2.0 or later

set outfilename [string] to ArtistSiteParsing...===============opening zargoXMI version: 1.2using xmi 1.2+ parseroutfile: ArtistSiteGenerating...==============method bodies will be preserved>>> Starting new Product: ArtistSite Generating class: Artist$

Page 19: ArchGenXML / UML and Plone

ArtistSite product dir

$ ls ArtistSiteArtist.py __init__.py i18n skinsExtensions config.py refresh.txt version.txt$

Restart ZopeInstall product using QuickInstaller

Page 20: ArchGenXML / UML and Plone

Artist.py

• Inserts documentation

• Placeholders for custom code

• i18n message ids

• Using ArtistSite/model/generate_source.sh

• Inserts author information

• Creates i18n msg catalog .pot file

• strips HTML from doc strings

Page 21: ArchGenXML / UML and Plone

Add new artist

Page 22: ArchGenXML / UML and Plone

Edit artist form

Page 23: ArchGenXML / UML and Plone

View artist

Page 24: ArchGenXML / UML and Plone

Static vocabulary

• Define a static vocabulary of instruments

Page 25: ArchGenXML / UML and Plone

Dynamic vocabulary

Use ATVocabularyManager to manage list of instruments

Page 26: ArchGenXML / UML and Plone

Dynamic vocab cont...

Page 27: ArchGenXML / UML and Plone

Containment

Use the solid rhomb to make a strict containment‘Artist’ instances can only be added to an ‘Artists’ instance

Page 28: ArchGenXML / UML and Plone

Artist container

Page 29: ArchGenXML / UML and Plone

Override base class

The artists folder will get large, so make it a BTreeFolder

Page 30: ArchGenXML / UML and Plone

References

Create a direct association

results in:

Reference fieldgroup to artist(s)

Page 31: ArchGenXML / UML and Plone

Group edit form

Group is associated with artists

Page 32: ArchGenXML / UML and Plone

Reference Browser Widget as default

Page 33: ArchGenXML / UML and Plone

Configure browser widget

Select the end point

Make multivaluedSpecify relationship

Define query

Page 34: ArchGenXML / UML and Plone

Adding references

Page 35: ArchGenXML / UML and Plone

Back references

Page 36: ArchGenXML / UML and Plone

Backreferences

Groups that artist belongs to

Page 37: ArchGenXML / UML and Plone

Stereotypes

Add the ‘member’ stereotype to tell ArchGenXML to subclass CMFMember

Page 38: ArchGenXML / UML and Plone

Registration form

• SiteMember is installed

• Replaces default member

• Easy way to create new member types

Page 39: ArchGenXML / UML and Plone
Page 40: ArchGenXML / UML and Plone

PloneMall

• Example of a sophisticated e-commerce framework built using UML

• See the UML model here:

• http://www.plonemall.com/uml/UML-beta2.png/image_view_fullscreen

Page 41: ArchGenXML / UML and Plone

What I didn’t cover

• Methods

• Stereotypes

• actions, portal_tool, abstract, stub, ordered

• Generalization (Interfaces)

• Workflow

• Unit testing

Page 42: ArchGenXML / UML and Plone

Acknowledgements

• Philipp Auersperg (Blue Dynamics)

• Jens Klein (jensens)

• Martin Aspeli (optilude)

• Fabiano Weimar dos Santos (xiru)

• Bernie Snizek (DrZoltron)

• Alan Runyan and Enfold Systems

• Plone community

Page 43: ArchGenXML / UML and Plone

Links• ArchGenXML presentation - http://www.jazkarta.com/presentations/archgenxml-presentation

• ArchGenXML product page - http://plone.org/products/archgenxml

• ArchGenXML getting started tutorial by Jens Klein

• http://plone.org/documentation/tutorial/archgenxml-getting-started

• ArchGenXML manual (with screenshots)

• http://plone.org/documentation/archetypes/archgenxml-manual

• Intro to Archetypes by Sidnei da Silva, published on ZopeMag.com

• http://www.zopemag.com/Issue006/Section_Articles/article_IntroToArchteypes.html

• Archetypes: Customizing Plone in 60 seconds (PDF) by Andy McKay

• http://www.enfoldsystems.com/About/Talks/archetypes.pdf

• Archetypes Fields Quick Reference by Maik Röder

• http://plone.org/documentation/archetypes/arch_field_quickref_1_3_1

• Archetypes Widgets Quick Reference by Maik Röder

• http://plone.org/documentation/archetypes/arch_widget_quickref_1_3_1