build by design for plone - lmu

43
ArchGenXML Build by Design for Plone Richard Amerman 7 Tech NW www.7technw.com

Upload: others

Post on 11-Apr-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Build by Design for Plone - LMU

ArchGenXMLBuild by Design

for Plone

Richard Amerman7 Tech NW

www.7technw.com

Page 2: Build by Design for Plone - LMU

Who am I?

● Open Source Advocate● Plone, Asterisk, LEAF

● Plone/Asterisk Developer/Integrator● Owner of 7 Tech Northwest● Plone Trainer● Idealist

Page 3: Build by Design for Plone - LMU

Overview

● What is this all about?● What are the pieces?

– Archetypes– UML– ArchGenXML

● Why would I use this?● How do I use this?● Where are things going in the future?

Page 4: Build by Design for Plone - LMU

What is this all about?

● RAD (Rapid Application Development)

● For the un-initiated– Generating a new product for Plone from a drawing

● For the converted– Generating an Archetypes based Plone product

from a UML diagram

Page 5: Build by Design for Plone - LMU

What are the Pieces?

● Archetypes● UML (Universal Modeling Language)● ArchGenXML

Page 6: Build by Design for Plone - LMU

What is Archetypes?

● Framework for developing Plone products– Automatically creates view and edit pages– Maintains unique object IDs– Creates references between objects

Page 7: Build by Design for Plone - LMU

Archetypes framework● Field validation● Standard security setup● Alternate storage options● Data transformation capabilities

Page 8: Build by Design for Plone - LMU

Archetypes Architecture● Class

– Schema● Field

–Widget● Field

–Widget● ...

– Method– Method

Page 9: Build by Design for Plone - LMU

Archetypes Example: rogue

schema=Schema(( StringField('first_name'), StringField('last_name'), ImageField('photo'),))

class Rogue(BaseContent) schema = BaseSchema + schema

registerType(Rogue,PROJECTNAME)

Page 10: Build by Design for Plone - LMU

Archetypes: Widgets

schema=Schema(( StringField('first_name', widget=StringWidget( label='First Name', size=15) ), StringField('last_name', widget=StringWidget( label='Last Name', size=15) ), ImageField('photo', widget=ImageWidget( label='Headshot', show_content_type=True) ),))

Page 11: Build by Design for Plone - LMU

What is UML?

● UML = Uniform Modeling Language● Standard widely-adopted graphical language● Describes the artifacts of software systems● Focus on conceptual representations

Page 12: Build by Design for Plone - LMU

Rogue defined in UML

Page 13: Build by Design for Plone - LMU

Poseidon for UML

Page 14: Build by Design for Plone - LMU

More Complex UML Model

Page 15: Build by Design for Plone - LMU

UML Editors

● Recomended– Poseidon (Commercial) (by Gentleware)– ArgoUML (Open Source)

● Others– ObjectDomain (Commercial) – Powerdesigner (Commercial) (by Sybase)– Umbrello (Open Source) (KDE)

Page 16: Build by Design for Plone - LMU

What is ArchGenXML?

● Command line utility● Auto-generates code from a UML model● Produces well formed Archetypes based Plone

products ready to install● No round-trip support yet● Custom code is preserved upon regeneration

Page 17: Build by Design for Plone - LMU

Why Would I Use This?

● Your cool● You like pictures● 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 18: Build by Design for Plone - LMU

Why Would I Use This?Continued

● 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 patterndriven software development

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

● You want to have productive discussions with your clients about a product without creating extra documentation

Page 19: Build by Design for Plone - LMU

How Would I Use This?

● Design and maintain product as model● Generate product using ArchGenXML● Add additional code to safe areas of generated

items● Use model as the center of discussion about

the product

Page 20: Build by Design for Plone - LMU

UML to Archetypesusing ArchGenXML

schema=Schema(( StringField('first_name', widget=StringWidget( label='First Name', size=15) ), StringField('last_name', widget=StringWidget( label='Last Name', size=15) ), ImageField('photo', widget=ImageWidget( label='Headshot', show_content_type=True) ),))

Page 21: Build by Design for Plone - LMU

UML speak to AT speak

● package● class● operation● attribute● tagged value

● product● content type● Method● field● property

