SlideShare a Scribd company logo
1 of 15
Download to read offline
Einleitung                             Binding                   Konfiguration   Plugins




             Python Enterprise Application Toolkit (PEAK)
                                               Eine kurze Einführung


                                                   Roland Gude


                                                 5. Februar 2007




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration   Plugins




Gliederung


       Einleitung


       Binding


       Konfiguration


       Plugins




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration      Plugins




PEAK im Überblick


               Framework für Komponentenbasiertes Softwaredesign
               Inversion-Of-Control Pattern
               Domain-Model Pattern
               Event basierte Programmierung
               Naming
               ...




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration   Plugins




Das binding Modul




               Inversion-Of-Control Pattern
               kopplung von Komponenten
               auffinden von Komponenten




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding     Konfiguration   Plugins




Das binding Modul
Beispiel


        from peak . a p i import ∗
    1
        class Spam( b i n d i n g . Component ) :
    2
            def yum ( s e l f ) :
    3
                p r i n t ’ spam ’
    4
        class Cook ( b i n d i n g . Component ) :
    5

            meal = b i n d i n g . Obtain ( ’ meal ’ )
    6
            def prepareMeal ( s e l f ) :
    7
                 s e l f . meal . yum ( )
    8
        class HungryGuy ( b i n d i n g . Component ) :
    9
            cook = b i n d i n g . Obtain ( ’ cook ’ )
   10
            def buyMeal ( s e l f ) :
   11
                 s e l f . cook . prepareMeal ( )
   12




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding         Konfiguration   Plugins




Das binding Modul
Fortsetzung Beispiel


        from b i n d i n g 1 import ∗
    1

        class R e s t a u r a n t ( b i n d i n g . Component ) :
    2
            meal = b i n d i n g . Make (Spam)
    3

            cook = b i n d i n g . Make ( Cook )
    4

            customer = b i n d i n g . Make ( HungryGuy )
    5
            def open ( s e l f ) :
    6
                   s e l f . customer . buyMeal ( )
    7

    8
        r e s t a u r a n t = Restaurant ( )
    9
        r e s t a u r a n t . open ( )
   10

        #>>> ’ spam ’
   11




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding    Konfiguration   Plugins




Das config Modul




               Konfiguration von Komponente
               .ini artige konfigurationsdateien
               ausführbar




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding             Konfiguration               Plugins




Das config Modul
Beispiel




        # ! / u s r / b i n / env peak r u n I n i
    1
    2
        [ peak . r u n n i n g ]
    3

        app = i m p o r t S t r i n g ( ’ c o n f i g u r a b l e . BigComputer ’ )
    4
    5
        [ what . i s ]
    6
        theAnswer = 42
    7




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding             Konfiguration                      Plugins




Das config Modul
Beispiel



        from peak . a p i import ∗
    1
    2

        class BigComputer ( commands . AbstractCommand ) :
    3
            answer = b i n d i n g . Obtain (
    4
                       PropertyName ( ’ what . i s . theAnswer ’ ) )
    5

            def _run ( s e l f ) :
    6
                p r i n t >> s e l f . s t d o u t , ’ Die A n t w o r t l a u t e t : ’ ,
    7

                                                              s e l f . answer
    8


        peak runInI config
        »» Die Antwort lautet: 42


Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration   Plugins




Plugins mit PEAK




       Eggs sind:
               vergleichbar mit JARs
               advertisable / discoverable




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration   Plugins




Plugins mit PEAK
Files




               spam
                       spam_plugin
                               __init__.py
                               spam.py
                       setup.py




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding              Konfiguration   Plugins




Plugins mit PEAK
spam_plugin.py




                                         Listing 1: spam_plugin.py
        p r i n t ’Spam l o a d i n g ! ’
    1

    2
        class Spam :
    3

    4
                def spam ( s e l f ) :
    5
                    r e t u r n ’ spam ’
    6




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding                    Konfiguration   Plugins




