Normalize creation/dropping of schemas in tests.

 * pyrseas/testutils.py (PostgresDb.clear): Drop all non-public
   schemas at the beginning. Simplify remaining steps.
 * tests/dbobject/test_table.py: Move test_create_table_within_schema
   here from test_schema.py.
 * tests/dbobject/test_*.py: Remove special-case code to drop schema s1.
Schema-qualify table when dropping columns. Fixes #26.

 * pyrseas/dbobject/column.py (Column.drop): Add schema qualification.
 * tests/dbobject/test_column.py: New regression test.
When iterating over schemas don't remove non-schema elements. Fixes #27.
Fix dbtoyaml -t to output sequences owned by tables and schema description.

 * pyrseas/database.py (Database.to_map): Add schemas and tables as
   arguments. Move modified code from dbtoyaml.py and adjust it to
   output owned sequences and schema description.
 * pyrseas/dbtoyaml.py: Remove code for trim schemas/tables and pass
   new arguments.
 * pyrseas/testutils.py (PostgresDb.execute_and_map): Add schemas and
   tables arguments and pass them on to to_map.
 * tests/dbobject/test_schema.py: New regression test.
 * tests/dbobject/test_table.py: New regression tests.

Requires further work, but these changes suffice for r0.5.
Refactor PyrseasTestCase into two classes to streamline test construction.

 * pyrseas/testutils.py (PostgresDb.{execute_and_map,process_map}):
   Refactor to new classes.  (PyrseasTestCase.database): New method to
   instantiate Database object.  DatabaseToMapTestCase,
   InputMapToSqlTestCase: New classes to derive test cases.
 * tests/dboject/test_*.py: Refactor tests using the two new classes.
Make DbConnection more generic and move into pyrseas.lib.

 * docs/database.rst: Explain new CatDbConnection class.
 * docs/dbconn.rst: Explain generic usage of extended DbConnection.
   Add new automethods close, commit, rollback, execute and remove
   autoattribute.version.
 * docs/{dbobject,index}.rst: Update links.
 * pyrseas/database.py (CatDbConnection): New class derived from
   DbConnection.  (Database.__init__): Change arguments and initialize
   dbconn here.
 * pyrseas/dbconn.py: Deleted/moved to pyrseas/lib.
 * pyrseas/dbobject/__init__.py (DbObjectDict.fetch): Remove connect
   but add rollback.
 * pyrseas/dbobject/operclass.py (OperatorClassDict._from_catalog):
   Add rollback's after fetchall's.
 * pyrseas/dbobject/table.py (ClassDict._from_catalog): Add rollback
   after fetchall.
 * pyrseas/dbtoyaml.py (main): Initialize Database directly. Get
   password here.
 * pyrseas/lib/__init__.py: New submodule.
 * pyrseas/lib/dbconn.py: Moved from pyrseas. Made more generic so
   that it can be used for other purposes.  Renamed _execute to
   execute, added close, commit and rollback methods.  Don't rollback
   after fetchone and fetchall.  Exclude set search_path calls.
 * pyrseas/testutils.py (PyrseasTestCase.database): Initialize
   Database directly.
 * pyrseas/yamltodb.py (main): Initialize Database directly. Get
   password here. Use DbConnection execute, rollback and commit
   instead of Psycopg.
Correct handling of closed connections.

 * pyrseas/lib/dbconn.py (DbConnection.close): Always set conn to None.
   (DbConnection.execute): Test Psycopg2 closed status too.
dbtoyaml: add -N/--exclude-schema, -T/--exclude-table

  * -N/--exclude-schema command line option allows to specify several schemas
    (via repeating option declaration) to exclude from output

  * -T/--exclude-table command line option allows to specify several tables
    (via repeating option declaration) to exclude from output

  * -n/--schema now allows to specify several schemas to include in output (via
    repeating option declaration).

  * Database.to_map now doesn't treat schemas=[None] as special case
Document and reorganize new dbtoyaml options.

 * AUTHORS: Add Roger Hunwicks, Andrey Popp.
 * docs/dbtoyaml.rst: Document -N and -T options and add info to -n
   and -t.
 * pyrseas/dbtoyaml.py: Group -n/N/t/T options in a separate section
   and editorialize help text and meta variables to resemble pg_dump.
Add support for PG 9.1 extensions.

 * docs/extension.rst:  New page to document extensions.
 * docs/index.rst: Add extension.rst.
 * pyrseas/database.py (Database.Dicts.__init__): Add dictionary for
   extensions.  (Database.link_refs): Add extensions argument to
   schemas.link_refs call.  (Database._trim_objects): Add extensions
   to list of object types.  (Database.diff_map): Add calls to
   extensions.diff_map and extensions._drop.
 * pyrseas/dbobject/dbtype.py (TypeDict.query): Exclude types
   dependent on extensions.
 * pyrseas/dbobject/extension.py: New module to implement extensions.
 * pyrseas/dbobject/function.py (ProcDict.query): Exclude procedures
   dependent on extensions.
 * pyrseas/dbobject/language.py (LanguageDict.query): Exclude
   languages dependent on extensions.  (LanguageDict.link_refs):
   Special case code for plpgsql.
 * pyrseas/dbobject/operator.py (OperatorDict.query): Exclude
   operators dependent on extensions.
 * pyrseas/dbobject/operclass.py (OperatorClassDict.query): Exclude
   operator classes dependent on extensions.
 * pyrseas/dbobject/operfamily.py (OperatorFamilyDict.query): Exclude
   operator families dependent on extensions.
 * pyrseas/dbobject/schema.py (Schema.to_map): Add extensions to list
   of object types.  (SchemaDict.query): Allow pg_catalog to be
   fetched (for language extensions).  (SchemaDict.from_map): Process
   input extensions.  (SchemaDict.link_refs): Add argument for
   extensions.  (SchemaDict.diff_map): Prevent dropping of pg_catalog
   schema.
 * pyrseas/testutils.py (PostgresDb.clear): Drop existing extensions.
   (InputMapToSqlTestCase.std_map): For 9.1, add PL/pgSQL as an
   extension.
 * tests/dbobject/__init__.py: Invoke extension tests.
 * tests/dbobject/test_extension.py: New test module.
 * tests/dbobject/test_language.py: Don't run tests under PG 9.1.
 * tests/dbobject/test_schema.py (SchemaToSqlTestCase): Use std_map to
   build maps.
 * tests/dbobject/test_table.py
   (TableToSqlTestCase.test_create_table_within_schema): Use std_map
   to build maps.
dbtoyaml: do not monkey patch sys module
yamltodb: do not monkey patch sys module
dbtoyaml: typo
In yamltodb, exit with status 2 if statements were output.

 * docs/yamltodb.rst: Document exit statuses.  Add paragraph about use
   of status 0 for verifying no changes were made.  Reformat some
   options for clarity.
 * pyrseas/yamltodb.py: If statements were output, exit with status 2.
Support MATCH attributes for foreign keys. Fixes #34.

 * pyrseas/dbobject/constraint.py (ForeignKey.add): Add MATCH spec.
   (ConstraintDict.query): Retrieve pg_constraint.confmatchtype.
   (ConstraintDict._from_catalog): Transform match types.
   (ConstraintDict.from_map): Check and save match specs.
 * tests/dbobject/test_constraint.py: Two new tests to verify MATCH
   attributes.
Back out change 38772f2, i.e., exit yamltodb with 0 if statements generated.

  Exiting yamltodb with 2 (or 1) prevents it from being used easily in
  automated deployment.
Properly support index functions/expressions.  Fixes #3.

 * pyrseas/dbobject/index.py (Index.key_columns): Rename to
   key_expressions and replace self.columns by self.keys.
   (Index.create): Call key_expressions() always.  (IndexDict.query):
   Rename expression to keyexprs.  (IndexDict._from_catalog): Parse
   the key expressions and index definition to properly deal with the
   various specifications.  (IndexDict.from_map): Accept 'keys' or
   'columns' but not 'expression'.
 * tests/dbobject/test_index.py (IndexToMapTestCase): Change 'columns'
   to 'keys'. Add new tests test_index_function_multi and
   test_index_mixed.  (IndexToSqlTestCase): Change 'columns' to
   'keys'.  Add new tests test_add_index_back_compat and
   test_index_mixed.
Add support for TABLESPACEs for tables, primary keys and indexes.

 * pyrseas/dbobject/constraint.py (Constraint.add): Add USING INDEX
   TABLESPACE clause.  (ConstraintDict.query): Fetch
   pg_tablespace.spcname.  (ConstraintDict.from_map): Allow tablespace
   attribute in input map for primary keys and unique constraints.
 * pyrseas/dbobject/index.py (Index.create): Add TABLESPACE clause.
   (Index.diff_map): Handle changes to index tablespaces.
   (IndexDict.query): Fetch pg_tablespace.spcname.
   (IndexDict.from_map): Allow tablespace attribute in input map.
 * pyrseas/dbobject/table.py (Table.to_map): Output tablespace if
   present.  (Table.create): Add TABLESPACE clause.  (Table.diff_map):
   Handle tablespace changes.  (ClassDict.query): Fetch
   pg_tablespace.spcname.  (ClassDict.from_map): Allow tablespace in
   input map for tables.
 * tests/dbobject/__init__.py: Invoke test_tablespace.
 * tests/dbobject/test_tablespace.py: Tests for new functionality.
In UserMappingDict, use pg_user_mappings instead of pg_user_mapping. Fixes #35.
dbtoyaml.py, yamltodb.py: set pswd to None as default so that libpq could use PGPASSWORD env.