[Python-modules-commits] [webpy] 01/04: Import webpy_0.38.orig.tar.gz

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Jul 23 08:46:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository webpy.

commit 6382f370f5744744f0f9f4b1389113ef009494d6
Author: W. Martin Borgert <debacle at debian.org>
Date:   Sat Jul 23 10:01:23 2016 +0200

    Import webpy_0.38.orig.tar.gz
---
 .gitignore          |   2 +
 .travis.yml         |   1 -
 ChangeLog.txt       |  25 +++++
 docs/Makefile       | 177 ++++++++++++++++++++++++++++++++
 docs/api.rst        |  59 +++++++++++
 docs/conf.py        | 258 ++++++++++++++++++++++++++++++++++++++++++++++
 docs/db.rst         | 145 ++++++++++++++++++++++++++
 docs/deploying.rst  |  97 ++++++++++++++++++
 docs/index.rst      |  46 +++++++++
 docs/input.rst      |  92 +++++++++++++++++
 docs/templating.rst | 291 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/session.py     |  10 +-
 tools/makedoc.py    |   7 +-
 web/__init__.py     |   2 +-
 web/application.py  |  44 +++++++-
 web/db.py           |  73 ++++++++++---
 web/form.py         |   8 +-
 web/net.py          |  55 +++++++++-
 web/session.py      |   4 +-
 web/utils.py        |  23 ++++-
 web/webapi.py       | 143 +++++++++++++++-----------
 web/wsgi.py         |   9 +-
 22 files changed, 1475 insertions(+), 96 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d0a113f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+.DS_Store
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index acba7a1..f76de70 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
 language: python
 python:
-  - "2.5"
   - "2.6"
   - "2.7"
 #  - "3.1"
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 9358f77..05c8017 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,5 +1,30 @@
 # web.py changelog
 
