From 962c22c9eda7d2ab7dc0b41bd1c7a52cf0c9d008 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 25 Feb 2007 22:44:52 +0000 Subject: migrated (most) docstrings to pep-257 format, docstring generator using straight
 + trim() func for now.  applies most of [ticket:214],
 compliemnts of Lele Gaifax

---
 lib/sqlalchemy/engine/strategies.py | 57 +++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 18 deletions(-)

(limited to 'lib/sqlalchemy/engine/strategies.py')

diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py
index a7f2cc003..7a7b84aa9 100644
--- a/lib/sqlalchemy/engine/strategies.py
+++ b/lib/sqlalchemy/engine/strategies.py
@@ -1,8 +1,13 @@
-"""defines different strategies for creating new instances of sql.Engine.  
-by default there are two, one which is the "thread-local" strategy, one which is the "plain" strategy. 
-new strategies can be added via constructing a new EngineStrategy object which will add itself to the
-list of available strategies here, or replace one of the existing name.  
-this can be accomplished via a mod; see the sqlalchemy/mods package for details."""
+"""Define different strategies for creating new instances of sql.Engine.
+
+By default there are two, one which is the "thread-local" strategy,
+one which is the "plain" strategy.
+
+New strategies can be added via constructing a new EngineStrategy
+object which will add itself to the list of available strategies here,
+or replace one of the existing name.  this can be accomplished via a
+mod; see the sqlalchemy/mods package for details.
+"""
 
 
 from sqlalchemy.engine import base, default, threadlocal, url
@@ -12,22 +17,30 @@ from sqlalchemy import pool as poollib
 strategies = {}
 
 class EngineStrategy(object):
-    """defines a function that receives input arguments and produces an instance of sql.Engine, typically
-    an instance sqlalchemy.engine.base.Engine or a subclass."""
+    """Define a function that receives input arguments and produces an
+    instance of sql.Engine, typically an instance
+    sqlalchemy.engine.base.Engine or a subclass.
+    """
+
     def __init__(self, name):
-        """construct a new EngineStrategy object and sets it in the list of available strategies
-        under this name."""
+        """Construct a new EngineStrategy object.
+
+        Sets it in the list of available strategies under this name.
+        """
+
         self.name = name
         strategies[self.name] = self
+
     def create(self, *args, **kwargs):
-        """given arguments, returns a new sql.Engine instance."""
+        """Given arguments, returns a new sql.Engine instance."""
+
         raise NotImplementedError()
 
 class DefaultEngineStrategy(EngineStrategy):
     def create(self, name_or_url, **kwargs):
         # create url.URL object
         u = url.make_url(name_or_url)
-        
+
         # get module from sqlalchemy.databases
         module = u.get_module()
 
@@ -36,7 +49,7 @@ class DefaultEngineStrategy(EngineStrategy):
         for k in util.get_cls_kwargs(module.dialect):
             if k in kwargs:
                 dialect_args[k] = kwargs.pop(k)
-                
+
         # create dialect
         dialect = module.dialect(**dialect_args)
 
@@ -50,6 +63,7 @@ class DefaultEngineStrategy(EngineStrategy):
             dbapi = kwargs.pop('module', dialect.dbapi())
             if dbapi is None:
                 raise exceptions.InvalidRequestError("Cant get DBAPI module for dialect '%s'" % dialect)
+
             def connect():
                 try:
                     return dbapi.connect(*cargs, **cparams)
@@ -80,41 +94,48 @@ class DefaultEngineStrategy(EngineStrategy):
         for k in util.get_cls_kwargs(engineclass):
             if k in kwargs:
                 engine_args[k] = kwargs.pop(k)
-                
+
         # all kwargs should be consumed
         if len(kwargs):
             raise TypeError("Invalid argument(s) %s sent to create_engine(), using configuration %s/%s/%s.  Please check that the keyword arguments are appropriate for this combination of components." % (','.join(["'%s'" % k for k in kwargs]), dialect.__class__.__name__, pool.__class__.__name__, engineclass.__name__))
-            
+
         return engineclass(provider, dialect, **engine_args)
 
     def pool_threadlocal(self):
         raise NotImplementedError()
+
     def get_pool_provider(self, pool):
         raise NotImplementedError()
+
     def get_engine_cls(self):
         raise NotImplementedError()
-           
+
 class PlainEngineStrategy(DefaultEngineStrategy):
     def __init__(self):
         DefaultEngineStrategy.__init__(self, 'plain')
+
     def pool_threadlocal(self):
         return False
+
     def get_pool_provider(self, pool):
         return default.PoolConnectionProvider(pool)
+
     def get_engine_cls(self):
         return base.Engine
+
 PlainEngineStrategy()
 
 class ThreadLocalEngineStrategy(DefaultEngineStrategy):
     def __init__(self):
         DefaultEngineStrategy.__init__(self, 'threadlocal')
+
     def pool_threadlocal(self):
         return True
+
     def get_pool_provider(self, pool):
         return threadlocal.TLocalConnectionProvider(pool)
+
     def get_engine_cls(self):
         return threadlocal.TLEngine
-ThreadLocalEngineStrategy()
-
 
-    
+ThreadLocalEngineStrategy()
-- 
cgit v1.2.1