Skip to content

Commit c68e3c9

Browse files
committed
Improve CSS style for the documentation
1 parent b01054b commit c68e3c9

File tree

7 files changed

+58
-143
lines changed

7 files changed

+58
-143
lines changed

dbutils/steady_db.py

+2
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ def tough_method(*args, **kwargs):
651651
if execute:
652652
self._setsizes(cursor2)
653653
method2 = getattr(cursor2, name)
654+
# if the following call hangs,
655+
# you may have forgotten to call begin()
654656
result = method2(*args, **kwargs)
655657
if execute:
656658
self._clearsizes()

docs/doc.css

+16-118
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
11
/*
2-
Webware for Python (https://webwareforpython.github.io/w4py/)
3-
4-
Common style sheet for Webware's documentation pages
2+
Style sheet for DBUtils documentation pages.
53
*/
64

75
/* First import default style for pages created with Docutils: */
86

97
@import url(docutils.css);
108

11-
/* Customization for Webware goes here: */
9+
/* Customization for DBUtils goes here: */
1210

13-
body {
14-
background-color: #FFFFFF;
15-
font-family: Verdana, Arial, Helvetica, sans-serif;
16-
font-size: 10pt;
17-
padding: 12pt;
18-
}
19-
table {
20-
empty-cells: show;
21-
border-collapse: collapse;
22-
margin: 0 auto;
23-
}
24-
table.doc {
25-
border-spacing: 2px;
26-
border-collapse: separate;
27-
border-style: none;
28-
}
29-
td, th {
30-
font-family: Verdana, Arial, Helvetica, sans-serif;
31-
font-size: 10pt;
32-
}
33-
table.doc td, table.doc th {
34-
padding: 4px;
35-
border-style: none;
36-
}
3711
p {
3812
margin-top: 6pt;
3913
margin-bottom: 6pt;
@@ -43,11 +17,9 @@ li {
4317
margin-bottom: 6pt;
4418
}
4519
h1, h2 {
46-
font-family: Verdana, Arial, Helvetica, sans-serif;
4720
color: #002352;
4821
}
4922
h3, h4 {
50-
font-family: Verdana, Arial, Helvetica, sans-serif;
5123
color: #002352;
5224
}
5325
h1 {
@@ -59,119 +31,45 @@ h2 {
5931
h3 {
6032
font-size: 14pt;
6133
}
62-
h4 {
63-
font-size: 12pt;
64-
}
65-
h5 {
66-
font-size: 11pt;
67-
}
68-
h6 {
69-
font-size: 10pt;
70-
}
71-
h1.titlebar {
72-
padding: 4pt;
73-
margin-bottom: 12pt;
74-
text-align: center;
75-
color: white;
76-
background-color: #025;
77-
}
78-
h1.title, h1.header {
34+
h1.title {
7935
padding: 4pt;
8036
margin-bottom: 12pt;
8137
text-align: center;
8238
border-bottom: 1pt solid #025;
8339
padding-bottom: 8pt;
8440
}
85-
div.footer {
86-
font-family: Tahoma, Arial, Helvetica, sans-serif;
87-
font-size: 9pt;
88-
text-align: center;
89-
padding: 4pt;
90-
margin-top: 16pt;
91-
border-top: 1pt solid #025;
92-
}
93-
.left {
94-
text-align: left;
95-
}
96-
.right {
97-
text-align: right;
98-
}
99-
.center {
100-
text-align: center;
101-
}
102-
.top {
103-
vertical-align: top;
104-
}
105-
.nowrap {
106-
white-space: nowrap;
107-
}
108-
.contents {
109-
font-family: Tahoma, Arial, Helvetica, sans-serif;
110-
}
11141
.contents ul {
11242
list-style: none;
11343
margin-bottom: 24pt;
11444
padding-left: 0em;
11545
margin-left: 2em;
11646
}
11747
.contents ul li {
118-
font-size: 11pt;
119-
margin-bottom: 3pt;
48+
font-size: 14pt;
49+
margin-bottom: 2pt;
12050
}
12151
.contents ul ul {
12252
list-style-type: none;
123-
margin-top: 2pt;
124-
margin-bottom: 2pt;
53+
margin-top: 1pt;
54+
margin-bottom: 1pt;
12555
padding-left: 0em;
12656
margin-left: 1.5em;
12757
}
12858
.contents ul ul li {
129-
font-size: 10pt;
59+
font-size: 13pt;
13060
margin-bottom: 1pt;
13161
}
132-
.contents .topic-title {
133-
font-size: 16pt;
134-
}
135-
span.name {
136-
font-weight: bold;
137-
}
138-
span.filename {
139-
font-family: Tahoma, Arial, Helvetica, sans-serif;
140-
font-size: 9pt;
141-
}
142-
code, .literal, .literal-block, .pre, .py {
143-
font-family: "Andale Mono", "Lucida Console", Monaco, "Courier New", Courier, monospace;
144-
font-size: 10pt;
145-
color: #052;
146-
}
147-
tt.literal, span.pre {
148-
background-color: #FFFFFF;
149-
}
150-
pre.py, pre.literal-block {
151-
margin: 0;
152-
padding: 2pt 1pt 1pt 2pt;
153-
background-color: #F0F0F8;
154-
}
155-
.typed {
156-
font-weight: bold;
157-
}
158-
.error {
159-
color: red;
62+
.contents > p.topic-title {
63+
font-size: 24pt;
16064
}
16165
.warning {
16266
color: brown;
16367
}
164-
165-
/* Configuration documentation: */
166-
167-
dl.config {
168-
}
169-
dt.config {
170-
}
171-
dd.config {
68+
.admonition-title {
69+
background-color: #F5F5DC;
70+
padding: 1pt 3pt;
17271
}
173-
span.setting {
174-
font-family: Tahoma, Arial, Helvetica, sans-serif;
175-
font-size: 9pt;
176-
font-weight: bold;
72+
.admonition-title::before {
73+
content: "⚠";
74+
margin-right: .5em;
17775
}

docs/docutils.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/main.de.html

+6
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,14 @@ <h3>PersistentDB (persistent_db)</h3>
321321
Stattdessen wird die Verbindung automatisch dann geschlossen, wenn der Thread
322322
endet. Sie können dieses Verhalten ändern, indem Sie den Parameter namens
323323
<span class="docutils literal">closeable</span> setzen.</p>
324+
<aside class="admonition warning">
325+
<p class="admonition-title">Warnung</p>
324326
<p>Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
325327
<span class="docutils literal">begin()</span> eingeleitet werden müssen. Hierdurch wird sichergestellt, dass
326328
das transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
327329
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, before sie vom
328330
gleichen Thread erneut benutzt wird.</p>
331+
</aside>
329332
<p>Das Holen einer Verbindung kann etwas beschleunigt werden, indem man den
330333
Parameter <span class="docutils literal">threadlocal</span> auf <span class="docutils literal">threading.local</span> setzt; dies könnte aber in
331334
einigen Umgebungen nicht funktionieren (es ist zum Beispiel bekannt, dass
@@ -428,12 +431,15 @@ <h3>PooledDB (pooled_db)</h3>
428431
with db.cursor() as cur:
429432
cur.execute(...)
430433
res = cur.fetchone()</pre>
434+
<aside class="admonition warning">
435+
<p class="admonition-title">Warnung</p>
431436
<p>Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
432437
<span class="docutils literal">begin()</span> eingeleitet werden müssen. Hierdurch wird sichergestellt,
433438
dass die Verbindung nicht mehr mit anderen Threads geteilt wird, dass das
434439
transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
435440
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, bevor sie
436441
wieder an den Verbindungspool zurückgegeben wird.</p>
442+
</aside>
437443
</section>
438444
</section>
439445
<section id="besonderheiten-bei-der-benutzung">

docs/main.de.rst

+13-12
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,12 @@ Stattdessen wird die Verbindung automatisch dann geschlossen, wenn der Thread
317317
endet. Sie können dieses Verhalten ändern, indem Sie den Parameter namens
318318
``closeable`` setzen.
319319

320-
Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
321-
``begin()`` eingeleitet werden müssen. Hierdurch wird sichergestellt, dass
322-
das transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
323-
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, before sie vom
324-
gleichen Thread erneut benutzt wird.
320+
.. warning::
321+
Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
322+
``begin()`` eingeleitet werden müssen. Hierdurch wird sichergestellt, dass
323+
das transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
324+
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, before sie vom
325+
gleichen Thread erneut benutzt wird.
325326

326327
Das Holen einer Verbindung kann etwas beschleunigt werden, indem man den
327328
Parameter ``threadlocal`` auf ``threading.local`` setzt; dies könnte aber in
@@ -452,13 +453,13 @@ Sie können dies auch durch Verwendung von Kontext-Managern vereinfachen::
452453
cur.execute(...)
453454
res = cur.fetchone()
454455

455-
456-
Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
457-
``begin()`` eingeleitet werden müssen. Hierdurch wird sichergestellt,
458-
dass die Verbindung nicht mehr mit anderen Threads geteilt wird, dass das
459-
transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
460-
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, bevor sie
461-
wieder an den Verbindungspool zurückgegeben wird.
456+
.. warning::
457+
Bitte beachten Sie, dass Transaktionen explizit durch Aufruf der Methode
458+
``begin()`` eingeleitet werden müssen. Hierdurch wird sichergestellt,
459+
dass die Verbindung nicht mehr mit anderen Threads geteilt wird, dass das
460+
transparente Neueröffnen von Verbindungen bis zum Ende der Transaktion
461+
ausgesetzt wird, und dass die Verbindung zurückgerollt wird, bevor sie
462+
wieder an den Verbindungspool zurückgegeben wird.
462463

463464

464465
Besonderheiten bei der Benutzung

docs/main.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,13 @@ <h3>PersistentDB (persistent_db)</h3>
298298
contrary to the intent of having persistent connections. Instead,
299299
the connection will be automatically closed when the thread dies.
300300
You can change this behavior by setting the <span class="docutils literal">closeable</span> parameter.</p>
301+
<aside class="admonition warning">
302+
<p class="admonition-title">Warning</p>
301303
<p>Note that you need to explicitly start transactions by calling the
302304
<span class="docutils literal">begin()</span> method. This ensures that the transparent reopening will be
303305
suspended until the end of the transaction, and that the connection
304306
will be rolled back before being reused by the same thread.</p>
307+
</aside>
305308
<p>By setting the <span class="docutils literal">threadlocal</span> parameter to <span class="docutils literal">threading.local</span>, getting
306309
connections may become a bit faster, but this may not work in all
307310
environments (for instance, <span class="docutils literal">mod_wsgi</span> is known to cause problems
@@ -374,7 +377,7 @@ <h3>PooledDB (pooled_db)</h3>
374377
<pre class="literal-block">db = pool.dedicated_connection()</pre>
375378
<p>If you don't need it anymore, you should immediately return it to the
376379
pool with <span class="docutils literal">db.close()</span>. You can get another connection in the same way.</p>
377-
<p><em>Warning:</em> In a threaded environment, never do the following:</p>
380+
<p>Warning: In a threaded environment, never do the following:</p>
378381
<pre class="literal-block">pool.connection().cursor().execute(...)</pre>
379382
<p>This would release the connection too early for reuse which may be fatal
380383
if the connections are not thread-safe. Make sure that the connection
@@ -390,11 +393,14 @@ <h3>PooledDB (pooled_db)</h3>
390393
with db.cursor() as cur:
391394
cur.execute(...)
392395
res = cur.fetchone()</pre>
396+
<aside class="admonition warning">
397+
<p class="admonition-title">Warning</p>
393398
<p>Note that you need to explicitly start transactions by calling the
394399
<span class="docutils literal">begin()</span> method. This ensures that the connection will not be shared
395400
with other threads, that the transparent reopening will be suspended
396401
until the end of the transaction, and that the connection will be rolled
397402
back before being given back to the connection pool.</p>
403+
</aside>
398404
</section>
399405
</section>
400406
<section id="advanced-usage">

0 commit comments

Comments
 (0)