Project

General

Profile

Wiki » History » Version 19

Version 18 (Elmer de Looff, 2012-11-08 14:23) → Version 19/20 (Elmer de Looff, 2012-11-08 14:52)

h1. µWeb

!>uweb_inernals.png!

µWeb is a Python software package designed to provide a flexible, lightweight, but powerful base to build web applications on top of. It can tie in to mod_python for Apache, or run stand-alone, using Python's included @BaseHTTPServer@ package.

µWeb provides an "MVP":http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter like environment, built around three core philosophies:
# as little "boilerplate":http://en.wikipedia.org/wiki/Boilerplate_code as possible;
# as little Magic™ as possible;
# and separation by convention, not brute force.

These philisophies overlap more than a little with the "Zen of Python":http://www.python.org/dev/peps/pep-0020/#content, which is not a coincidence.



h2. Installation

Details on how to install µWeb can be found on the [[installation]] page.

h2. Management

Initializing new projects, starting and stopping development servers and creating your Apache configurations can all be done with the [[Application|µWeb management application]].

h2. Components

µWeb is a framework that consists of mix of components building from a low-level standalone server on top of @BaseHTTPServer@ to a refined template parser and database abstraction model.

h3. Request Router

The *[[Request Router]]* is the entry point of the µWeb framework. Any HTTP request seen by the server is passed through here, from which it is delegated to the proper handler.

h3. PageMaker and Response (_Presenter_)

*[[PageMaker]]* provides the presenter part of the MVP approach. Each web request ends on a specific method of the PageMaker. From here, request information can be viewed (cookies, query arguments and POST data), and databases used to gather data to fulfill the request. Upon completion, a raw string or a more complex *[[Response]]* object may be returned.

h3. TemplateParser (_View_)

Templates allow for a separation of presentation and logic, allowing you to move large parts of HTML or other output to a separate file. The *[[TemplateParser]]* replaces all the tags left in the template with the given output, which can be simple variables, or the use of multi-level database objects. Also, as an added benefit, the default output of TemplateParser is such that any text fed into the template, is automatically made safe for HTML output.

h3. Database abstraction (_Model_)

The *[[Model|µWeb database model]]* provides a Record class which provides for a smart interaction with your database tables. Creating a simple Record subclass for each of your (main) database tables allows you:
* to load database record by their primary key value;
* automatic retrieval of 1-1 or n-1 relations;
* creating, updating or deleting of records.

h3. HTTP Request abstraction

The *[[Request]]* class ensures that, no matter the server that accepts the request (Apache or BaseHTTPServer), the various parts further on in the framework have access to header information, query arguments, cookies and POST data in a structured manner. More information on the client, server and other environment variables is also available here.

h3. µWeb Standalone Server

*[[Standalone]]* is a module that allows µWeb to function outside the presence of Apache and mod_python. This is easy for local testing, or low volume websites.

h3. Common errors when building uweb projects

[[FAQ|As with any software package, some things tend to go awry for most new users, so we've made a list of them, and their solution.]]