+## 2016-07-08 0.38
+
+* Fixed failing tests in test/session.py when postgres is not installed. (tx Michael Diamond)
+* Fixed an error with Python 2.3 (tx Michael Diamond)
+* web.database now accepts a URL, $DATABASE_URL (fixes #171) (tx Aaron Swartz, we miss you)
+* support port use 'port' as keyword for postgres database with used eith pgdb (tx Sandesh Singh)
+* Fixes to FirebirdDB database (tx Ben Hanna)
+* Added a gaerun method to start application for google app engine (tx Matt Habel)
+* Better error message from `db.multiple_insert` when not all rows have the same keys (tx Ben Hoyt)
+* Allow custom messages for most errors (tx Shaun Sharples)
+* IPv6 support (tx Matthew of Boswell and zamabe)
+* Fixed sending email using Amazon SES (tx asldevi)
+* Fixed handling of long numbers in sqlify. closes #213. (tx cjrolo)
+* Escape HTML characters when emitting API docs. (tx Jeff Zellman)
+* Fixed an inconsistency in form.Dropdown when numbers are used for args and value. (tx Noprianto)
+* Fixed a potential remote exeution risk in `reparam` (tx Adrián Brav)
+* The where clause in db queries can be a dict now
+* Added `first` method to iterbetter
+* Fix to unexpected session when used with MySQL (tx suhashpatil)
+* Change dburl2dict to use urlparse and to support the simple case of just a database name. (tx Jeff Zellman)
+* Support '204 No Content' status code (tx Matteo Landi)
+* Support `451 Unavailable For Legal Reasons` status code(tx Yannik Robin Kettenbach)
+* Updates to documentation (tx goodrone, asldevi)
+
+
 ## 2012-06-26 0.37
 
 * Fixed datestr issue on Windows -- #155
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..c9bf88b
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,177 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/webpy.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/webpy.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/webpy"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/webpy"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/api.rst b/docs/api.rst
new file mode 100644
index 0000000..ef42b5b
--- /dev/null
+++ b/docs/api.rst
@@ -0,0 +1,59 @@
+web.py API
+==========
+
+
+web.application
+---------------
+
+.. automodule:: web.application
+    :members:
+
+web.db
+------
+
+.. automodule:: web.db
+    :members:
+
+web.net
+-------
+
+.. automodule:: web.net
+    :members:
+
+web.form
+--------
+
+.. automodule:: web.form
+    :members:
+
+web.http
+--------
+
+.. automodule:: web.http
+    :members:
+
+web.session
+-----------
+
+.. automodule:: web.session
+    :members:
+
+web.template
+------------
+
+.. automodule:: web.template
+    :members:
+
+web.utils
+---------
+
+.. automodule:: web.utils
+    :members:
+
+web.webapi
+----------
+
+.. automodule:: web.webapi
+    :members:
+
+
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..62ac2fe
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,258 @@
+# -*- coding: utf-8 -*-
+#
+# web.py documentation build configuration file, created by
+# sphinx-quickstart on Sun Oct 27 15:35:05 2013.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = ['sphinx.ext.autodoc']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'web.py'
+copyright = u''
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.37'
+# The full version, including alpha/beta/rc tags.
+release = '0.37'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'webpydoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+  ('index', 'webpy.tex', u'web.py Documentation',
+   u'Anand Chitipothu', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'webpy', u'web.py Documentation',
+     [u'Anand Chitipothu'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'webpy', u'web.py Documentation',
+   u'Anand Chitipothu', 'webpy', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
diff --git a/docs/db.rst b/docs/db.rst
new file mode 100644
index 0000000..7dd297f
--- /dev/null
+++ b/docs/db.rst
@@ -0,0 +1,145 @@
+Accessing the database
+======================
+
+Web.py provides a simple and uniform interface to the database that you want to work with, whether it is PostgreSQL, MySQL, SQLite or any other. It doesn't try to build layers between you and your database. Rather, it tries to make it easy to perform common tasks, and get out of your way when you need to do more advanced things.
+
+
+Create database object
+------------------------
+
+The first thing to work with databases from web.py is to create a
+create a database object with `web.database()`. It returns database object, which has convenient methods for you to use.
+
+Make sure that you have appropriate database library installed (`psycopg2` for PostgreSQL, `MySQLdb` for MySQL, `sqlite3` for SQLite).
+
+::
+
+    db = web.database(dbn='postgres', db='dbname', user='username', pw='password')
+
+`dbn` for MySQL is `mysql` and `sqlite` for SQLite. SQLite doesn't take `user` `pw` parameters.
+
+Multiple databases
+``````````````````
+
+Working with more databases is not at all difficult with web.py. Here's what you do.
+
+::
+
+    db1 = web.database(dbn='postgres', db='dbname1', user='username1', pw='password2')
+    db2 = web.database(dbn='postgres', db='dbname2', user='username2', pw='password2')
+
+And use `db1`, `db2` to access those databases respectively.
+
+
+Operations
+----------
+`web.database()` returns an object which provide you all the functionality to insert, select, update and delete data from your database. For each of the methods on `db` below, you can pass `_test=True` to see the SQL statement rather than executing it.
+
+
+Inserting
+`````````
+::
+
+    # Insert an entry into table 'user'
+    userid = db.insert('user', firstname="Bob", lastname="Smith", joindate=web.SQLLiteral("NOW()"))
+
+
+The first argument is the table name and the rest of them are set of named arguments which represent the fields in the table. If values are not given, the database may create default values or issue a warning.
+
+For bulk insertion rather than inserting record by record, use `Multiple Inserts` rather.
+
+Selecting
+`````````
+
+The `select` method is used for selecting rows from the database. It returns a `web.iterbetter` object, which can be looped through.
+
+To select `all` the rows from the `user` table, you would simply do
+
+::
+
+    users = db.select('user')
+
+For the real world use cases, `select` method takes `vars`, `what`, `where`, `order`, `group`, `limit`, `offset`, and `_test` optional parameters.
+
+::
+
+    users = db.select('users', where="id>100")
+
+To prevent SQL injection attacks, you can use `$key` in where clause and pass the `vars` which has { 'key': value }.
+
+::
+
+    vars = dict(name="Bob")
+    results = db.select('users', where="name = $name", vars=vars, _test=True)
+    >>> results
+    <sql: "SELECT * FROM users WHERE name = 'Bob'">
+
+
+Updating
+````````
+The `update` method accepts same kind of arguments as Select. It returns the number of rows updated.
+
+::
+
+    num_updated  = db.update('users', where="id = 10", firstname = "Foo")
+
+Deleting
+````````
+The `delete` method returns the number of rows deleted. It also accepts "using" and "vars" parameters. See ``Selecting`` for more details on `vars`.
+
+::
+
+    num_deleted = db.delete('users', where="id=10")
+
+Multiple Inserts
+````````````````
+The `multiple_insert` method on the `db` object allows you to do that. All that's needed is to prepare a list of dictionaries, one for each row to be inserted, each with the same set of keys and pass it to `multiple_insert` along with the table name. It returns the list of ids of the inserted rows.
+
+The value of `db.supports_multiple_insert` tells you if your database supports multiple inserts.
+::
+
+    values = [{"name": "foo", "email": "foo at example.com"}, {"name": "bar", "email": "bar at example.com"}]
+    db.multiple_insert('person', values=values)
+
+
+Advanced querying
+`````````````````
+Many a times, there is more to do with the database, rather than the simple operations which can be done by `insert`, `select`, `delete` and `update` - Things like your favorite (or scary) joins, counts etc. All these are possible with `query` method, which also takes `vars`.
+
+::
+
+    results = db.query("SELECT COUNT(*) AS total_users FROM users")
+    print results[0].total_users # prints number of entries in 'users' table
+
+Joining tables
+::
+
+    results = db.query("SELECT * FROM entries JOIN users WHERE entries.author_id = users.id")
+
+
+Transactions
+````````````
+The database object has a method `transaction` which starts a new transaction and returns the transaction object. The transaction object can be used to commit or rollback that transaction. It is also possible to have nested transactions.
+
+From Python 2.5 onwards, which support `with` statements, you would do
+
+::
+
+    with db.transaction():
+        userid = db.insert('users', name='foo')
+        authorid = db.insert('authors', userid=userid)
+
+
+For earlier versions of Python, you can do
+
+::
+
+    t = db.transaction()
+    try:
+        userid = db.insert('users', name='foo')
+        authorid = db.insert('authors', userid=userid)
+    except:
+        t.rollback()
+        raise
+    else:
+        t.commit()
diff --git a/docs/deploying.rst b/docs/deploying.rst
new file mode 100644
index 0000000..822a1a5
--- /dev/null
+++ b/docs/deploying.rst
@@ -0,0 +1,97 @@
+Deploying web.py applications
+=============================
+
+FastCGI
+-------
+
+web.py uses `flup`_ library for supporting fastcgi. Make sure it is installed.
+
+.. _flup: http://trac.saddi.com/flup
+
+You just need to make sure you applicaiton file is executable. Make it so by adding the following line to tell the system to execute it using python::
+
+    #! /usr/bin/env python
+
+and setting the exeutable flag on the file::
+
+    chmod +x /path/to/yourapp.py
+
+Configuring lighttpd    
+^^^^^^^^^^^^^^^^^^^^
+
+Here is a sample lighttpd configuration file to expose a web.py app using fastcgi. ::
+
+    # Enable mod_fastcgi and mod_rewrite modules
+    server.modules   += ( "mod_fastcgi" )
+    server.modules   += ( "mod_rewrite" )
+
+    # configure the application
+    fastcgi.server = ( "/yourapp.py" =>
+        (( 
+            # path to the socket file
+            "socket" => "/tmp/yourapp-fastcgi.socket", 
+
+            # path to the application
+            "bin-path" => "/path/to/yourapp.py",
+
+            # number of fastcgi processes to start
+            "max-procs" => 1,
+
+            "bin-environment" => (
+                "REAL_SCRIPT_NAME" => ""
+            ),
+            "check-local" => "disable"
+        ))
+    )
+
+     url.rewrite-once = (
+        # favicon is usually placed in static/
+        "^/favicon.ico$" => "/static/favicon.ico",
+
+        # Let lighttpd serve resources from /static/. 
+        # The web.py dev server automatically servers /static/, but this is 
+        # required when deploying in production.
+        "^/static/(.*)$" => "/static/$1",
+
+        # everything else should go to the application, which is already configured above.
+        "^/(.*)$" => "/yourapp.py/$1",
+     )
+
+With this configuration lighttpd takes care of starting the application. The webserver talks to your application using fastcgi via a unix domain socket. This means both the webserver and the application will run on the same machine.
+
+nginx + Gunicorn
+----------------
+
+Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project.
+
+To make a web.py application work with gunicorn, you'll need to get the wsgi app from web.py application object. ::
+
+    import web
+    ...
+    app = web.application(urls, globals())
+
+    # get the wsgi app from web.py application object
+    wsgiapp = app.wsgifunc()
+
+Once that change is made, gunicorn server be started using::
+
+    gunicorn -w 4 -b 127.0.0.1:4000 yourapp:wsgiapp
+
+This starts gunicorn with 4 workers and listens at port 4000 on localhost.
+
+It is best to use Gunicorn behind HTTP proxy server. The gunicorn team strongly advises to use nginx.
+Here is a sample nginx configuration which proxies to application running on `127.0.0.1:4000`. ::
+
+  server {
+    listen 80;
+    server_name example.org;
+    access_log  /var/log/nginx/example.log;
+
+    location / {
+        proxy_pass http://127.0.0.1:4000;
+
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+  }
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..b35dc6f
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,46 @@
+.. web.py documentation master file, created by
+   sphinx-quickstart on Sun Oct 27 15:35:05 2013.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to web.py's documentation!
+==================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 3
+
+   urlmapping
+   input
+   db
+   templating
+   deploying
+   api
+
+Getting Started
+===============
+
+Building webapps with web.py is easy. To get started, save the following code as say, `hello.py` and run it with `python hello.py`. Now point your browser to `http://localhost:8080/` which responds you with 'Hello, world!'. Hey, you're done with your first program with with web.py - with just 8 lines of code!
+
+::
+
+    import web
+
+    urls = ("/.*", "hello")
+    app = web.application(urls, globals())
+
+    class hello:
+        def GET(self):
+            return 'Hello, world!'
+
+    if __name__ == "__main__":
+        app.run()
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/input.rst b/docs/input.rst
new file mode 100644
index 0000000..bc7892a
--- /dev/null
+++ b/docs/input.rst
@@ -0,0 +1,92 @@
+Accessing User Input
+====================
+
+While building web applications, one basic and important thing is to respond to the user input that is sent to the server.
+
+Web.py makes it easy to access that whether it is parameters in the url (`GET` request) or the form data (`POST` or `PUT` request). The `web.input()` method returns a dictionary-like object (more specifically a `web.storage` object) that contains the user input, whatever the request method is.
+
+
+To access the URL parameters (?key=value) from the `web.input` object, just use `web.input().key`.
+
+GET
+---
+
+For a URL which looks like `/page?id=1&action=edit`, you do
+
+::
+
+    class Page(object):
+        def GET(self):
+            data = web.input()
+            id = int(data.id)   # all the inputs are now strings. Cast it to int, to get integer.
+            action = data.action
+            ...
+
+`KeyError` exception is thrown if `key` is not there in the URL parameters.
+Web.py makes it easier to handle that with default values to web.input().
+
+::
+
+    class Page(object):
+        def GET(self):
+            data = web.input(id=1, action='read')
+            id, action = int(data.id), data.action
+            ...
+
+POST
+----
+
+It works exactly the same way with POST method. If you have a form with `name` and `password` elements, you would do
+
+::
+
+    class Login(object):
+        def POST(self):
+            data = web.input()
+            name, password = data.name, data.password
+            ...
+
+
+Multiple inputs with same name
+------------------------------
+
+What if you have a URL which looks like `/page?id=1&id=2&id=3` or you have a form with multiple selects? What would `web.input().id` give us? It simply swallows all but one value. But to let web.input() know that we're expecting more values with the same name is simple. Just pass `[]` as the default argument for that name.
+
+::
+
+    class Page(object):
+        def GET(self):
+            data = web.input(id=[])
+            ids = data.id         # now, `ids` is a list with all the `id`s.
+            ...
+
+
+File uploads
+------------
+
+Uploading files is easy with web.py. `web.input()` takes care of that too. Just make sure that the upload form has an attribute enctype="multipart/form-data". The `input()` gives you `filename` and `value`, which are the uploaded file name and the contents of it, respectively.
+To make things simpler, it also gives you `file`, a file-like object if you pass `myfile={}` where `myfile` is the name of the input element in your form.
+::
+
+    class Upload(object):
+        def GET(self):
+            return render.upload()
+
+        def POST(self):
+             data = web.input(myfile={})
+             fp = data.myfile
+             save(fp)   # fp.filename, fp.read() gives name and contents of the file
+             ...
+
+or
+
+::
+
+    class Upload(object):
+        ...
+
+        def POST(self):
+             data = web.input() # notice that `myfile={}` is missing here.
+             fp = data.myfile
... 1170 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/webpy.git



More information about the Python-modules-commits mailing list