Skip to content

Commit

Permalink
ZMI: Improved GUI-compatibility to Zope4+
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Dec 13, 2020
1 parent 225979e commit b6f8a46
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 288 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

2.4.8
--------------------

Restuctered ZMI according to Zope4+


2.4.7.dev1+perfact.4
--------------------

Expand Down
2 changes: 2 additions & 0 deletions Products/ZPsycopgDA/DA.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Connection(Shared.DC.ZRDB.Connection.Connection):
database_type = 'Psycopg2'
meta_type = title = 'Z Psycopg 2 Database Connection'
icon = 'misc_/conn'
zmi_icon = 'fas fa-database text-info'
zmi_show_add_dialog = True

def __init__(self, id, title, connection_string,
zdatetime, check=None, tilevel=DEFAULT_TILEVEL,
Expand Down
2 changes: 1 addition & 1 deletion Products/ZPsycopgDA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# their work without bothering about the module dependencies.

__doc__ = "ZPsycopg Database Adapter Registration."
__version__ = '2.4.7.dev1+perfact.4'
__version__ = '2.4.8'

# Python2 backward compatibility
try:
Expand Down
258 changes: 115 additions & 143 deletions Products/ZPsycopgDA/dtml/add.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,159 +6,131 @@
help_topic='ZPsycopgDA-Method-Add.stx'
)">

<p class="form-help">
A Zope Psycopg 2 Database Connection is used to connect and execute
queries on a PostgreSQL database.
</p>

<p class="form-help">
In the form below <em>Connection String</em> (also called the Data Source Name
or DSN for short) is a string containing the connection parameters, for
example: “dbname=test user=postgres password=secret”
</p>

<p class="form-help">
The basic connection parameters are:
<ul>
<li>dbname: the database name (only in dsn string)</li>
<li>database: the database name (only as keyword argument)</li>
<li>user: user name used to authenticate</li>
<li>password: password used to authenticate</li>
<li>host: database host address (defaults to UNIX socket if not provided)</li>
<li>port: connection port number (defaults to 5432 if not provided)</li>
</ul>
</p>

<p class="form-help">
<b>Note on transaction levels:</b> Unless your server is capable of retries
(Setting "max-conflict-retries" in zope.conf), you should not use
"repeatable read" or "serializable", because both can produce random errors
on contradicting transactions.
</p>

<p class="form-help">
<b>Note on two-phase commit:</b> This feature uses "PREPARE TRANSACTION", which
has some limitations (no NOTIFY or LISTEN is possible), and needs special
provisions to clean up orphaned prepared transactions. Use with care.
</p>

<form action="manage_addZPsycopgConnection" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
<main class="container-fluid">

<p class="form-help">
A Zope Psycopg 2 Database Connection is used to connect and execute
queries on a PostgreSQL database. In the form below <em>Connection String</em>
(also called the Data Source Name or DSN for short) is a string containing
the connection parameters, for example:
<samp>“dbname=test user=postgres password=secret”</samp>
</p>

<form action="manage_addZPsycopgConnection" method="POST">
<div class="form-group row">
<label for="id" class="form-label col-sm-4 col-md-3">Id</label>
<div class="col-sm-8 col-md-9">
<input id="id" class="form-control" type="text" name="id"
placeholder="Psycopg2_database_connection"
value="Psycopg2_database_connection" />
</div>
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40"
value="Psycopg2_database_connection" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title

<div class="form-group row">
<label for="title" class="form-label col-sm-4 col-md-3">Title</label>
<div class="col-sm-8 col-md-9">
<input id="title" class="form-control" type="text" name="title"
placeholder="Z Psycopg 2 Database Connection"
value="Z Psycopg 2 Database Connection" />
</div>
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40"
value="Z Psycopg 2 Database Connection"/>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Connection string

