Professional Python Frameworks Web 2.0 Programming with Django and TurboGears

Similar documents
AutoCAD & AutoCAD LT The book you need to succeed! DVD Included! Ellen Finkelstein. Start drawing today with Quick Start tutorial

PROFESSIONAL EMBEDDED ARM DEVELOPMENT

Canon EOS 7D. Learn to: IN FULL COLOR! Doug Sahlin. Making Everything Easier! Use the on-board controls, Live View, and playback mode

CREATING. Digital Animations. by Derek Breen

Nikon D3000. Digital Field Guide

Corrosion Inspection and Monitoring

Pulse-Width Modulated DC-DC Power Converters Second Edition

THE JOHN DEERE WAY. Performance That Endures. David Magee. John Wiley & Sons, Inc.

BUILDING A MINECRAFT. City by Sarah Guthals, PhD

Intellectual Capital in Enterprise Success

HIGH INTEGRITY DIE CASTING PROCESSES

ADVANCED POWER ELECTRONICS CONVERTERS

Douglas J. Cumming The Robert W. Kolb Series in Finance John Wiley & Sons, Inc.

Exploring Arduino. Tools and Techniques for Engineering Wizardry. Jeremy Blum

AIRCRAFT CONTROL AND SIMULATION

PRACTICAL RF SYSTEM DESIGN

Rebel T2i/550D. Canon EOS. Learn to: IN FULL COLOR! Julie Adair King with Dan Burkholder. Making Everything Easier!

P1: OTA/XYZ P2: ABC JWBT483-fm JWBT483-Mckinsey February 16, :11 Printer Name: Hamilton VALUATION WORKBOOK i

Fundamentals of Global Positioning System Receivers

Nikon D300s. Learn to: IN FULL COLOR! Julie Adair King. Making Everything Easier! Get the most from every menu option

About Face. Alan Cooper, Robert Reimann, and David Cronin. The Essentials of Interaction Design

Backgammon. by Chris Bray. FOR DUMmIES. A John Wiley and Sons, Ltd, Publication

Knitting. DUMmIES FOR 2ND EDITION

Tableau. by Molly Monsey and Paul Sochan

Words of Wisdom. from Women to Watch

CELLULAR TECHNOLOGIES FOR EMERGING MARKETS

Commercial Real Estate Investing

Fraud Auditing and Forensic Accounting

REFLECTARRAY ANTENNAS

RFID HANDBOOK THIRD EDITION

1 // TOPICS + CATEGORIES 6 2 // BLOG POSTS 15 3 // STATIC PAGES 28 4 // NAVIGATION MENUS 36 5 // BLOG PHOTOS 39 6 // BLOG GRAPHICS 42

Sheet Metal Design Guidelines

Health Information Technology Standards. Series Editor: Tim Benson

Sheet Metal Design Guidelines

PROCESS ANALYZER SAMPLE-CONDITIONING SYSTEM TECHNOLOGY ROBERT E. SHERMAN

HYPERSPECTRAL DATA EXPLOITATION

Control of Electric Machine Drive Systems. Seung-Ki Sul

THE POWER OF JAPANESE CANDLESTICK CHARTS

Stories By Creators PARTICIPANT HANDBOOK PETALZ.ORG

Beginning Flash Game Programming FOR. DUMmIES. by Andy Harris

System Architecture. Strategy and Product Development for Complex Systems. Global edition. Global edition. Edward Crawley Bruce Cameron Daniel Selva

HANDBOOK OF ADVANCED MATERIALS

The EDR Aerial Photo Decade Package

Sheet Metal Design Guidelines

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England. and Associated Companies throughout the world

THE FIELDS OF ELECTRONICS

S LvER P NY. Spar l i ng Jewel. by D. L. Green illustrated by Emily Wallis

Breakthroughs in Decision Science and Risk Analysis

PREDICTIVE CONTROL OF POWER CONVERTERS AND ELECTRICAL DRIVES

Appendix B: Historic Aerial Photographs

Sustainable Development

The EDR Aerial Photo Decade Package

SpringerBriefs in Space Development

Design for Innovative Value Towards a Sustainable Society

Building Arduino PLCs