Page 22: Build by Design for Plone - LMU

In practice1)Create UML model to describe your type

2)Export your model as XMI

3)Run the ArchGenXML script

4)Restart Zope to install product in Zope

5)Install the newly generated product in Plone site

Page 23: Build by Design for Plone - LMU

Generated Files/Folders

Page 24: Build by Design for Plone - LMU

[mytype].py

● Inserts documentation● Placeholders for custom code● i18n message ids● Using generate_source.sh

– Inserts author information– Creates i18n msg catalog .pot file– strips HTML from doc strings

Page 25: Build by Design for Plone - LMU

Tagged Values

● Set properties on object– Widget– Required– Default– Vocabulary– Searchable– Accessor– allowed_types– multiValued

Page 26: Build by Design for Plone - LMU

Tagged Values: Example

Page 27: Build by Design for Plone - LMU

Variants of Content Types

● Simple Classes● Folderish Classes● Portal Tools● Packages● Advanced

– Abstract mixin classes– Stub classes– Interfaces

Page 28: Build by Design for Plone - LMU

Workflow Generation

● Created using UML state diagram● Attached to a single class● Consists of the following:

– Initial State– States– Transitions (an arrow connecting two states)

Page 29: Build by Design for Plone - LMU

Workflow: Additional Items

● Transition guards● Permissions● Workflow actions● Worklists

Page 30: Build by Design for Plone - LMU

Workflow: Example State Diagram

Page 31: Build by Design for Plone - LMU

Custom Template Generation

● Custom Templates– Add method with 'view' stereotype

● Should follow [mytype]_view naming convention● Example: <<view>>+rogue_view{}:● Produces sparse template

● Portlet Generation– Add method with 'portlet' stereotype

● Should follow portlet_[myportlet] naming convention● Example: <<portlet>>+rogue_view{}:● Produces nice template

Page 32: Build by Design for Plone - LMU

Other Items

● Methods– Added as methods to a class in the model– Should not have a return

● Actions– Added as methods to a class in the model

● Forms– Added as methods to a class in the model– Generates empty form-controller template

Page 33: Build by Design for Plone - LMU

Third Party Product Integration

● ATVocabularyManager– Dynamic Vocabularies

● Relations– Support for Relations Product (complex references)

● CMFMember– Custom member types– Replace existing Plone member

Page 34: Build by Design for Plone - LMU

CMFMember Integration

Page 35: Build by Design for Plone - LMU

uml.joelburton.com● http://uml.joelburton.com/● An experimental web service for converting UML diagrams to Archetypes products.

Page 36: Build by Design for Plone - LMU

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 37: Build by Design for Plone - LMU
Page 38: Build by Design for Plone - LMU

Where are Things Going in the Future?

● ArchGenXML– Still actively developed (more than Genesis)– Will be updated for Plone 2.5

● Genesis– New replacement for ArchGenXML– Still being developed

Page 39: Build by Design for Plone - LMU

Summary

● What is this all about?● What are the pieces?

– Archetypes– UML– ArchGenXML

● Why would I use this?● How do I use this?● Where are things going in the future?

Page 40: Build by Design for Plone - LMU

Missing Pieces

● Deriving/Subclassing● Command Line Switches● Custom Validation● Custom Widgets● Imports● Methods and Actions● Unit testing

Page 41: Build by Design for Plone - LMU

Resources● ArchGenXML product page

– http://plone.org/products/archgenxml

● ArchGenXML getting started tutorial by Jens Klein

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

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

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

● Archetypes Quick Reference Manual by Maik Röder

– http://plone.org/products/archetypes/documentation/manual/quickref

Page 42: Build by Design for Plone - LMU

ArchGenXML Acknowledgements

● Philipp Auersperg (Blue Dynamics)● Jens Klein (jensens)● Martin Aspeli (optilude)● Reinout van Rees (reinout)● Joel Burton● ArchGenXML Dev Team● Plone community

Page 43: Build by Design for Plone - LMU

Special Acknowledgement

Special Thanks!This presentation was inspired by and barowed from a

great presentation by Nate Aune:● http://www.jazkarta.com/presentations/ArchGenXML-UML-talk.pdf

● Nate Aune (natea)– www.jazkarta.com

[email protected]