O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spring Python 1.1

Book Description

Create powerful and versatile Spring Python applications using pragmatic libraries and useful abstractions

  • Maximize the use of Spring features in Python and develop impressive Spring Python applications

  • Explore the versatility of Spring Python by integrating it with frameworks, libraries, and tools

  • Discover the non-intrusive Spring way of wiring together Python components

  • Packed with hands-on-examples, case studies, and clear explanations for better understanding

  • In Detail

    Spring Python captures the concepts of the Spring Framework and Spring Security and brings them to the world of Python and provides many functional parts to assemble applications. Spring Python is all about using the many useful features of Spring to the fullest and making these features available when working with Python.

    Get to grips with all of the concepts of Spring and apply these to the language and environment of Python to develop powerful applications for your own personal requirements. The book provides an introduction to Spring Python and steadily takes you towards the advanced features that this integration has to offer.

    Spring uses the Java programming language. Spring Python, the first Spring extension to go live, allows developers to make maximum use of Spring features in Python. This book starts off by introducing each of the core building blocks of Spring Python using real code examples and high-level diagrams. It explores the various concepts of Spring Python with the help of examples and case studies and focuses on vital Spring Python features to make the lives of Python and Java developers simple. The early chapters cover simple applications with simple operations including data access, and then subsequent chapters scale up to multi-node, secured, transactional applications stopping short of very advanced level complexity.

    This book will help you to scale your applications without having to add unnecessary complexity

    Table of Contents

    1. Spring Python 1.1
      1. Table of Contents
      2. Spring Python 1.1
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Getting Started with Spring Python
        1. Spring Python for Python developers
          1. Exploring Spring Python's non-invasive nature
          2. Adding in some useful templates
        2. Spring Python for Java developers
        3. Extending Spring Python
        4. Installing Spring Python
          1. Setting up an environment for Spring Python
          2. Installing from a pre-built binary download
          3. Installing from source
        5. Spring Python community
        6. Summary
      8. 2. The Heart of Spring Python—Inversion of Control
        1. Swapping production code with test doubles
          1. More about Inversion of Control
          2. Adding Inversion of Control to our application
          3. Dependency Injection a.k.a. the Hollywood principle
          4. Adding Inversion of Control to our test
        2. Container versus Context
          1. Lazy objects
          2. Scoped objects
          3. Property driven objects
          4. Post processor objects
          5. Context aware objects
        3. Debate about IoC in dynamic languages
        4. Migrating a Spring Java application to Python
        5. Summary
      9. 3. Adding Services to APIs
        1. AOP from 10,000 feet
          1. Crosscutting versus hierarchical
          2. Crosscutting elements
          3. Weaving crosscutting behavior
        2. Adding caching to Spring Python objects
          1. Applying many advisors to a service
          2. Performance cost of AOP
        3. AOP is a paradigm, not a library
          1. Distinct features of Spring Python's AOP module
          2. The risks of AOP
          3. AOP is part of the Spring triangle
        4. Testing our aspects
          1. Decoupling the service from the advice
            1. Testing our service
            2. Confirming that our service is correctly woven into the API
        5. Summary
      10. 4. Easily Writing SQL Queries with Spring Python
        1. The classic SQL issue
          1. Parameterizing the code
          2. Replacing multiple lines of query code with one line of Spring Python
        2. The Spring triangle—Portable Service Abstractions
        3. Using DatabaseTemplate to retrieve objects
          1. Mapping queries by convention over configuration
          2. Mapping queries into dictionaries
        4. DatabaseTemplate and ORMs
          1. Solutions provided by DatabaseTemplate
          2. How DatabaseTemplate and ORMs can work together
        5. Testing our data access layer with mocks
        6. How much testing is enough?
        7. Summary
      11. 5. Adding Integrity to your Data Access with Transactions
        1. Classic transaction issues
          1. Creating a banking application
          2. Transactions and their properties
          3. Getting transactions right is hard
        2. Simplify by using @transactional
          1. More about TransactionTemplate
          2. The Spring Triangle—Portable Service Abstractions
          3. Programmatic transactions
            1. Configuring with the IoC container
              1. Configuring without the IoC container
              2. @transactional versus programmatic
            2. Making new functions play nice with existing transactions
              1. How Spring Python lets us define a transaction's ACID properties
            3. Applying transactions to non-transactional code
            4. Testing your transactions
        3. Summary
      12. 6. Securing your Application with Spring Python
        1. Problems with coding security by hand
        2. Building web applications ignoring security
          1. Looking at our web application from 10,000 feet
        3. Handling new security requirements
          1. Authentication confirms "who you are"
          2. Authorization confirms "what you can do"
        4. Time to add security to our application
        5. Accessing security data from within the app
        6. Testing application security
        7. Configuring SQL-based security
        8. Configuring LDAP-based security
        9. Using multiple security providers is easy
          1. Migrating from an old security solution to a new one
          2. Supporting multiple user communities
          3. Providing redundant security access
        10. Coding our own security extension
          1. Coding a custom authentication provider
        11. Some of the challenges with Spring Python Security
        12. Summary
      13. 7. Scaling your Application Across Nodes with Spring Python's Remoting
        1. Introduction to Pyro (Python Remote Objects)
        2. Converting a simple application into a distributed one on the same machine
          1. Fetching the service from an IoC container
          2. Creating a client to call the service
          3. Making our application distributed without changing the client
          4. Is our example contrived?
          5. Spring Python is non-invasive
        3. Scaling our application
          1. Converting the single-node backend into multiple instances
          2. Creating a round-robin dispatcher
          3. Adjusting client configuration without client code knowing its talking to multiple node backend
        4. Summary
      14. 8. Case Study I—Integrating Spring Python with your Web Application
        1. Requirements for a good bank
        2. Building a skeleton web application
        3. Securing the application
        4. Building some basic customer functions
        5. Coding more features
          1. Updating the main page with more features
          2. Refining the ability to open an account
          3. Adding the ability to close an account
          4. Adding the ability to withdraw money
          5. Adding the ability to deposit money
          6. Adding the ability to transfer money
          7. Showing account history
        6. Issues with customer features
          1. Securing Alice's accounts
          2. Adding overdraft protection to withdrawals
          3. Making transfers transactional
        7. Remotely accessing logs
        8. Creating audit logs
        9. Summary
      15. 9. Creating Skeleton Apps with Coily
        1. Plugin approach of Coily
          1. Key functions of coily
        2. Required parts of a plugin
        3. Creating a skeleton CherryPy app
        4. Summary
      16. 10. Case Study II—Integrating Spring Python with your Java Application
        1. Building a flight reservation system
          1. Building a web app the fastest way
          2. Looking up existing flights
          3. Moving from sample Python data to real Java data
        2. Issues with wrapping Java code
        3. Summary
      17. Index