Creative Lighting System

Troubleshooting Process Plant Control

Optimal Flow Measurement: Understanding Selection, Application, Installation, and Operation of Flowmeters

The Candlestick Course

Library of Congress Cataloging-in-Publication Data

Creative Lighting System

Project Management in Construction

Fiverr Cash Secrets The Proven Formula To Cashing In With Fiverr

List Building for Authors Creating a Compelling Virtual Giveaway

FUNDAMENTALS OF SIGNALS AND SYSTEMS

Postdisciplinary Studies in Discourse

The EDR Aerial Photo Decade Package

John Vance Fouad Zeidan Brian Murphy

RISK MANAGEMENT APPLICATIONS IN PHARMACEUTICAL AND BIOPHARMACEUTICAL MANUFACTURING

OpulenceForLife.com 1

RADIO-FREQUENCY AND MICROWAVE COMMUNICATION CIRCUITS

BIOMEDICAL E T H I C S REVIEWS

TRANSMISSION LINES IN DIGITAL AND ANALOG ELECTRONIC SYSTEMS

British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library.

RCRA Waste Management:

Hacking the Atom. Steven B. Krivit EXPLORATIONS IN NUCLEAR RESEARCH, VOL. 1. Edited by Michael J. Ravnitzky

REAL ESTATE INVESTING IN CANADA

Application of Evolutionary Algorithms for Multi-objective Optimization in VLSI and Embedded Systems

OBJECT-ORIENTED ANALYSIS AND DESIGN THROUGH UNIFIED MODELING LANGUAGE

VALUE THE FOUR CORNERSTONES OF CORPORATE FINANCE

Machining Design Guidelines

rumble of The coaster ghost by Troy Cummings

Your secret weapon against the Lich King s wrath

University of Huddersfield Repository

SOLDERING. Understanding the Basics. Edited by Mel Schwartz. Materials Park, Ohio

KEVIN L. MOSS 50 FAST DIGITAL CAMERA TECHNIQUES

Full Color Throughout!

Oracle Real-Time Scheduler

Small-Crack Test Methods

Palgrave Studies in the History of Science and Technology

2016 IEEE Global Humanitarian Technology Conference (GHTC 2016)

Technology Roadmapping for Strategy and Innovation

Colorized. Mustang Wiring & Vacuum Diagrams. (with Electrical Illustrations)

Esri and Autodesk What s Next?

Robotic automation goes mainstream: Accenture announces agreement with IPsoft

Failure Analysis of Paints and Coatings. Revised Edition

INSTRUMENTATION AND CONTROL SYSTEMS SECOND EDITION

The BioBrick Public Agreement. DRAFT Version 1a. January For public distribution and comment

IMPLEMENTING THE WEALTH MANAGEMENT INDEX

Writing Fiction. Learn to: Randy Ingermanson. Peter Economy. Making Everything Easier! Find your target audience. Choose your creative paradigm

Transcription:

Professional Python Frameworks Web 2.0 Programming with Django and TurboGears Dana Moore Raymond Budd William Wright Wiley Publishing, Inc.

Professional Python Frameworks Web 2.0 Programming with Django and TurboGears Acknowledgments... xiii Introduction... xxi Part I: Introduction to Python Frameworks Chapter 1: Web 2.0, Python, and Frameworks... 3 Chapter 2: Web 2.0 with Traditional Python... 19 Chapter 3: Introducing the Frameworks... 47 Part II: TurboGears Chapter 4: Introduction to TurboGears... 101 Chapter 5: User Identity and Visitor Tracking... 137 Chapter 6: Widgets... 169 Chapter 7: Advanced TurboGears Topics... 203 Part III: Django Chapter 8: Dblog: A Blog Implemented in Django... 241 Chapter 9: Django Views and Users... 275 Chapter 10: Advanced Django Topics: AJAX, RSS, and More... 305 Part IV: Advanced Client-Side Topics Chapter 11: MochiKit Pythonic JavaScripting... 337 Chapter 12: Flash-Based Interfaces and TurboGears... 359 Appendix A: Tools Used... 395 Index... 405

Professional Python Frameworks Web 2.0 Programming with Django and TurboGears

