Download - Building an artist community website with ArchGenXML / Poseidon

Transcript
Page 1: Building an artist community website with ArchGenXML / Poseidon

www.jazkarta.com 866.864.4918Building an Artist Community Website (9/21/05)

Building an artist community website

with Poseidon / ArchGenXML / Plone

Nate AunePlone Conference

Vienna, AustriaSept. 21, 2005

Page 2: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Overview• What is Archetypes?

• What is UML?

• What is ArchGenXML?

• Build a model using UML

• Transform the model into a Plone product

• Multimedia

• Questions?

jazkarta.com/presentations/artist-community.pdf

Page 4: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

What is Archetypes?

• Framework for developing Plone products

• Automatically creates view and edit pages

• Maintains unique object IDs

• Creates references between objects

Page 5: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Archetypes framework

• Field validation

• Standard security setup

• Alternate storage options

• Data transformation capabilities

Page 6: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Archetypes schemas

Page 7: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Example Archetype: Artist

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

class Artist(BaseContent) schema = BaseSchema + schema

registerType(Artist,PROJECTNAME)

Page 8: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

What is UML?

• UML = Uniform Modeling Language

• Standard widely-adopted graphical language

• Describes the artifacts of software systems

• Focus on conceptual representations

Page 10: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Artist: Described in UML

Page 11: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Poseidon UML tool

Page 12: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

UML speak to AT speak• product

• content type

• method

• field

• property

• subclass, view

• package

• class

• operation

• attribute

• tagged value

• stereotype

Page 17: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

ArtistSite product dir

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

Restart ZopeInstall product using QuickInstaller

Page 20: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Add new artist

Page 22: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Edit artist form

Page 23: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

View artist

Page 24: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Static vocabulary

• Define a static vocabulary of instruments

Page 25: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Dynamic vocabulary

Use ATVocabularyManager to manage list of instruments

Page 26: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Dynamic vocab cont...

Page 27: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Containment

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

Page 28: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Artist container

Page 29: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Override base class

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

Page 30: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Stereotype <<large>>

• Select the class

• Click on the stereotypes button (...)

• Select the ‘stub’ stereotype

Page 31: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

References

Create a direct association

results in:

Reference fieldgroup to artist(s)

Page 32: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Group edit form

Group is associated with artists

Page 33: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Reference Browser Widget as default

Page 34: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Configure browser widget

Select the end point

Make multivaluedSpecify relationship

Define query

Page 35: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Adding references

Page 36: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Back references

Page 37: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Backreferences

Groups that artist belongs to

Page 38: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Stereotype <<member>>

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

Page 39: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Registration form

• SiteMember is installed

• Replaces default member

• Easy way to create new member types

Page 40: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Page 41: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Stereotype <<stub>>

• Add content types to your model without having them get generated

• Makes it easy to integrate 3rd party products into your custom product

• Adds allowed_content_types to your class

Page 42: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

<<stub>>

• Select the class

• Click on the stereotypes button (...)

• Select the ‘stub’ stereotype

Page 43: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Page 44: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

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 45: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

SiteEvent : a custom event type

• Subclass ATEvent and add your own fields

Page 46: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Associate with venue

• Make a:

• Venues container

• Venue content type

• Direct association from SiteEvent to Venue

Page 47: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

What I didn’t cover• Methods

• Additional Stereotypes

• actions, portal_tool, abstract, ordered

• Generalization (Interfaces)

• Workflow

• Unit testing

• Documentation

Page 48: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Acknowledgements• Philipp Auersperg (Blue Dynamics)

• Jens Klein (jensens)

• Martin Aspeli (optilude)

• Fabiano Weimar dos Santos (xiru)

• Bernie Snizek (DrZoltron)

• Blue Dynamics - conference organizers

• Plone communityGo to Jens and Phil’s ArchGenXML talk!

Page 49: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Links• How to subclass ATContentType in 7 minutes

•http://plone.org/documentation/how-to/subclass-atct-using-archgenxml• 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

Page 50: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Multimedia in Plone

• Multimedia = audio, video, photo, etc.

• Currently limited built-in support for these media file types

• No definitive multimedia package for Plone

Page 51: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Existing 3rd party products• Audio

• ATAudio, Plodcasting, PloneRadio

• Video

• ATVideo, lilix.movie, Parwin

• Photo

• ATPhoto, CMFPhoto, ZPhotoSlides

Page 52: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

PloneMultimedia• PloneMultimedia

• ATAudio

• ATVideo

• ATPhoto

• Common ‘base’ products in which to build custom multimedia products

• Add-on product for ATContentTypes

Page 53: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Subclass ATCT• ATAudio - subclass ATFile

• inherit methods: cleanupFilename, download, getIcon

• validators: checkFileSize

• ATPhoto - subclass ATImage

• getEXIF, ATFolder template-mixin (Display menu)

Page 54: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Upload audio file

• Type in a description

• Upload file

• Click ‘Next’ button

Page 55: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Metadata

• ATAudio extracts metadata

• Auto-populates form fields

• Extensible genres

• Upload album art

Page 56: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Audio view page

• Embedded player

• Play in popup window

• Stream to external media player

• Download to FS

Page 57: Building an artist community website with ArchGenXML / Poseidon

Drag-n-drop MP3s

Drag-n-drop MP3s to WebDAV folder MP3s appear in recordings folder

Page 58: Building an artist community website with ArchGenXML / Poseidon

Metadata extracted

Song Metadata (from iTunes)

ATAudio auto-extracts ID3 tags

Page 59: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

CD view page

Page 60: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Flash player

• Flash popup player

• Uses XSPF playlist

• Jump forward/backward through tracks

Page 61: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Demo

Page 62: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Thanks to...

• ATAudio team

• Volodymr Cherepanyak (chervol)

• Rocky Burt (RockyBurt)

• Salim Fadhley (_salimfadhley)

• jenner (for adding Flash player support)

Page 63: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Multimedia sprint

• This thursday and friday at the Hotel Academia!

• http://plone.org/events/sprints/multimedia

• Ask Nate for a map to the hotel

Page 64: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Multimedia Resources• http://plone.org/products/ataudio

• http://plone.org/products/plonemultimedia

• http://plone4artists.org

• Mailing list: [email protected] with subject “subscribe”

• Mailing list: [email protected] with subject “subscribe”

Page 65: Building an artist community website with ArchGenXML / Poseidon

Building an Artist Community Website (9/21/05) www.jazkarta.com 866.864.4918

Questions?