Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
83a58eff
Commit
83a58eff
authored
Sep 21, 1999
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new test-tab-feature on database connection objects
parent
2d5ab3c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
7 deletions
+58
-7
lib/python/Shared/DC/ZRDB/Aqueduct.py
lib/python/Shared/DC/ZRDB/Aqueduct.py
+5
-5
lib/python/Shared/DC/ZRDB/Connection.py
lib/python/Shared/DC/ZRDB/Connection.py
+32
-2
lib/python/Shared/DC/ZRDB/connectionTestForm.dtml
lib/python/Shared/DC/ZRDB/connectionTestForm.dtml
+21
-0
No files found.
lib/python/Shared/DC/ZRDB/Aqueduct.py
View file @
83a58eff
##############################################################################
7
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
'''Shared classes and functions
$Id: Aqueduct.py,v 1.3
6 1999/07/21 19:43:39 michel
Exp $'''
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
$Id: Aqueduct.py,v 1.3
7 1999/09/21 15:43:18 jeffrey
Exp $'''
__version__
=
'$Revision: 1.3
7
$'
[
11
:
-
2
]
import
Globals
,
os
from
Globals
import
HTMLFile
,
Persistent
...
...
@@ -289,8 +289,8 @@ def custom_default_report(id, result, action='', no_table=0,
row
=
[]
for
c
in
columns
:
n
=
c
[
'name'
]
if
goofy
(
n
)
>=
0
:
n
=
'expr="_
vars
[
\
'
%s]"'
%
(
`'"'+n`
[
2
:])
row
.
append
(
' %s<
!--#var %s%s--
>%s'
if
goofy
(
n
)
>=
0
:
n
=
'expr="_[
\
'
%s]"'
%
(
`'"'+n`
[
2
:])
row
.
append
(
' %s<
dtml-var %s%s
>%s'
%
(
td
,
n
,
c
[
'type'
]
!=
's'
and
' null=""'
or
''
,
_td
))
row
=
(
' %s
\
n
%s
\
n
%s'
%
(
tr
,
string
.
joinfields
(
row
,
delim
),
_tr
))
...
...
lib/python/Shared/DC/ZRDB/Connection.py
View file @
83a58eff
...
...
@@ -85,14 +85,17 @@
__doc__
=
'''Generic Database Connection Support
$Id: Connection.py,v 1.1
8 1999/03/25 16:07:28 jim
Exp $'''
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
$Id: Connection.py,v 1.1
9 1999/09/21 15:43:18 jeffrey
Exp $'''
__version__
=
'$Revision: 1.1
9
$'
[
11
:
-
2
]
import
Globals
,
OFS
.
SimpleItem
,
AccessControl
.
Role
,
Acquisition
,
sys
from
DateTime
import
DateTime
from
App.Dialogs
import
MessageDialog
from
Globals
import
HTMLFile
from
string
import
find
,
join
,
split
from
Aqueduct
import
custom_default_report
from
Results
import
Results
import
DocumentTemplate
class
Connection
(
Globals
.
Persistent
,
...
...
@@ -105,6 +108,7 @@ class Connection(
manage_options
=
(
{
'label'
:
'Status'
,
'action'
:
'manage_main'
},
{
'label'
:
'Properties'
,
'action'
:
'manage_properties'
},
{
'label'
:
'Test'
,
'action'
:
'manage_testForm'
},
{
'label'
:
'Security'
,
'action'
:
'manage_access'
},
)
...
...
@@ -112,6 +116,7 @@ class Connection(
__ac_permissions__
=
(
(
'View management screens'
,
(
'manage_main'
,)),
(
'Change Database Connections'
,
(
'manage_edit'
,)),
(
'Test Database Connections'
,
(
'manage_testForm'
,
'manage_test'
)),
(
'Open/Close Database Connection'
,
(
'manage_open_connection'
,
'manage_close_connection'
)),
)
...
...
@@ -164,6 +169,31 @@ class Connection(
action
=
'./manage_main'
,
)
manage_testForm
=
HTMLFile
(
'connectionTestForm'
,
globals
())
def
manage_test
(
self
,
query
,
REQUEST
=
None
):
"Executes the SQL in parameter 'query' and returns results"
dbc
=
self
()
#get our connection
res
=
dbc
.
query
(
query
)
result
=
Results
(
res
)
if
REQUEST
is
None
:
return
result
#return unadulterated result objects
if
result
.
_searchable_result_columns
():
r
=
custom_default_report
(
self
.
id
,
result
)
else
:
r
=
'This was not a query.'
report
=
DocumentTemplate
.
HTML
(
'<html><body bgcolor="#ffffff" link="#000099" vlink="#555555">
\
n
'
'<dtml-var name="manage_tabs">
\
n
<hr>
\
n
%s
\
n
\
n
'
'<hr><h4>SQL Used:</strong><br>
\
n
<pre>
\
n
%s
\
n
</pre>
\
n
<hr>
\
n
'
'</body></html>'
%
(
r
,
query
))
report
=
apply
(
report
,(
self
,
REQUEST
),{
self
.
id
:
result
})
return
report
manage_main
=
HTMLFile
(
'connectionStatus'
,
globals
())
...
...
lib/python/Shared/DC/ZRDB/connectionTestForm.dtml
0 → 100644
View file @
83a58eff
<html>
<head><title>
Test
&dtml-title_or_id;
</title></head>
<body
bgcolor=
"#FFFFFF"
link=
"#000099"
vlink=
"#555555"
alink=
"#77003B"
>
<dtml-var
manage_tabs
>
<h2>
Test query on
<dtml-var
title_or_id
></h2>
<form
action=
"manage_test"
method=
"post"
>
<table
border=
"0"
>
<tr
valign=
"top"
>
<th
align=
"left"
>
Query:
</th>
<td><textarea
rows=
"10"
cols=
"60"
name=
"query:text"
wrap=
"off"
accesskey=
"e"
tabindex=
"1"
></textarea></td>
</tr>
<tr>
<th
align=
"left"
>
</th>
<td><input
type=
"submit"
value=
"Submit Query"
></td>
</tr>
</table>
</form>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment