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

Building web applications ignoring security


We need a simple application. For this example, we will use CherryPy (http://cherrypy.org), a pythonic web framework that conveniently maps URLs into Python methods.

Note

If you want to know more about the CherryPy framework, I highly recommend reading CherryPy Essentials by Sylvain Hellegouarch.

After building our web application, we will review some of the options people take in securing things. Then, we will plug in Spring Python Security, showing how easy it is to lock down an application.

First, let's build a simple web application that serves wiki pages, and allows us to edit them.

import cherrypy

def forward(url):
    return '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' + url + '">'

class Springwiki(object):
    def __init__(self, controller = None):
        self.controller = controller

    @cherrypy.expose
    def index(self, article="Main Page"):
        page = self.controller.getPage(article)
        return page.html()

    @cherrypy...