Rapid Application Development in Plone - Paul Roe

download Rapid Application Development in Plone - Paul Roe

If you can't read please download the document

Transcript of Rapid Application Development in Plone - Paul Roe



Rapid Application Development in Plone

Presenter: Paul RoeCompany: TheVirtual Limited

Building Plone sites since 2002

www.thevirtual.co.nz

Hi I'm Paul from TheVirtual

People get pictures

When you talk code, logic or in abstract it hurts the head of the client and misses that rare opportunity to use the client's eyes and ears at the same time. Steven Gourley

I'm going to give brief introduction to using UML modelling and the ArchGenXML code generator.

Quickly describe a more complicated real world web application .

And then talk about some of the advantages that come with being able to use visual modelling in conjunction with ArchGenXML

My hope is that you'll see the potential of these tools and give them a go.

Pictures

UML (Unified Modelling Language) General purpose visual modelling language.

We're interested in data models (entities and relationships), workflows and events.

Gui ToolsArgoUML http://argouml.tigris.org/

Poseidon http://www.gentleware.com/

ObjectDomain http://www.objectdomain.com/

We use ArgoUML. There are some relevant tutorials on the Plone site in the ArchGenXML howtos.

ArgoUML

Initial ArgoUML screen. There's a UML Profile available for Archetypes which includes most of the stuff you need for getting things working.

Simple Content

As an example we'll subclass a Document and add a couple of fields.

Field Properties (tags)

Changing properties of fields, content types and relationships is easy.

Select the field, Click tags and add tags to change the label, description and field level permissions etc

You can add tags on the content type as well allowing permissions and many other properties to be controlled.

We've set the modify permission on the field when we generate code later we'll see the label and write permissions have been set on the schema

Add Workflow (Statechart)

Now we'll add a simple workflow.

If you're happy with the default plone workflow you don't need to do anything as ArchGenXML takes care of that.

But if you need something special adding a workflow to a content type is simple. Select the content type and add a statechart from the context menu

You can also assign an existing workflow via a tag on the content type

States and transitions

Add workflow states and transitions, and events.

Set permissions on the object and control access to the transitions

ArchGenXML

http://plone.org/products/archgenxml

code generator

Generates Python code from UML-Models (XMI-Format)

Take advantage of version control

Plone and Archetypes changes

There are pros and cons of using code generation and gui tools for building applications. I've used a few systems in the past and I'm well aware of problems that can arise. Using version control on the models and generated code ensures that you understand whats going on when things are regenerated.

Some of the many advantages are the reduction in boilerplate and ease of making major changes to the code base.

Upgrades in Plone have also been much easier. The change to Generic Setup being one as new versions of ArchgenXML support the changes

Generate

$ archgenxml -c generate.conf PhotoDoc.zargo

schema = Schema((

ImageField( name='photo', widget=ImageField._properties['widget']( label='Photo', label_msgid='PhotoDoc_label_photo', i18n_domain='PhotoDoc', ), storage=AnnotationStorage(), write_permission="PhotoDoc: Modify Images", label="An Image", ), StringField( name='code', widget=StringField._properties['widget']( label='Code',

Now we're going to generate the code, the first line invokes archgenxml.

The rest is just a small part of the generated code for the schema in the content type.

You can see the label and write permission on the field is set as per our model.

Manual Code

class photodoc(BaseContent, BrowserDefaultMixin): """ """ security = ClassSecurityInfo()

implements(interfaces.Iphotodoc)

meta_type = 'photodoc' _at_rename_after_creation = True

schema = photodoc_schema

##code-section class-header #fill in your manual code here ##/code-section class-header

# Methods

registerType(photodoc, PROJECTNAME)# end of class photodoc

##code-section module-footer #fill in your manual code here##/code-section module-footer

Throughout all the generated files there are plenty of places to put custom code which is kept across rebuilds.

ArchGenXML builds the entire file structure and sets up the profiles for install and configuration

Install

Copy across product, restart plone and you can install in a plone site.

This all took about as long to explain as to actually do it!

The real value of the UML diagramming and ArchGenXML comes when building something more complicated.

Something
More Complicated

Its all very well being able to demo easy stuff, but how practical is it in the real world working with customers.

These are a couple of the UML models from a real project.


A real project

Steve Gourley approached us with the plan to build a web application for his Heath and Fitness Training and Recruitment company (NZIHF).

Steve was well prepared and at our first meeting I suggested that the best way forward was to use use a GUI tool to analyse and explore the project. By collaboratively building a visual model of the application we would both better understand the project, and be able to work through any complex relationships and workflows more easily.We had regular meetings for an hour or two. With builds, extra custom code and testing done between.

The previous image shows parts of that project.

Simple Workflow

There's not a lot of time to go into detail, but in this and the next few slides I'll show a few small parts that correspond to the simple demo at the start

This is one of the simple workflows from the project

Its reused over a few content types

Permissions

This shows the permissions on a state in a training workflow.

It shows who can access and change the object.

The worklist tag means that when the object is in this state it appears in a review list similar to what a Reviewer would see with pending items.

Events

This shows the properties on a transition in a workflow.

Events can be fired on transitions.

We setup a subscriber in the Effect Field.

The subscriber in this case is fired when someone passes part of a course. This does a few checks and can change the state of their course to Passed if they've completed everything.

It generates all the boiler plate for the Subscriber, just leaving the actual checks to be coded.There's a lot more to show, but that all we have time for.

Steve Gourley - NZIHF

A significant feature in attaining a good result for us was the opportunity to see the object and itsrelationships to other objects

We had no idea the thing was then generating code, but we did know what was being talked about and therefore had a richer exploration of what we wanted in a more economic (time, which is money in development too!) way.

Steve best sums up the advantages of UML, ArchGenXML and Plone.

It really works well and the more input from the customer the better it works!

Thanks Questions?

Steve is happy to talk to people he's at nzihf.co.nz



Rapid Application Development in Plone

Presenter: Paul RoeCompany: TheVirtual Limited

Building Plone sites since 2002

www.thevirtual.co.nz

Thanks