Plugins mit PEAK
setup.py

                                                 Listing 2: setup.py
        from s e t u p t o o l s import setup , find_packages
    1

    2
        setup (
    3
            name= quot;Spamquot; ,
    4
            v e r s i o n = quot; 0 . 1 rc7−dev9 quot; ,
    5
            d e s c r i p t i o n = quot; quot; quot;Spam p l u g i n quot; quot; quot; ,
    6
            a u t h o r = quot; Roland Gude quot; ,
    7
            packages = [ ’ spam_plugin ’ ] ,
    8
            entry_points=quot; quot; quot;
    9
            [ entry . point ]
   10
            spam = spam_plugin . spam : Spam
   11
            quot;quot;quot;)
   12



Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding   Konfiguration   Plugins




Plugins mit PEAK
build and install




       $ cd spam
       $ python setup.py bdist_egg
       $ sudo easy_install dist/Spam-0.1rc7-dev9-py2.4.egg




Roland Gude
Python Enterprise Application Toolkit (PEAK)
Einleitung                             Binding               Konfiguration          Plugins




Plugins mit PEAK
plugins benutzen



                                         Listing 3: load_plugins.py
        import pkg_resources
    1
    2
        f o r e i n pkg_resources . i t e r _ e n t r y _ p o i n t s (
    3
                                                           quot; entry . point quot; ) :
    4
              plugin_class = e . load ( )
    5
              p r i n t e . name , p l u g i n _ c l a s s
    6


        $ python load_plugins.py
        Spam loading!
        spam spam_plugin.spam:Spam


Roland Gude
Python Enterprise Application Toolkit (PEAK)

More Related Content

Similar to Python Enterprise Apllication Toolkit (PEAK) - Eine kurze Einführung

Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperr
Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperrOracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperr
Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperrGunther Pippèrr
 
9 Tipps für die Modernisierung von PHP-Anwendungen
9 Tipps für die Modernisierung von PHP-Anwendungen9 Tipps für die Modernisierung von PHP-Anwendungen
9 Tipps für die Modernisierung von PHP-AnwendungenRalf Eggert
 
Perl6: Interfaces und Factories für Testdriven Development
Perl6: Interfaces und Factories für Testdriven DevelopmentPerl6: Interfaces und Factories für Testdriven Development
Perl6: Interfaces und Factories für Testdriven DevelopmentRalf Peine
 
Django nutshell overview
Django nutshell overviewDjango nutshell overview
Django nutshell overviewschacki
 
C++ Dependency Management 2.0
C++ Dependency Management 2.0C++ Dependency Management 2.0
C++ Dependency Management 2.0Patrick Charrier
 
Automatisierung von Windows-Anwendungen
Automatisierung von Windows-AnwendungenAutomatisierung von Windows-Anwendungen
Automatisierung von Windows-AnwendungenAndreas Schreiber
 
20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatengeKarin Patenge
 
Java und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenJava und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenAndreas Schreiber
 
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...LeanIX GmbH
 
Ionic 2 - Hybridapps auf Steroiden
Ionic 2 - Hybridapps auf SteroidenIonic 2 - Hybridapps auf Steroiden
Ionic 2 - Hybridapps auf SteroidenHendrik Lösch
 
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang BarthNagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang BarthNETWAYS
 
Von Maven zu Gradle in 45 Minuten
Von Maven zu Gradle in 45 MinutenVon Maven zu Gradle in 45 Minuten
Von Maven zu Gradle in 45 MinutenQAware GmbH
 
Python in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtPython in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtAndreas Schreiber
 
Abläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisierenAbläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisierenChristian Münch
 
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...gedoplan
 
Opensource Tools für das Data Center Management
Opensource Tools für das Data Center ManagementOpensource Tools für das Data Center Management
Opensource Tools für das Data Center Managementinovex GmbH
 

Similar to Python Enterprise Apllication Toolkit (PEAK) - Eine kurze Einführung (20)

Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperr
Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperrOracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperr
Oracle oem 12c_plugin_development-doag-konferenz_11_2014_print_gunther_pipperr
 
