Building Extensible Desktop Applications with Zope 3 Nathan R. Yergler Software Engineer Creative Commons Licensed under Creative Commons Attribution 2.5.

Slides:



Advertisements
Similar presentations
Object orientation and persistent objects Dragos Chirila Finsiel Romania Copenhagen, 24 May 2004.
Advertisements

OneBridge Mobile Data Suite Product Positioning. Target Plays IT-driven enterprise mobility initiatives Extensive support for integration into existing.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Requirements Specification
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Data Grids: Globus vs SRB. Maturity SRB  Older code base  Widely accepted across multiple communities  Core components are tightly integrated Globus.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
High Performance Faceted Interfaces Using S2S Eric Rozell, Tetherless World Constellation.
Systems Architecture, Fourth Edition1 Internet and Distributed Application Services Chapter 13.
WebDynpro for ABAP Short introduction.
The Open Grid Service Architecture (OGSA) Standard for Grid Computing Prepared by: Haoliang Robin Yu.
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Jun Peng Stanford University – Department of Civil and Environmental Engineering Nov 17, 2000 DISSERTATION PROPOSAL A Software Framework for Collaborative.
Types of software. Sonam Dema..
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
UNIT-V The MVC architecture and Struts Framework.
Deploying Dynamics Applications Thomas Hansen – Director, appSolutions a|s
The Design Discipline.
LAYING OUT THE FOUNDATIONS. OUTLINE Analyze the project from a technical point of view Analyze and choose the architecture for your application Decide.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
CALIFORNIA DEPARTMENT OF WATER RESOURCES GEOSPATIAL TECHNICAL SUPPORT MODULE 2 ARCHITECTURE OVERVIEW AND DATA PROMOTION FEBRUARY 20, 2013.
Inventory:OCSNG + GLPI Monitoring: Zenoss 3
Codeigniter is an open source web application. It occupies a very small amount of space in the memory and is most useful for developers who aim to develop.
Dessy, 17 september 2007 Tango Meeting Development of Tango Client Applications in Python Tiago Coutinho and Josep Ribas.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Geospatial Technical Support Module 2 California Department of Water Resources Geospatial Technical Support Module 2 Architecture overview and Data Promotion.
Google Web Toolkit An Overview By Shauvik Roy Choudhary.
© 2003 Xilinx, Inc. All Rights Reserved For Academic Use Only Xilinx Design Flow FPGA Design Flow Workshop.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Shannon Hastings Multiscale Computing Laboratory Department of Biomedical Informatics.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
This material exempt per Department of Commerce license exception TSU Xilinx Tool Flow.
Framework for MDO Studies Amitay Isaacs Center for Aerospace System Design and Engineering IIT Bombay.
Interface and Implementation Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
ECI – electronic Commerce Infrastructure “ An application to the Shares Market ” Demetris Zeinalipour ( Melinos Kyriacou
Separating the Interface from the Engine: Creating Custom Add-in Tasks for SAS Enterprise Guide ® Peter Eberhardt Fernwood Consulting Group Inc.
INFSO-RI Enabling Grids for E-sciencE Ganga 4 – The Ganga Evolution Andrew Maier.
Getting Started with SIDL using the ANL SIDL Environment (ASE) ANL SIDL Team MCS Division, ANL April 2003 The ANL SIDL compilers are based on the Scientific.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
ASP.NET User Controls. User Controls In addition to using Web server controls in your ASP.NET Web pages, you can create your own custom, reusable controls.
Understand Windows Services Software Development Fundamentals LESSON 5.3.
CS223: Software Engineering Lecture 13: Software Architecture.
- How to draw a clear distinction between a client and a server(there is often no clear distinction) - A server may continuously act as a client - Distinction.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
Architectural Mismatch: Why reuse is so hard? Garlan, Allen, Ockerbloom; 1994.
1 Copyright © 2008, Oracle. All rights reserved. Repository Basics.
The Development Process of Web Applications
Fedora Project / Red Hat
Coupling and Cohesion 1.
The Open Grid Service Architecture (OGSA) Standard for Grid Computing
PYTHON: AN INTRODUCTION
Java Beans Sagun Dhakhwa.
Oracle Fusion HCM online Training at GoLogica
Ch > 28.4.
File service architecture
Modern web applications
Instructions to get MAX PLUS running
Java Applets.
Modern web applications
Outline Chapter 2 (cont) OS Design OS structure
Web Application Development Using PHP
Presentation transcript:

Building Extensible Desktop Applications with Zope 3 Nathan R. Yergler Software Engineer Creative Commons Licensed under Creative Commons Attribution 2.5 license

27 July 2006 Extensible Applications with Zope 3 2 ccPublisher

27 July 2006 Extensible Applications with Zope 3 3 ccPublisher 2 Goals Wanted to make customization easy Allow for extensibility Leverage common components  Reduced maintenance burden  We shouldn’t “own” anything that’s not strategic

27 July 2006 Extensible Applications with Zope 3 4 extensible (n): “An architectural property of a program that allows its capabilities to expand.”

27 July 2006 Extensible Applications with Zope 3 5 component (n): “a system element offering a predefined service and able to communicate with other components”

27 July 2006 Extensible Applications with Zope 3 6 Zope 3 Zope is an open source web application server Zope 3 includes a component / event model  Adapters  Utilities  Events

27 July 2006 Extensible Applications with Zope 3 7 Zope 3 Overview zope.* app componenteventinterface tal...

27 July 2006 Extensible Applications with Zope 3 8 A Simple Example class CurrencyConverterApp: def __init__(self, root):... def convert(self): # clear the output widget self.txtOutput.delete(0,END) # set the output widget to input * 2 self.txtOutput.insert(0, float(self.txtInput.get()) * 2)

27 July 2006 Extensible Applications with Zope 3 9 Steps to Extensibility Separate interface and converter functionality Decouple interface and converter using component lookup Allow for multiple providers of functionality Package core functionality as an extension

27 July 2006 Extensible Applications with Zope 3 10 Separating Responsibilities Write an interface declaration Write a component which provides the interface Use the component in the user interface

27 July 2006 Extensible Applications with Zope 3 11 IConverter class IConverter(zope.interface.Interface): def currency_name(): """Return the name of the target currency.""" def currency_symbol(): """Return the symbol for the target currency.""" def convert(usd_value): """Convert US$ value to the target currency."""

27 July 2006 Extensible Applications with Zope 3 12 The Converter Component class RealConverter: zope.interface.implements(interfaces.IConverter) def currency_name(self): """Return the name of the target currency.""" return "Real"... def convert(self, usd_value): """Convert US$ value to the target currency.""" return usd_value / 2.247

27 July 2006 Extensible Applications with Zope 3 13 Using the Component def convert(self): # clear the output widget self.txtOutput.delete(0,END) # set the output widget to input * 2 self.txtOutput.insert(0, components.RealConverter().convert( float(self.txtInput.get()) )

27 July 2006 Extensible Applications with Zope 3 14 Decoupling the Pieces Register the component as a utility Use Zope component model to lookup our converter

27 July 2006 Extensible Applications with Zope 3 15 Utilities Components which provide an interface Looked up by interface and optional name Provide global functionality Applications can be agnostic about how things happen

27 July 2006 Extensible Applications with Zope 3 16 Registering the Component from zope import component # register the converter as a utility converter = RealConverter() component.provideUtility(converter, IConverter, 'Real')

27 July 2006 Extensible Applications with Zope 3 17 Using Component Lookup def convert(self): # lookup our converter converter = zope.component.getUtility( interfaces.IConverter, 'Real') # clear the output widget self.txtOutput.delete(0,END) # set the output widget to input * 2 self.txtOutput.insert(0, converter.convert(float(self.txtInput.get())))

27 July 2006 Extensible Applications with Zope 3 18 Multiple Providers Using multiple named utilities is one option Requires us to know the names of all converters Instead we use adapters  Recall utilities provide are unique (Interface, Name)  There can be multiple subscription adapters

27 July 2006 Extensible Applications with Zope 3 19 Adapters Components computed from other components Easily convert from one type of object to another “Normal” Zope 3 Adaptation is one-to-one  one object in, one adapted object returned Subscription Adapters are different:  Return all adapters from A to B

27 July 2006 Extensible Applications with Zope 3 20 Refactoring the Interfaces class IUSD(zope.interface.Interface): def get_value(): """Return the stored value.""" class ICurrency(zope.interface.Interface): def currency_name(): """Return the name of the target currency.""" def currency_symbol(): """Return the symbol for the target currency.""" class IConverter(zope.interface.Interface): def convert(): """Convert US$ value to the target currency."""

27 July 2006 Extensible Applications with Zope 3 21 Implementing the Component class RealConverter(object): component.adapts(interfaces.IUSD) interface.implements(interfaces.IConverter, interfaces.ICurrency) def __init__(self, usd): self.usd = usd # implementation for IConverter def convert(self): return self.usd.get_value() * 2 # implementation for ICurrency...

27 July 2006 Extensible Applications with Zope 3 22 Registering the Component # Register as an ICurrency implementation for the list component.provideSubscriptionAdapter(RealConverter, provides=interfaces.ICurrency) # Register as an Adapter for the specific currency component.provideAdapter(RealConverter, provides=interfaces.IConverter, name='R$')

27 July 2006 Extensible Applications with Zope 3 23 User Interface: Target List def __init__(self, root):... # get a list of target currencies u = components.USDCurrency(None) currencies = [c.currency_symbol() for c in component.subscribers([u], interfaces.ICurrency)] self.lstTargets = Listbox(frame)...

27 July 2006 Extensible Applications with Zope 3 24 User Interface: Converting def convert (self): # create an object to hold the US$ usd = components.USDCurrency( float(self.txtInput.get()) ) # get the target currency symbol target = self.lstTargets.get( self.lstTargets.curselection()[0]) # look up the converter by target name converter = component.queryAdapter(usd, interfaces.IConverter, target) self.txtOutput.insert(END, converter.convert())

27 July 2006 Extensible Applications with Zope 3 25 Extensions Depend on application policy...  Where do they live?  How are they registered?...and application code...  What code is responsible for loading?  How are they allowed to interact with the app?

27 July 2006 Extensible Applications with Zope 3 26 Loading Extensions ccPublisher uses ZCML slugs  ZCML is an XML-based configuration language  ccPublisher looks for small ZCML files in the extensions directory and loads them setuptools provides Entry Points which you can iterate over

27 July 2006 Extensible Applications with Zope 3 27 Using entry points for loading Move each “extension” into separate modules Provide a register() function Create a simple setup.py Generate a Python Egg for each Dynamically load extensions at run time

27 July 2006 Extensible Applications with Zope 3 28 Extension Module: real.py class RealConverter(object): component.adapts(interfaces.IUSD) interface.implements(interfaces.IConverter, interfaces.ICurrency)... def register(): component.provideSubscriptionAdapter(RealConverter, provides=interfaces.ICurrency) component.provideAdapter(RealConverter, provides=interfaces.IConverter, name='R$')

27 July 2006 Extensible Applications with Zope 3 29 setup_real.py from setuptools import setup setup( name='real', py_modules=['real'], entry_points = {'currency.register': ['real = real:register'], } ) $ python setup_real.py bdist_egg

27 July 2006 Extensible Applications with Zope 3 30 Loading the Extensions # load pkg_resources, which is part of setuptools import pkg_resources... def loadExtensions(): """Load the extensions using the currency.register entry point.""" # iterate over available implementations for e in pkg_resources.iter_entry_points( 'currency.register'): # load the entry point register = e.load() # call the registration function register()

27 July 2006 Extensible Applications with Zope 3 31 Component-Based Results Debugging is different  Cohesive components = shallower bugs  “Over-reaching” components = break out pdb Our “application” is less than 10% of the total code – in other words, 90% of code can be shared between customized applications Developers can easily extend the system  New storage providers  Extensions (i.e., Bit Torrent, blog pinging, etc)

27 July 2006 Extensible Applications with Zope 3 32 Thanks Questions? OSCON2006