Web to py enterprise web framework - p 4 pot

10 396 0
Web to py enterprise web framework - p 4 pot

Đang tải... (xem toàn văn)

Thông tin tài liệu

ACKNOWLEDGMENTS 15 1.9 Acknowledgments web2py was originally developedby andcopyrighted by Massimo Di Pierro. The first version (1.0) was released in October, 2007. Since then it has been adopted by many users, some of whom have also contributed bug reports, testing, debugging, patches, and proofreading of this book. Some of the major contributors are, in alphabetical order by first name: Alexandre Andrade, Alexey Nezhdanov(GAE and database performance), Alvaro Justen (dynamical translations), Andre Berthiaume, Andre Bossard, Attila Csipa (cron job), Bill Ferrett (modular DAL design), Boris Manojlovic (Ajax edit), Carsten Haese (Informix), Chris Baron, Christopher Smiga (In- formix), Clifford John Lazell (tester and JS), David H. Lee (OpenID), Denes Lengyel (validators, DB2 support), Douglas Soares de Andrade (2.4 and 2.6 compliance, docstrings), Felipe Barousse, Fran Boon (authorization and au- thentication), Francisco Gama (bug fixing), Fred Yankowski (XHTML com- pliance), Gabriele Carrettoni, Graham Dumpleton, Gregor Jovanovich, Hans Christian v. Stockhausen (OpenID), Hans Donner (GAE support, Google login, widgets, Sphinx documentation), Ivan Valev, Joe Barnhart, Jonathan Benn (validators and tests), Jonathan Lundell, Jose Jachuf (Firebird sup- port), Kacper Krupa, Kyle Smith (JavaScript), Limodou (winservice), Lucas Geiger,Marcel Leuthi (Oracle support), Mark Larsen (taskbar widget), Mark Moore (databases and daemon scripts), Markus Gritsch (bug fixing), Martin Hufsky (expressions in DAL), Mateusz Banach (stickers, validators, content- type), Michael Willis (shell), Milan Andric, Minor Gordon, Nathan Freeze (admin design, validators), Niall Sweeny (MSSQL support), Niccolo Polo (epydoc), Nicolas Bruxer (memcache support), Ondrej Such (MSSQL sup- port), Pai (internationalization), Phyo Arkar Lwin (web hosting and Jython tester), Ricardo Cardenes, Richard Gordon, Richard Baron Penman, Robin Bhattacharyya (Google App Engine support), Roman Goldmann, Ruijun Luo (windows binary), Scott Santarromana, Sergey Podlesnyi (Oracle and migra- tions tester), Shane McChesney, Sharriff Aina (tester and PyAMF integra- tion), Sterling Hankins (tester), Stuart Rackham (MSSQL support), Telman Yusupov (Oracle support), Tim Farrell, Tim Michelsen (Sphinx documen- tation), Timothy Farrell (Python 2.6 compliance, windows support), Tito Garrido, Yair Eshel (internationalizaiton), Yarko Tymciurak (design, Sphinx documentation), Ygao, Younghyun Jo (internationalization), Zoom Quiet I am sure I forgot somebody, so I apologize. I particularly thank Alvaro, Denes, Felipe, Graham, Jonathan, Hans, Kyle, Mark, Richard, Robin, Roman, Scott, Shane, Sharriff, Sterling, Stuart and Yarko for proofreading various chapters of this book. Their contribution was invaluable. If you find any errors in this book, they are exclusively my fault, 16 INTRODUCTION probably introduced by a last-minute edit. I also thank Ryan Steffen of Wiley Custom Learning Solutions for help with publishing the first edition of this book. web2py contains code from the following authors, whom I would like to thank: Guido van Rossum for Python [2], Peter Hunt, Richard Gordon, Robert BrewerfortheCherryPy[21] web server,ChristopherDolivet forEditArea [22], Brian Kirchoff for nicEdit [23], Bob Ippolito for simplejson [24], Simon Cusack and Grant Edwards for pyRTF [25], Dalke Scientific Software for pyRSS2Gen [26], Mark Pilgrim for feedparser [27], Trent Mick for mark- down2 [28], Allan Saddi for fcgi.py, Evan Martin for the Python memcache module [29], John Resig for jQuery [31]. The logo used on the cover of this book was designed by Peter Kirchner at Young Designers. I thank Helmut Epp (provost of DePaul University), David Miller (Dean of the College of Computing and Digital Media of DePaul University), and Estia Eichten (Member of MetaCryption LLC), for their continuous trust and support. Finally,I wish tothank my wife,Claudia, and my son,Marco, for putting up with me during the manyhours I have spent developing web2py, exchanging emails with users and collaborators, and writing this book. This book is dedicated to them. 1.10 About this Book This book includes the following chapters, besides this introduction: • Chapter 2 is a minimalist introduction to Python. It assumes knowl- edge of both procedural and object-oriented programming concepts such as loops, conditions, function calls and classes, and covers basic Python syntax. It also covers examples of Python modules that are used throughout the book. If you already know Python, you may skip Chapter 2. • Chapter 3 shows how to start web2py, discusses the administrative interface, and guides the reader through various examples of increasing complexity: an application that returns a string, a counter application, an image blog, and a full blown wiki application that allows image uploads and comments, provides authentication, authorization, web services and an RSS feed. While reading this chapter, you may need ABOUT THIS BOOK 17 to refer to Chapter 2 for general Python syntax and to the following chapters for a more detailed reference about the functions that are used. • Chapter 4 covers more systematically the core structure and libraries: URL mapping, request, response, sessions, cacheint, CRON, interna- tionalization and general workflow. • Chapter 5 is a reference for the template language used to build views. It shows how to embed Python code into HTML, and demonstrates the use of helpers (objects that can generate HTML). • Chapter 6 covers the Database Abstraction Layer, or DAL. The syntax of the DAL is presented through a series of examples. • Chapter 7 covers forms, form validation and form processing. FORM is the low level helper for form building. SQLFORM is the high level form builder. In Chapter 7 we also discuss the new Create/Read/Up- date/Delete (CRUD) API. • Chapter 8 covers authentication, authorization and the extensible Role- Based Access Control mechanism available in web2py. Mail config- uration and CAPTCHA are also discussed here, since they are used by authentication. • Chapter 9 is about creating web services in web2py. We provide examples of integration with the Google Web Toolkit via Pyjamas, and with Adobe Flash via PyAMF. • Chapter 10 is about web2py and jQuery recipes. web2py is designed mainly for server-side programming, but it includes jQuery, since we have found it to be the best open-source JavaScript library available for effects and Ajax. In this chapter, we discuss how to effectively use jQuery with web2py. • Chapter 11 is about production deployment of web2py applications. We mainly address three possible production scenarios: on a Linux web server or a set of servers (which we consider the main deployment alternative), running as a service ona Microsoft Windows environment, and deployment on the Google Applications Engine (GAE). In this chapter, we also discuss security and scalability issues. • Chapter 12 contains a variety of other recipes to solve specific tasks, inlcuding upgrades, gecoding, pagination, Twitter API, and more. This book only covers basic web2py functionalities and the API that ships with web2py. This book does not cover web2py appliances, for 18 INTRODUCTION example KPAX, the web2py Content Management System. The appliance for Central Authentication Service is briefly discussed in Chapter 8. Youcandownload web2py appliancesfromthecorresponding website[33]. You can find additional topics discussed on AlterEgo [34], the interactive web2py FAQ. 1.11 Elements of Style Ref. [35] contains good style practices when programming with Python. You will find that web2py does not always follow these rules. This is not because of omissions or negligence; it is our belief that the users of web2py should follow these rules and we encourage it. We chose not to follow some of those rules when defining web2py helper objects in order to minimize the probability of name conflict with objects defined by the user. For example, the class that represents a <div> is called DIV, while according to the Python style reference it should have been called Div. We believe that, for this specific example that using an all-upper-case "DIV" is a more natural choice. Moreover, this approach leaves programmers free to create a class called "Div" if they choose to do so. Our syntax also maps naturally into the DOM notation of most browsers (including, for example, Firefox). According to the Python style guide, all-upper-case strings should be used for constants and not variables. Continuing with our example, even consid- ering that DIV is a class, it is a special class that should never be redefined by the user because doing so would break other web2py applications. Hence, we believe this qualifies the DIV class as something that should be treated as a constant, further justifying our choice of notation. In summary, the following conventions are followed: • HTML helpers and validators are all upper case for the reasons dis- cussed above (for example DIV, A, FORM, URL). • The translator object T is upper case despite the fact that it is an instance of a class and not a class itself. Logically the translator object performs an action similar to the HTML helpers — it affects rendering part of the presentation. Also, T needs to be easy to locate in the code and has to have a short name. • DAL classes follow the Python style guide (first letter capitalized), sometimes with the addition of a clarifying DAL prefix (for example Table, Field, DALQuery, etc.). ELEMENTS OF STYLE 19 In all other cases we believe we have followed, as much as possible, the Python Style Guide (PEP8). For example all instance objects are lower-case (request, response, session, cache), and all internal classes are capitalized. In all the examples of this book, web2py keywords are shown in bold, while strings and comments are shown in italic. . ' __new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__ ', '__radd__', '__rand__', '__rdiv__', '__rdivmod__',. shell prompt type: 1 python web2 py. py -S welcome If you do not have Python 2.5 already installed, you will have to download and install it before running web2 py. The -S welcome command line option. '__index__', '__init__', '__int__', '__invert__', ' __long__', '__lshift__', '__mod__', '__mul__', '__neg__', ' __new__',

Ngày đăng: 06/07/2014, 19:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan