From 6b40f50b87a03172d77abf0e50f42b565f416645 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 14 Oct 2006 22:22:53 +0000 Subject: [PATCH] fixup of the tutorial, doc tester with the new logging stuff --- doc/build/content/tutorial.txt | 7 ++++--- doc/build/testdocs.py | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/build/content/tutorial.txt b/doc/build/content/tutorial.txt index 201234e47f..dc9a9b8898 100644 --- a/doc/build/content/tutorial.txt +++ b/doc/build/content/tutorial.txt @@ -130,7 +130,7 @@ Inserting is achieved via the `insert()` method, which defines a *clause object* Since we created this insert statement object from the `users` table which is bound to our `Engine`, the statement itself is also bound to the `Engine`, and supports executing itself. The `execute()` method of the clause object will *compile* the object into a string according to the underlying *dialect* of the Engine to which the statement is bound, and will then execute the resulting statement. {python} - >>> i.execute(user_name='Mary', password='secure') # doctest:+ELLIPSIS + >>> i.execute(user_name='Mary', password='secure') # doctest:+ELLIPSIS,+NORMALIZE_WHITESPACE INSERT INTO users (user_name, password) VALUES (?, ?) ['Mary', 'secure'] COMMIT @@ -214,13 +214,14 @@ Result sets also support iteration. We'll show this with a slightly different f ### Table Relationships {@name=table_relationships} -Lets create a second table, `email_addresses`, which references the `users` table. To define the relationship between the two tables, we will use the `ForeignKey` construct. We will also issue the `CREATE` statement for the table in one step: +Lets create a second table, `email_addresses`, which references the `users` table. To define the relationship between the two tables, we will use the `ForeignKey` construct. We will also issue the `CREATE` statement for the table: {python} >>> email_addresses_table = Table('email_addresses', metadata, ... Column('address_id', Integer, primary_key=True), ... Column('email_address', String(100), nullable=False), - ... Column('user_id', Integer, ForeignKey('users.user_id'))).create() # doctest:+ELLIPSIS,+NORMALIZE_WHITESPACE + ... Column('user_id', Integer, ForeignKey('users.user_id'))) + >>> email_addresses_table.create() # doctest:+ELLIPSIS,+NORMALIZE_WHITESPACE CREATE TABLE email_addresses ( address_id INTEGER NOT NULL, email_address VARCHAR(100) NOT NULL, diff --git a/doc/build/testdocs.py b/doc/build/testdocs.py index 33da3db259..e93c4c5799 100644 --- a/doc/build/testdocs.py +++ b/doc/build/testdocs.py @@ -5,14 +5,22 @@ import os import re import doctest import sqlalchemy.util as util +import sqlalchemy.logging as salog +import logging -# monkeypatch a plain logger -class Logger(object): - def __init__(self, *args, **kwargs): +salog.default_enabled=True +rootlogger = logging.getLogger('sqlalchemy') +rootlogger.setLevel(logging.NOTSET) +class MyStream(object): + def write(self, string): + sys.stdout.write(string) + sys.stdout.flush() + def flush(self): pass - def write(self, msg): - print msg -util.Logger = Logger +handler = logging.StreamHandler(MyStream()) +handler.setFormatter(logging.Formatter('%(message)s')) +rootlogger.addHandler(handler) + def teststring(s, name, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, -- 2.47.2