From: Mike Bayer Date: Thu, 27 Oct 2005 04:11:59 +0000 (+0000) Subject: (no commit message) X-Git-Tag: rel_0_1_0~442 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a154978fe1c504910c2a95104807e2a4a1febdc;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git --- diff --git a/doc/build/components/pydoc.myt b/doc/build/components/pydoc.myt index 4acf6592c1..07191b242c 100644 --- a/doc/build/components/pydoc.myt +++ b/doc/build/components/pydoc.myt @@ -1,6 +1,8 @@ <%method obj_doc> <%args> obj + functions = None + classes = None <%init> import types @@ -12,55 +14,61 @@ objects = obj.__ALL__ else: objects = obj.__dict__.keys() - functions = [getattr(obj, x, None) - for x in objects - if getattr(obj,x,None) is not None and - (isinstance(getattr(obj,x), types.FunctionType)) - and not getattr(obj,x).__name__[0] == '_' - ] - classes = [getattr(obj, x, None) - for x in objects - if getattr(obj,x,None) is not None and - (isinstance(getattr(obj,x), types.TypeType) - or isinstance(getattr(obj,x), types.ClassType)) - and not getattr(obj,x).__name__[0] == '_' - ] + if functions is None: + functions = [getattr(obj, x, None) + for x in objects + if getattr(obj,x,None) is not None and + (isinstance(getattr(obj,x), types.FunctionType)) + and not getattr(obj,x).__name__[0] == '_' + ] + functions.sort(lambda a, b: cmp(a.__name__, b.__name__)) + if classes is None: + classes = [getattr(obj, x, None) + for x in objects + if getattr(obj,x,None) is not None and + (isinstance(getattr(obj,x), types.TypeType) + or isinstance(getattr(obj,x), types.ClassType)) + and not getattr(obj,x).__name__[0] == '_' + ] + classes.sort(lambda a, b: cmp(a.__name__, b.__name__)) else: - functions = [getattr(obj, x).im_func for x in obj.__dict__.keys() if isinstance(getattr(obj,x), types.MethodType) and not getattr(obj,x).__name__[0] == '_'] - classes = [] + if functions is None: + functions = [getattr(obj, x).im_func for x in obj.__dict__.keys() if isinstance(getattr(obj,x), types.MethodType) and not getattr(obj,x).__name__[0] == '_'] + functions.sort(lambda a, b: cmp(a.__name__, b.__name__)) + if classes is None: + classes = [] - functions.sort(lambda a, b: cmp(a.__name__, b.__name__)) - classes.sort(lambda a, b: cmp(a.__name__, b.__name__)) + if isclass: + description = "Class " + name + else: + description = "Module " + name -

-% if isclass: - Class <% name %> -% else: - Module <% name %> -% -

+<&|doclib.myt:item, name=obj.__name__, description=description &> + <% obj.__doc__ %> -
+<% (obj.__doc__ and "

" or '') %> +% if len(functions): <&|formatting.myt:paramtable&> -% if not isclass and len(functions): -

Module Functions

% for func in functions: -hi <& SELF:function_doc, func=func &> % + % % if len(classes):

Classes

+<&|formatting.myt:paramtable&> % for class_ in classes: <& SELF:obj_doc, obj=class_ &> % + % + - + <%method function_doc> <%args>func @@ -72,21 +80,17 @@ hi varkw = argspec[2] defaults = argspec[3] or () argstrings = [] - i = 0 - for arg in argnames: - try: - default = defaults[i] - argstrings.append("%s=%s" % (arg, repr(default))) - i +=1 - except IndexError: - argstrings.append(arg) + for i in range(0, len(argnames)): + if i >= len(argnames) - len(defaults): + argstrings.append("%s=%s" % (argnames[i], repr(defaults[i - (len(argnames) - len(defaults))]))) + else: + argstrings.append(argnames[i]) if varargs is not None: argstrings.append("*%s" % varargs) if varkw is not None: argstrings.append("**%s" % varkw) - huh ? <% repr(func) |h %> <&| formatting.myt:function_doc, name="def " + func.__name__, arglist=argstrings &> <% func.__doc__ %> diff --git a/doc/build/content/pooling.myt b/doc/build/content/pooling.myt index c1fb89e114..ec7a23ca77 100644 --- a/doc/build/content/pooling.myt +++ b/doc/build/content/pooling.myt @@ -1,8 +1,30 @@ <%flags>inherit='document_base.myt' <&|doclib.myt:item, name="pooling", description="Connection Pooling" &> <&|doclib.myt:item, name="establishing", description="Establishing a Transparent Connection Pool" &> + Any DBAPI module can be "proxied" through the connection pool using the following technique: + + <&|formatting.myt:code&> + import sqlalchemy.pool as pool + import psycopg2 as psycopg + psycopg = pool.manage(psycopg) + + # then connect normally + connection = psycopg.connect(database='test', username='scott', password='tiger') + +

This produces a sqlalchemy.pool.DBProxy object which supports the same connect() function as the original DBAPI module. Upon connection, a thread-local connection proxy object is returned, which delegates its calls to a real DBAPI connection object. This connection object is stored persistently within a connection pool (an instance of sqlalchemy.pool.Pool) that corresponds to the exact connection arguments sent to the connect() function. The connection proxy also returns a proxied cursor object upon calling connection.cursor(). When all cursors as well as the connection proxy are de-referenced, the connection is automatically made available again by the owning pool object.

+ +

Basically, the connect() function is used in its usual way, and the pool module transparently returns thread-local pooled connections. Each distinct set of connect arguments corresponds to a brand new connection pool created; in this way, an application can maintain connections to multiple schemas and/or databases, and each unique connect argument set will be managed by a different pool object.

<&|doclib.myt:item, name="configuration", description="Connection Pool Configuration" &> +

When proxying a DBAPI module through the pool module, options exist for how the connections should be pooled: +

+ \ No newline at end of file diff --git a/doc/style.css b/doc/style.css index 6decd245de..ddef5196d8 100644 --- a/doc/style.css +++ b/doc/style.css @@ -30,7 +30,7 @@ a:hover {color:#700000;} } .light { - background-color: #FFFFFF; + background-color: #EFEFEF; } .dark {