PloneConf2011 - How to build ERP application while having fun

Preview:

Citation preview

How to build complex

web applications having fun?

How to build complex

web applications having fun?

How to build complex

web applications having fun?

How to build complex

web applications having fun?

How to build complex

web applications having fun?

How to build complex

web applications having fun?

the team

the team

WHY this talk?

My Reasons to be here

★ Building complex web

applications should

be fun

★ to promote

SMALL “Roughly 5000 lines of code”

SMALL

FAST

“Roughly 5000 lines of code”

SMALL

FAST

STABLE

“Roughly 5000 lines of code”

SMALL

TESTED

FAST

STABLE

“Roughly 5000 lines of code”

“100% statement coverage via unit and

integration tests”

SMALL

DOCUMENTED

TESTED

FAST

STABLE

“Roughly 5000 lines of code”

“100% statement coverage via unit and

integration tests”

“Literally nothingin Pyramid

is undocumented”

★ Debug Toolbar

★ Flexible authentication

and authorization

★ Tweens - a bit like WSGI

middleware

★ Decorator-based configuration

from pyramid.view import view_configfrom pyramid.response import Response

@view_config(route_name='fred')def fred_view(request): return Response('fred')

★ Event system (based on ZCA)

from pyramid.events import NewRequestfrom pyramid.events import subscriber

@subscriber(NewRequest)def mysubscriber(event): event.request.foo = 1

★ Extendable configuration

from pyramid.config import Configurator

if __name__ == '__main__': config = Configurator() config.include('pyramid_formalchemy')

the project

The Customer

★ .

★ Born as a startup

★ Offices in US

Water today

★ U.S. - the largest consumer market

for bottled water in the world

★ in 2011, the market is forecast to have

a value of $86,421.2 billion

“Bottled water has become the second largest commercial beverage category”

project requirements

paperless sale

paperless sale

CRM

Sales

1 2 3 4 5

Warehouse

E-commerce

Support

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

★ Customer’s management (satisfaction, order status, etc.)

★ Reports (machine statistics, etc.)

★ Campaigns

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

★ Sales network management

★ Invoicing / accountancy

★ Revenue counter

★ Discount management

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

★ Catalog management

★ Warehouse management

★ Logistic tracking

★ Online shop (for beverages and accessories)

★ Machine configurator (interactive wizard)

★ Online payments

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

★ Machine maintenance (filter change)

★ Emergency services

★ Order / installation process

paperless saleCRM

Sales

1

2

3

4

5

Warehouse

E-commerce

Support

★ Machine maintenance (filter change)

★ Emergency services

★ Order / installation process

Support

CRM

Sales

Warehouse

E-commerce

paperless sale

Support

CRM

Sales

Warehouse

E-commerce

Intranet Extranet

paperless sale

Totally paperless ERP

project gotchas

project gotchas

★ Requirements are not rock

solid (it’s a startup) - project will

grow with the customer

★ Customer is in U.S. - planning

regular meetings is essential

★ We need to find new framework

for ERP part

★ Only 5 months to delivery

Arch i tectural dec i s ions

a n d

a n d

★ architecture is not so far

away from Zope

★ it supports SQLAlchemy

out of the box

★ great documentation and

active community

★ add’s some fresh air to your

architecture

why ?

★ pyramid_formalchemy CRUD

★ easy pluggable widgets

★ Multi-upload

★ Metric units

★ Autocomplete

★ Multi-relation

★ 75% jQuery code

why ?

★ pyramid_formalchemy CRUD

★ easy pluggable widgets

★ Multi-upload

★ Metric units

★ Autocomplete

★ Multi-relation

★ 75% jQuery code

why ?

★ pyramid_formalchemy CRUD

★ easy pluggable widgets

★ Multi-upload

★ Metric units

★ Autocomplete

★ Multi-relation

★ 75% jQuery code

why ?

and ?

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ Diazo (plone.app.theming)

and ?

★ Poi

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ PAS (PluggableAuthService)

★ Diazo (plone.app.theming)

and ?

★ Poi

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ PAS (PluggableAuthService)

★ Poi

★ Diazo (plone.app.theming)

and ?

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ PAS (PluggableAuthService)

