Date post: | 12-May-2015 |
Category: |
Technology |
Upload: | jazkarta-inc |
View: | 2,381 times |
Download: | 1 times |
ArchGenXML / UMLand Plone
Plone Regional SymposiumNew Orleans, LA
July 22, 2005
Nate AuneJazkarta Consultingwww.jazkarta.com
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)
Overview
• What is Archetypes?
• What is UML?
• What is ArchGenXML?
• Build a model using UML
• Transform the model into a Plone
• Questions?
What is Archetypes?
• Framework for developing Plone products
• Automatically creates view and edit pages
• Maintains unique object IDs
• Creates references between objects
Archetypes framework
• Field validation
• Standard security setup
• Alternate storage options
• Data transformation capabilities
Archetypes architecture
• Schema
• Field
• Widget
• Field
• Widget
• ...
Example Archetype: Artist
schema= Schema((StringField('title'),ImageField('photo'),LinesField('instrument'),
))
class Artist(BaseContent)schema = BaseSchema + schema
registerType(Artist,PROJECTNAME)
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, ),))
What is UML?
• UML = Uniform Modeling Language
• Standard widely-adopted graphical language
• Describes the artifacts of software systems
• Focus on conceptual representations
Artist: Described in UML
Poseidon UML tool
What is ArchGenXML?
• Command line utility
• Auto-generates code from a UML model
• No round-trip support yet
• Custom code is preserved upon regeneration
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
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
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, ),))
UML speak to AT speak
• product
• content type
• method
• field
• property
• package
• class
• operation
• attribute
• tagged value
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
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$
ArtistSite product dir
$ ls ArtistSiteArtist.py __init__.py i18n skinsExtensions config.py refresh.txt version.txt$
Restart ZopeInstall product using QuickInstaller
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
Add new artist
Edit artist form
View artist
Static vocabulary
• Define a static vocabulary of instruments
Dynamic vocabulary
Use ATVocabularyManager to manage list of instruments
Dynamic vocab cont...
Containment
Use the solid rhomb to make a strict containment‘Artist’ instances can only be added to an ‘Artists’ instance
Artist container
Override base class
The artists folder will get large, so make it a BTreeFolder
References
Create a direct association
results in:
Reference fieldgroup to artist(s)
Group edit form
Group is associated with artists
Reference Browser Widget as default
Configure browser widget
Select the end point
Make multivaluedSpecify relationship
Define query
Adding references
Back references
Backreferences
Groups that artist belongs to
Stereotypes
Add the ‘member’ stereotype to tell ArchGenXML to subclass CMFMember
Registration form
• SiteMember is installed
• Replaces default member
• Easy way to create new member types
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
What I didn’t cover
• Methods
• Stereotypes
• actions, portal_tool, abstract, stub, ordered
• Generalization (Interfaces)
• Workflow
• Unit testing
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
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