Professional Python Frameworks Web 2.0 Programming with Django and TurboGears Dana Moore Raymond Budd William Wright Wiley Publishing, Inc.

Professional Python Frameworks: Web 2.0 Programming Django and TurboGears Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright 2007 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN-13: 978-0-470-13809-0 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data Moore, Dana, 1947- Professional Python frameworks : Web 2.0 programming with Django and Turbogears / Dana Moore, Raymond Budd, William Wright. p. cm. Includes index. ISBN 978-0-470-13809-0 (pbk.) 1. Web site development. 2. Python (Computer program language) I. Budd, Raymond, 1976- II. Wright, William, 1964- III. Title. TK5105.888.M663 2007 006.7'6 dc22 2007032138 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Python is a registered trademark of Python Software Foundation. Django is a registered trademark of The World Company Corporation. TurboGears is a trademark of Kevin Dangoor. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

For Jane, who, in our 35 years of love, has encouraged in me the belief that I can reach for and attain higher goals than I could ever imagine. And for my cherished daughter Caitlin, who is for me both luminous and a conductor of light; both possessing genius and having the power to stimulate it in others. DM For Leah. You continually amaze me with your thoughtfulness, unwavering support, and above all your remarkable ability to make me laugh and smile. Also for my sisters, who have helped me out so many different times in so many different ways. RB For my two favorite girls, Karan and Annette. Your encouragement and inspiration make all things seem possible. WW

About the Authors Dana Moore is a division scientist with BBN Technologies and is an acknowledged expert in the fields of peer-to-peer and collaborative computing, software agent frameworks, and assistive environments. Prior to joining BBN, Dana was chief scientist for Roku Technologies and a distinguished member of technical staff at Bell Laboratories. Dana is a popular conference speaker and a university lecturer. He has written articles for numerous computing publications and coauthored the books Peer-to-Peer: Building Secure, Scalable, and Manageable Networks; Jabber Developer s Handbook; and Rich Internet Applications. Dana holds a Master of Science degree from the University of Maryland and a Bachelor of Science degree in industrial design, also from the University of Maryland. Raymond Budd is a software engineer with BBN Technologies. He has designed, developed, and supported a variety of web applications and other distributed systems in Java, Ruby, and Python. He has been published in several conference proceedings such as the Eighteenth National Conference on Artificial Intelligence and journals including Applied Intelligence. Additional areas of interest include knowledge representations, knowledge engineering, and distributed planning and scheduling. He received a Bachelor of Science degree in computer science from the University of Pittsburgh. William Wright is a senior principal investigator with SPARTA, where he develops networking software for systems distributed across the globe. His interests include real-time embedded systems, software architecture for reuse, and software agent frameworks. A frequent conference speaker, William has also written for Dr. Dobb s Journal, Java Developer s Journal, and Embedded Systems Programming, among others. He coauthored the books Jabber Developer s Handbook and Beginning Java Networking. William holds a Master of Science degree in computer science from George Mason University and a Bachelor of Music degree in education from Indiana University.

Acquisitions Editor Jenny Watson Development Editor Maureen Spears Production Editor Elizabeth Ginns Britten Copy Editor Kathryn Duggan Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Credits Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert Project Coordinator Adrienne Martinez Proofreader Candace English Indexer Jack Lewis Anniversary Logo Design Richard Pacifico

Acknowledgments The authors wish to thank the industry leaders who shared their thoughts with us in interviews. We thank Kevin Dangoor, creator of TurboGears, for sharing his insights on the design and development of Web 2.0 applications and the evolution of web application tools. We also appreciate the insights of Adrian Holovaty, leader of the Django project, whose thoughts on high-level languages for web applications show where we ve been and where we re going. We express our thanks to Edward Benson for his help managing the source code for this book. Thanks also to Patrick Pinkowski for his assistance with the cover photo. We are especially grateful for the efforts of Maureen Spears, our development editor at Wiley. Her combination of high standards and encouragement made the development of this book a joy. Finally, and most importantly, we thank our friends, families, and significant others for their forbearance. Writing is a solitary activity that tends to exclude others, even those most important to us, and we appreciate all their support and promise to somehow make up for the lost time and opportunities.