Programmieren mit Go
Programmieren mit GoProgrammieren mit Go
Programmieren mit Go
 
9 Tipps für die Modernisierung von PHP-Anwendungen
9 Tipps für die Modernisierung von PHP-Anwendungen9 Tipps für die Modernisierung von PHP-Anwendungen
9 Tipps für die Modernisierung von PHP-Anwendungen
 
Perl6: Interfaces und Factories für Testdriven Development
Perl6: Interfaces und Factories für Testdriven DevelopmentPerl6: Interfaces und Factories für Testdriven Development
Perl6: Interfaces und Factories für Testdriven Development
 
Django nutshell overview
Django nutshell overviewDjango nutshell overview
Django nutshell overview
 
C++ Dependency Management 2.0
C++ Dependency Management 2.0C++ Dependency Management 2.0
C++ Dependency Management 2.0
 
Web-Services mit Go
Web-Services mit GoWeb-Services mit Go
Web-Services mit Go
 
Automatisierung von Windows-Anwendungen
Automatisierung von Windows-AnwendungenAutomatisierung von Windows-Anwendungen
Automatisierung von Windows-Anwendungen
 
20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge20160229_ModernApplicationDevelopment_Python_KPatenge
20160229_ModernApplicationDevelopment_Python_KPatenge
 
Java und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenJava und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzen
 
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...
CodeTalks Vortrag: Automatisierung mit Ansible & Jenkins @ LeanIX Enterprise ...
 
Ionic 2 - Hybridapps auf Steroiden
Ionic 2 - Hybridapps auf SteroidenIonic 2 - Hybridapps auf Steroiden
Ionic 2 - Hybridapps auf Steroiden
 
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang BarthNagios Conference 2007 |  Pluginprogrammierung in Perl by Wolfgang Barth
Nagios Conference 2007 | Pluginprogrammierung in Perl by Wolfgang Barth
 
Symfony2
Symfony2Symfony2
Symfony2
 
Von Maven zu Gradle in 45 Minuten
Von Maven zu Gradle in 45 MinutenVon Maven zu Gradle in 45 Minuten
Von Maven zu Gradle in 45 Minuten
 
Python in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtPython in der Luft- und Raumfahrt
Python in der Luft- und Raumfahrt
 
Abläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisierenAbläufe mit PHP und Phing automatisieren
Abläufe mit PHP und Phing automatisieren
 
Logging und Debugging in Oracle Forms
Logging und Debugging in Oracle FormsLogging und Debugging in Oracle Forms
Logging und Debugging in Oracle Forms
 
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
 
Opensource Tools für das Data Center Management
Opensource Tools für das Data Center ManagementOpensource Tools für das Data Center Management
Opensource Tools für das Data Center Management
 