<div class="form-group row">
<label for="connection_string" class="form-label col-sm-4 col-md-3">Connection string</label>
<div class="col-sm-8 col-md-9">
<input id="connection_string" class="form-control" type="text" name="connection_string"
placeholder="dbname=test user=postgres password=secret"
value="" />
<small>
The basic connection parameters are:
<br/>
<code>dbname</code>: the database name (only in dsn string)
<br />
<code>database</code>: the database name (only as keyword argument)
<br />
<code>user</code>: user name used to authenticate
<br />
<code>password</code>: password used to authenticate
<br />
<code>host</code>: database host address (defaults to UNIX socket if not provided)
<br />
<code>port</code>: connection port number (defaults to 5432 if not provided)
</small>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="text" name="connection_string" size="40" value="" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Connect immediately

<div class="form-group row">
<label for="check" class="form-label col-sm-4 col-md-3">Connect immediately</label>
<div class="col-sm-5 col-md-1">
<input class="btn btn-primary" type="checkbox" id="check" name="check" value="YES" checked="YES" class="form-control"/>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="check" value="YES" checked="YES" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Use Zope's internal DateTime

<div class="form-group row">
<label for="zdatetime" class="form-label col-sm-4 col-md-3">Use Zope's internal DateTime</label>
<div class="col-sm-5 col-md-1">
<input class="btn btn-primary" type="checkbox" id="zdatetime" name="zdatetime" value="YES" checked="YES" class="form-control"/>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="zdatetime" value="YES" checked="YES" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Transaction isolation level

<div class="form-group row">
<label for="tilevel" class="form-label col-sm-4 col-md-3">Transaction isolation level</label>
<div class="col-sm-8 col-md-9">
<select class="form-control" id="tilevel" name="tilevel:int">
<option value="4">Read uncommitted</option>
<option value="1">Read committed</option>
<option value="2" selected="YES">Repeatable read</option>
<option value="3">Serializable</option>
</select>
<small>
Note: Unless your server is capable of retries (Setting <samp>max-conflict-retries</samp>
in zope.conf), you should not use <samp>repeatable read</samp> or <samp>serializable</samp>,
because both can produce random errors on contradicting transactions.
</small>
</div>
</div>
</td>
<td align="left" valign="top">
<select name="tilevel:int">
<option value="4">Read uncommitted</option>
<option value="1">Read committed</option>
<option value="2" selected="YES">Repeatable read</option>
<option value="3">Serializable</option>
</select>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Auto-commit each query

<div class="form-group row">
<label for="autocommit" class="form-label col-sm-4 col-md-3">Auto-commit each query</label>
<div class="col-sm-5 col-md-1">
<input class="btn btn-primary" type="checkbox" id="autocommit" name="autocommit" value="YES" checked="YES" class="form-control"/>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="autocommit" value="YES" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Read-only mode

<div class="form-group row">
<label for="readonlymode" class="form-label col-sm-4 col-md-3">Read-only mode</label>
<div class="col-sm-5 col-md-1">
<input class="btn btn-primary" type="checkbox" id="readonlymode" name="readonlymode" value="YES" checked="YES" class="form-control"/>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="readonlymode" value="YES" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Use Two-Phase Commit

<div class="form-group row">
<label for="use_tpc" class="form-label col-sm-4 col-md-3">Use Two-Phase Commit</label>
<div class="col-sm-8 col-md-9">
<input class="btn btn-primary" type="checkbox" id="use_tpc" name="use_tpc" value="YES" checked="YES" class="form-control"/>
<small class="d-block">
Note: "Two-Phase Commit" uses <samp>PREPARE TRANSACTION</samp>, which
has some limitations (no <samp>NOTIFY</samp> or <samp>LISTEN</samp> is possible),
and needs special provisions to clean up orphaned prepared transactions.
Use with care.
</small>
</div>
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="use_tpc" value="YES" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Encoding

<div class="form-group row">
<label for="encoding" class="form-label col-sm-4 col-md-3">Encoding</label>
<div class="col-sm-8 col-md-9">
<input id="encoding" class="form-control" type="text" name="encoding"
placeholder="UTF-8"
value="" />
</div>
</div>
</td>
<td align="left" valign="top">
<input type="text" name="encoding" size="40" value="" />
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<div class="form-element">
<input class="form-element" type="submit" name="submit" value=" Add " />

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value=" Add " />
</div>
</td>
</tr>
</table>
</form>
</form>

</main>

<dtml-var manage_page_footer>
Loading

0 comments on commit b6f8a46

Please sign in to comment.