]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixup of the tutorial, doc tester with the new logging stuff
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 14 Oct 2006 22:22:53 +0000 (22:22 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 14 Oct 2006 22:22:53 +0000 (22:22 +0000)
doc/build/content/tutorial.txt
doc/build/testdocs.py

index 201234e47f22b0f1b02b41afdc0b4620251fb936..dc9a9b8898ff35e4e9b2c243df6b469dc1710e75 100644 (file)
@@ -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,
index 33da3db259a79b04b0f1d5eec79f7ed79111ce72..e93c4c57991feb963ff02cc4c3c3e9b34a90fd02 100644 (file)
@@ -5,14 +5,22 @@ import os
 import re\r
 import doctest\r
 import sqlalchemy.util as util\r
+import sqlalchemy.logging as salog\r
+import logging\r
 \r
-# monkeypatch a plain logger\r
-class Logger(object):\r
-    def __init__(self, *args, **kwargs):\r
+salog.default_enabled=True\r
+rootlogger = logging.getLogger('sqlalchemy')\r
+rootlogger.setLevel(logging.NOTSET)\r
+class MyStream(object):\r
+    def write(self, string):\r
+        sys.stdout.write(string)\r
+        sys.stdout.flush()\r
+    def flush(self):\r
         pass\r
-    def write(self, msg):\r
-        print msg\r
-util.Logger = Logger\r
+handler = logging.StreamHandler(MyStream())\r
+handler.setFormatter(logging.Formatter('%(message)s'))\r
+rootlogger.addHandler(handler)\r
+\r
 \r
 def teststring(s, name, globs=None, verbose=None, report=True, \r
                optionflags=0, extraglobs=None, raise_on_error=False, \r