Python Enterprise Apllication Toolkit (PEAK) - Eine kurze Einführung

  • 1. Einleitung Binding Konfiguration Plugins Python Enterprise Application Toolkit (PEAK) Eine kurze Einführung Roland Gude 5. Februar 2007 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 2. Einleitung Binding Konfiguration Plugins Gliederung Einleitung Binding Konfiguration Plugins Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 3. Einleitung Binding Konfiguration Plugins PEAK im Überblick Framework für Komponentenbasiertes Softwaredesign Inversion-Of-Control Pattern Domain-Model Pattern Event basierte Programmierung Naming ... Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 4. Einleitung Binding Konfiguration Plugins Das binding Modul Inversion-Of-Control Pattern kopplung von Komponenten auffinden von Komponenten Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 5. Einleitung Binding Konfiguration Plugins Das binding Modul Beispiel from peak . a p i import ∗ 1 class Spam( b i n d i n g . Component ) : 2 def yum ( s e l f ) : 3 p r i n t ’ spam ’ 4 class Cook ( b i n d i n g . Component ) : 5 meal = b i n d i n g . Obtain ( ’ meal ’ ) 6 def prepareMeal ( s e l f ) : 7 s e l f . meal . yum ( ) 8 class HungryGuy ( b i n d i n g . Component ) : 9 cook = b i n d i n g . Obtain ( ’ cook ’ ) 10 def buyMeal ( s e l f ) : 11 s e l f . cook . prepareMeal ( ) 12 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 6. Einleitung Binding Konfiguration Plugins Das binding Modul Fortsetzung Beispiel from b i n d i n g 1 import ∗ 1 class R e s t a u r a n t ( b i n d i n g . Component ) : 2 meal = b i n d i n g . Make (Spam) 3 cook = b i n d i n g . Make ( Cook ) 4 customer = b i n d i n g . Make ( HungryGuy ) 5 def open ( s e l f ) : 6 s e l f . customer . buyMeal ( ) 7 8 r e s t a u r a n t = Restaurant ( ) 9 r e s t a u r a n t . open ( ) 10 #>>> ’ spam ’ 11 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 7. Einleitung Binding Konfiguration Plugins Das config Modul Konfiguration von Komponente .ini artige konfigurationsdateien ausführbar Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 8. Einleitung Binding Konfiguration Plugins Das config Modul Beispiel # ! / u s r / b i n / env peak r u n I n i 1 2 [ peak . r u n n i n g ] 3 app = i m p o r t S t r i n g ( ’ c o n f i g u r a b l e . BigComputer ’ ) 4 5 [ what . i s ] 6 theAnswer = 42 7 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 9. Einleitung Binding Konfiguration Plugins Das config Modul Beispiel from peak . a p i import ∗ 1 2 class BigComputer ( commands . AbstractCommand ) : 3 answer = b i n d i n g . Obtain ( 4 PropertyName ( ’ what . i s . theAnswer ’ ) ) 5 def _run ( s e l f ) : 6 p r i n t >> s e l f . s t d o u t , ’ Die A n t w o r t l a u t e t : ’ , 7 s e l f . answer 8 peak runInI config »» Die Antwort lautet: 42 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 10. Einleitung Binding Konfiguration Plugins Plugins mit PEAK Eggs sind: vergleichbar mit JARs advertisable / discoverable Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 11. Einleitung Binding Konfiguration Plugins Plugins mit PEAK Files spam spam_plugin __init__.py spam.py setup.py Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 12. Einleitung Binding Konfiguration Plugins Plugins mit PEAK spam_plugin.py Listing 1: spam_plugin.py p r i n t ’Spam l o a d i n g ! ’ 1 2 class Spam : 3 4 def spam ( s e l f ) : 5 r e t u r n ’ spam ’ 6 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 13. Einleitung Binding Konfiguration Plugins Plugins mit PEAK setup.py Listing 2: setup.py from s e t u p t o o l s import setup , find_packages 1 2 setup ( 3 name= quot;Spamquot; , 4 v e r s i o n = quot; 0 . 1 rc7−dev9 quot; , 5 d e s c r i p t i o n = quot; quot; quot;Spam p l u g i n quot; quot; quot; , 6 a u t h o r = quot; Roland Gude quot; , 7 packages = [ ’ spam_plugin ’ ] , 8 entry_points=quot; quot; quot; 9 [ entry . point ] 10 spam = spam_plugin . spam : Spam 11 quot;quot;quot;) 12 Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 14. Einleitung Binding Konfiguration Plugins Plugins mit PEAK build and install $ cd spam $ python setup.py bdist_egg $ sudo easy_install dist/Spam-0.1rc7-dev9-py2.4.egg Roland Gude Python Enterprise Application Toolkit (PEAK)
  • 15. Einleitung Binding Konfiguration Plugins Plugins mit PEAK plugins benutzen Listing 3: load_plugins.py import pkg_resources 1 2 f o r e i n pkg_resources . i t e r _ e n t r y _ p o i n t s ( 3 quot; entry . point quot; ) : 4 plugin_class = e . load ( ) 5 p r i n t e . name , p l u g i n _ c l a s s 6 $ python load_plugins.py Spam loading! spam spam_plugin.spam:Spam Roland Gude Python Enterprise Application Toolkit (PEAK)