★ Poi

★ Diazo (plone.app.theming)

and ?

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ PAS (PluggableAuthService)

★ Poi

★ Diazo (plone.app.theming)

and ?

★ The Best CMS ever

★ easy to integrate with

other Python frameworks

★ almost 2000 addons

★ PAS (PluggableAuthService)

Integrat ion

SQ LA l c hemy

PostgreSQL

aeterna.models

SQ LA l c hemy

au then t i c a t ion - au thor iza t ion

auth storage

au then t i c a t ion - au thor iza t ionR

equ

est

PostgreSQL

repoze.who

pas.plugins.sa

auth storage

au then t i c a t ion - au thor iza t ion

★ users

★ groups

★ roles

PostgreSQL

auth storage

au then t i c a t ion - au thor iza t ion

★ users

★ groups

★ roles

PostgreSQL

single-sign-on

★ plone.session

★ repoze.who.plugins.auth_tkt

mod_auth_tkt

bu i l dout

[intranet-plone]

recipe = plone.recipe.zope2instance

eggs =

${intranet-plone:eggs} aeterna.models

[intranet-pyramid]

recipe = zc.recipe.egg

eggs =

${intranet-pyramid:eggs} aeterna.models

T he b ig p i c ture

PostgreSQL

ZODB

Ap

ach

e

repoze.who

pas.plugins.sa

beaker

intranetextranet

T he b ig p i c ture

PostgreSQL

ZODB

Ap

ach

e

repoze.who

pas.plugins.sa

beaker

why not other compet i tors?

django: no!★ less code more magic

★ not so flexible

(specification is growing)

★ using SQLAlchemy within

could be tricky

drupal : no!★ security problems

(370 CVE entries)

★ integration is more difficult

(PHP vs. Python)

★ missing features

workflow, complex ACL, etc.

openerp : no!★ quite complex: CRM, sales,

accounting and much more

★ not enough time

to fully investigate it

★ not a generic framework

results

What matters?

Proper Tools

and a good team

★ Prototyping - it’s always a

lot of fun, but...

★ be aware of The

Learning Curve Effect

★ Collecting specification and

keeping docs up-to-date

(a real on-going process)

check this out!

pyramid_formalchemy

★ started by gawel (Gaël Pasgrimaud)

and supported by

★ using SQLAlchemy,

Formalchemy and fanstatic

★ available on pypi more then 1720 downloads so far

pyramid_formalchemy

★ Lots of improvements during

by

★ events hooks

★ view and action customizations

★ i18n support

★ paster templates

★ fanstatic integration

★ Minimal configuration:

pyramid_formalchemy

def main(global_config, **settings):

engine = engine_from_config(settings, 'sqlalchemy.') initialize_sql(engine) config = Configurator(settings=settings)

# pyramid_formalchemy's configuration config.include('pyramid_formalchemy')

# register an admin UI config.formalchemy_admin('/admin', package='pyramidapp')

return config.make_wsgi_app()

★ Minimal configuration:

pyramid_formalchemy

★ Events subscriptions:

pyramid_formalchemy

@events.subscriber([User, events.IBeforeEditRenderEvent])def before_user_edit(context, event):

fs = event.kwargs['fs']

# add roles_manage field for manager: if not has_permission('manage', event.request): fs.append(fs.roles_manage) # set TinyMCE as a renderer for biography field: fs.biography.set(renderer=tinymce)

★ Events subscriptions:

pyramid_formalchemy

pyramid_formalchemy

★ demohttp://docs.formalchemy.org/demo/admin

★ documentationhttp://docs.formalchemy.org/pyramid_formalchemy

★ downloadhttp://pypi.python.org/pypi/pyramid_formalchemy

pyramid_formalchemy

★ demohttp://docs.formalchemy.org/demo/admin

★ documentationhttp://docs.formalchemy.org/pyramid_formalchemy

★ downloadhttp://pypi.python.org/pypi/pyramid_formalchemy

★ a pyramid_formalchemy plugin

★ based on twitter bootstrap

★ integrated with fanstatic

★ released on pypi

http://pypi.python.org/pypi/fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

fa.bootstrap

Quest ions?