1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<h1 class="pudge-member-page-heading">
<tt>ConnectionHub</tt>
</h1>
<h4 class="pudge-member-page-subheading">
This object serves as a hub for connections, so that you can pass
in a ConnectionHub to a SQLObject subclass as though it was a
connection, but actually bind a real database connection later.
You can also bind connections on a per-thread basis.
</h4>
<p class="pudge-member-parent-link">
<small>
The ConnectionHub class is accessible via the
<a href="module-sqlobject.dbconnection.html">
<tt>sqlobject.dbconnection</tt>
</a> module.
</small>
</p>
<div id="pudge-section-nav">
<ul>
<li>
<a href="#attributes" class="pudge-section-link">
Attributes (1)
</a>
</li><li>
<a href="#methods" class="pudge-section-link">
Methods (8)
</a>
</li>
<li>
<a href="sqlobject/dbconnection.py.html?f=931&l=1030#931" class="pudge-section-link">
Source
</a>
</li>
</ul>
</div>
<div style="clear: left"></div>
<div class="rst pudge-module-doc">
<p>You must hang onto the original ConnectionHub instance, as you
cannot retrieve it again from the class or instance.</p>
<p>To use the hub, do something like:</p>
<pre class="literal-block">
hub = ConnectionHub()
class MyClass(SQLObject):
_connection = hub
hub.threadConnection = connectionFromURI('...')
</pre>
</div>
<hr>
<a name="attributes"></a>
<h2>Attributes</h2>
<div class="pudge-member name">
<a name="threadConnection"></a>
<h4 class="pudge-member-name"><span class="prefix">a</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#threadConnection" class="pudge-obj-link">threadConnection</a></tt></h4>
<div class="pudge-section rst">
<pre><property object at 0xb670598c></pre>
</div>
</div>
<a name="methods"></a>
<h2>Methods</h2>
<div class="pudge-member routine alias">
<a name="__format__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__format__" class="pudge-obj-link">__format__</a>(...)</tt>
<a href="__builtin__.py.html" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
<p class="pudge-member-blurb">
default object formatter
</p>
</div>
</div><div class="pudge-member routine alias">
<a name="__subclasshook__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__subclasshook__" class="pudge-obj-link">__subclasshook__</a>(...)</tt>
<a href="None.html" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
<p class="pudge-member-blurb">
Abstract classes can override this to customize issubclass().
</p>
<p>This is invoked early on by abc.ABCMeta.__subclasscheck__().
It should return True, False or NotImplemented. If it returns
NotImplemented, the normal algorithm is used. Otherwise, it
overrides the normal algorithm (and the outcome is cached).</p>
</div>
</div><div class="pudge-member routine alias">
<a name="__sizeof__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__sizeof__" class="pudge-obj-link">__sizeof__</a>(...)</tt>
<a href="__builtin__.py.html" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
<p class="pudge-member-blurb">
__sizeof__() -> int
size of object in memory, in bytes
</p>
</div>
</div><div class="pudge-member routine ">
<a name="__init__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__init__" class="pudge-obj-link">__init__</a>(self)</tt>
<a href="sqlobject/dbconnection.py.html?f=952&l=954#952" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
</div>
</div><div class="pudge-member routine ">
<a name="__get__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__get__" class="pudge-obj-link">__get__</a>(self, obj, type=None)</tt>
<a href="sqlobject/dbconnection.py.html?f=955&l=962#955" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
</div>
</div><div class="pudge-member routine ">
<a name="__set__"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#__set__" class="pudge-obj-link">__set__</a>(self, obj, value)</tt>
<a href="sqlobject/dbconnection.py.html?f=963&l=965#963" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
</div>
</div><div class="pudge-member routine ">
<a name="getConnection"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#getConnection" class="pudge-obj-link">getConnection</a>(self)</tt>
<a href="sqlobject/dbconnection.py.html?f=966&l=976#966" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
</div>
</div><div class="pudge-member routine ">
<a name="doInTransaction"></a>
<h4 class="pudge-member-name"><span class="prefix">f</span>
<tt><a href="class-sqlobject.dbconnection.ConnectionHub.html#doInTransaction" class="pudge-obj-link">doInTransaction</a>(self, func, *args, **kw)</tt>
<a href="sqlobject/dbconnection.py.html?f=977&l=1017#977" title="View Source">...</a>
</h4>
<div class="pudge-section rst">
<p class="pudge-member-blurb">
This routine can be used to run a function in a transaction,
rolling the transaction back if any exception is raised from
that function, and committing otherwise.
</p>
<p>Use like:</p>
<pre class="literal-block">
sqlhub.doInTransaction(process_request, os.environ)
</pre>
<p>This will run <tt class="docutils literal">process_request(os.environ)</tt>. The return
value will be preserved.</p>
</div>
</div>
<p>
<small>
See
<a href="sqlobject/dbconnection.py.html?f=931&l=1030#931" title="sqlobject/dbconnection.py:931">the source</a>
for more information.
</small>
</p>
|