Book Image

Spring Python 1.1

By : Greg L. Turnquist
Book Image

Spring Python 1.1

By: Greg L. Turnquist

Overview of this book

<p>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.<br /><br />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.<br /><br />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.</p>
Table of Contents (16 chapters)
Spring Python 1.1
Credits
About the Author
About the Reviewers
Preface
Index

Preface

Back in 2004, a new revolution was brewing in the Java industry: the Spring Framework. It challenged the concept of monolithic, one-size-fits-all application servers by offering pragmatic solutions without heavy handed requirements. Contrary to previous frameworks, Spring did not require all-or-nothing adoption. Instead, it offered a practical approach by providing convenient abstractions over commonly used patterns. It also embraced the concept of dependency injection, allowing non-intrusive adoption of powerful options.

The Spring Framework doesn't hinge on the technology that it is coded in. The concepts and methods, known as the Spring way, work anywhere. In 2006, I created the Spring Python project. This was to combine the non-intrusive, powerful concepts of Spring with the nimble, dynamic flexibility of Python.

This book will guide you through the building blocks of Spring Python with the aim of giving you the key to build better Python applications.

The first seven chapters show you how to download and get started with Spring Python. Each of these chapters introduces a different module you can use to build applications with. The eighth chapter shows how to use the modules in concert to build a more powerful yet easier to maintain application. The ninth chapter introduces a command-line utility used to rapidly create applications. The final chapter shows how to integrate Python and Java together, quickly and easily.

I have written this book with the intention that developers can discover the scope and beauty of the Spring way and how it can enrich development, without complicating it. I often look at software development as more craftsmanship than science, and believe Spring Python can make for a valuable tool in any developer's tool box.

What this book covers

Chapter 1: Getting Started with Spring Python gives you a quick glance at various features of Spring Python, followed by information on how to download and install it.

Chapter 2: The Heart of Spring Python—Inversion of Control introduces you to Spring Python's core container which is reused through the rest of the book to empower testing and non-intrusive features.

Chapter 3: Adding Services to APIs shows how to smoothly add cross cutting services to your code using Spring Python's aspect oriented programming.

Chapter 4: Easily Writing SQL Queries with Spring Python shows you how to rapidly write pure SQL queries without dealing with mind-numbing boilerplate code. It also shows how Spring Python works nicely with ORM-based persistence.

Chapter 5: Adding Integrity to your Data Access with Transactions shows how to seamlessly wrap business code with SQL transactions.

Chapter 6: Securing your Application with Spring Python shows how to wrap web applications with flexible authentication and authorization services, while easily supporting policy changes. It also shows how to code custom extensions to integrate with security systems not currently supported.

Chapter 7: Scaling your Application Across Nodes with Spring Python's Remoting shows how Spring Python nicely integrates with Pyro, the RPC library for Python. This powerful combination will allow you to non-intrusively develop simple apps on your desktop and retool them for multi-node production systems

Chapter 8: Case Study I—Integrating Spring Python with your Web Application invites you to use all of Spring Python's components to build a strong, secured banking application. This shows how the various parts of Spring Python work together in concert to empower you the developer.

Chapter 9: Creating Skeleton Apps with Coily introduces Spring Python's plugin-based Coily tool to rapidly create web applications.

Chapter 10: Case Study II – Integration Spring Python with your Java Application ends the book by showing how easy it is to link Java and Python components together using Jython. This allows polyglot programmers to mix together their favorite services.

What you need for this book

You will need Python 2.4 or above and Spring Python 1.1.0.FINAL (covered in Chapter 1).

Who this book is for

This book is for Python developers who want to take their applications to the next level, by adding/using parts that scale their application up, without adding unnecessary complexity. It is also helpful for Java developers who want to mix in some Python to speed up their coding effort.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We added closeAccount to SpringBankView to let the customer close an existing account it its balance is zero."

A block of code is set as follows:

def get_article(self, article):
    if article in self.cache:
        return self.cache[article]
        else:
        return self.delegate.get_article(article)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

def get_article(self, article):
    if article in self.cache:
        return self.cache[article]
        else:
        return self.delegate.get_article(article)

Any command-line input or output is written as follows:

$ svn checkout https://src.springframework.org/svn/se-springpython-py/trunk/springpython springpython

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Let's look at the layout of the gen-cherrypy-app plugin as an example."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for the book

Visit https://www.packtpub.com//sites/default/files/downloads/0660_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.