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
8982f867
Commit
8982f867
authored
Dec 17, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many changes in reponse to preview feedback
parent
56634f91
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
179 additions
and
128 deletions
+179
-128
lib/python/Products/ZGadflyDA/CHANGES.txt
lib/python/Products/ZGadflyDA/CHANGES.txt
+0
-32
lib/python/Products/ZGadflyDA/DA.py
lib/python/Products/ZGadflyDA/DA.py
+48
-23
lib/python/Products/ZGadflyDA/connectionAdd.dtml
lib/python/Products/ZGadflyDA/connectionAdd.dtml
+3
-2
lib/python/Products/ZGadflyDA/connectionEdit.dtml
lib/python/Products/ZGadflyDA/connectionEdit.dtml
+59
-0
lib/python/Products/ZGadflyDA/db.py
lib/python/Products/ZGadflyDA/db.py
+47
-62
lib/python/Products/ZSQLMethods/SQL.py
lib/python/Products/ZSQLMethods/SQL.py
+14
-4
lib/python/Products/ZSQLMethods/add.dtml
lib/python/Products/ZSQLMethods/add.dtml
+5
-2
lib/python/Products/ZSQLMethods/edit.dtml
lib/python/Products/ZSQLMethods/edit.dtml
+3
-3
No files found.
lib/python/Products/ZGadflyDA/CHANGES.txt
deleted
100755 → 0
View file @
56634f91
Aqueduct Gadfly Changes
-----------------------
AqueductGadfly 1.1.2
Bugs fixed
- Connection objects became unpublishable.
AqueductGadfly 1.1.1
Bugs fixed
- The management screens for connection objects were
inaccessible.
- The non-working "Design" was included in the management interface.
AqueductGadfly 1.1
Features Added
- Added permission for adding Gadfly database connections.
- The Gadfly Database Adapter Databases are stored in the
'var/gadfly' directory of the Principia installation. If this
directory doesn't exist, it is automatically created, as is a
'demo' database.
- Some descriptive information, as well as the Gadfly copyright
notice have been added to the add-connection interface.
lib/python/Products/ZGadflyDA/DA.py
View file @
8982f867
...
...
@@ -97,17 +97,17 @@
database_type
=
'Gadfly'
__doc__
=
'''%s Database Connection
$Id: DA.py,v 1.
5 1998/12/16 15:28:47
jim Exp $'''
%
database_type
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
$Id: DA.py,v 1.
6 1998/12/17 18:48:36
jim Exp $'''
%
database_type
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
from
db
import
DB
,
manage_DataSources
import
sys
,
DABase
,
Globals
import
Shared.DC.ZRDB.Connection
_Connection
=
Shared
.
DC
.
ZRDB
.
Connection
.
Connection
_connections
=
{}
def
data_sources
():
return
filter
(
lambda
ds
,
used
=
_connections
.
has_key
:
not
used
(
ds
[
0
]),
manage_DataSources
())
data_sources
=
manage_DataSources
addConnectionForm
=
Globals
.
HTMLFile
(
'connectionAdd'
,
globals
())
def
manage_addZGadflyConnection
(
...
...
@@ -122,28 +122,53 @@ class Connection(DABase.Connection):
" "
database_type
=
database_type
id
=
'%s_database_connection'
%
database_type
meta_type
=
title
=
'Z
ope
%s Database Connection'
%
database_type
meta_type
=
title
=
'Z %s Database Connection'
%
database_type
icon
=
'misc_/Z%sDA/conn'
%
database_type
def
factory
(
self
):
return
DB
manage_properties
=
Globals
.
HTMLFile
(
'connectionEdit'
,
globals
(),
data_sources
=
data_sources
)
def
connected
(
self
):
if
hasattr
(
self
,
'_v_database_connection'
):
return
self
.
_v_database_connection
.
opened
return
''
def
title_and_id
(
self
):
s
=
_Connection
.
inheritedAttribute
(
'title_and_id'
)(
self
)
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
self
.
_v_database_connection
.
opened
):
s
=
"%s, which is connected"
%
s
else
:
s
=
"%s, which is <font color=red> not connected</font>"
%
s
return
s
def
title_or_id
(
self
):
s
=
_Connection
.
inheritedAttribute
(
'title_and_id'
)(
self
)
if
(
hasattr
(
self
,
'_v_database_connection'
)
and
self
.
_v_database_connection
.
opened
):
s
=
"%s (connected)"
%
s
else
:
s
=
"%s (<font color=red> not connected</font>)"
%
s
return
s
def
connect
(
self
,
s
):
c
=
_connections
if
c
.
has_key
(
s
)
and
c
[
s
]
!=
self
.
_p_oid
:
raise
'In Use'
,
(
'The database <em>%s</em> is in use.'
%
s
)
c
[
s
]
=
self
.
_p_oid
return
Connection
.
inheritedAttribute
(
'connect'
)(
self
,
s
)
if
c
.
has_key
(
s
):
c
=
self
.
_v_database_connection
=
c
[
s
]
if
not
c
.
opened
:
c
.
open
()
return
self
def
__del__
(
self
):
s
=
self
.
connection_string
c
=
_connections
if
c
.
has_key
(
s
)
and
c
[
s
]
==
self
.
_p_oid
:
del
c
[
s
]
try
:
try
:
self
.
_v_database_connection
=
c
[
s
]
=
DB
(
s
)
except
:
t
,
v
,
tb
=
sys
.
exc_info
()
raise
'BadRequest'
,
(
'<strong>Invalid connection string: </strong>'
'<CODE>%s</CODE><br>
\
n
'
'<!--
\
n
%s
\
n
%s
\
n
-->
\
n
'
%
(
s
,
t
,
v
)),
tb
finally
:
tb
=
None
return
self
def
manage_close_connection
(
self
,
REQUEST
):
" "
s
=
self
.
connection_string
c
=
_connections
if
c
.
has_key
(
s
)
and
c
[
s
]
==
self
.
_p_oid
:
del
c
[
s
]
return
Connection
.
inheritedAttribute
(
'manage_close_connection'
)(
self
,
REQUEST
)
lib/python/Products/ZGadflyDA/connectionAdd.dtml
View file @
8982f867
...
...
@@ -28,11 +28,12 @@
</tr>
<tr>
<td
align=
"LEFT"
valign=
"TOP"
><strong>
Select a Data Source
</strong>
<br><em><font
-1
>
Additional data sources may be created by making additional
<br><em><font
-1
>
Additional data sources may be created by making additional
directories in the
<code>
var/gadfly
</code>
subdirectory of
your Principia installation.
</font></em>
</td>
<td
align=
"LEFT"
valign=
"TOP"
><select
name=
connection
size=
7
>
<td
align=
"LEFT"
valign=
"TOP"
><select
name=
connection
size=
5
>
<!--#in data_sources-->
<option
value=
"<!--#var sequence-key-->"
>
<!--#var sequence-key--><!--#if
...
...
lib/python/Products/ZGadflyDA/connectionEdit.dtml
0 → 100644
View file @
8982f867
<html>
<head><title>
Edit
<!--#var title_or_id-->
</title></head>
<body
bgcolor=
"#FFFFFF"
link=
"#000099"
vlink=
"#555555"
alink=
"#77003B"
>
<!--#var manage_tabs-->
<h2>
Edit
<!--#var title_or_id-->
</h2>
<form
action=
"manage_edit"
method=
"POST"
>
<table
cellspacing=
"2"
>
<tr>
<th
align=
"LEFT"
valign=
"TOP"
>
Id
</th>
<td
align=
"LEFT"
valign=
"TOP"
>
<!--#var id-->
</td>
</tr>
<tr>
<th
align=
"LEFT"
valign=
"TOP"
><em>
Title
</em></th>
<td
align=
"LEFT"
valign=
"TOP"
>
<input
type=
"TEXT"
name=
"title"
size=
"40"
value=
"<!--#var title-->"
>
</td>
</tr>
<tr>
<td
align=
"LEFT"
valign=
"TOP"
><strong>
Select a Data Source
</strong>
<br><em><font
-1
>
Additional data sources may be created by making additional
directories in the
<code>
var/gadfly
</code>
subdirectory of
your Principia installation.
</font></em>
</td>
<td
align=
"LEFT"
valign=
"TOP"
><select
name=
connection_string
size=
5
>
<!--#in data_sources-->
<option
value=
"<!--#var sequence-key-->"
<!
--#if
"
_
['
sequence-key
'
]=
=connection_string"--
>
SELECTED
<!--#/if-->
>
<!--#var sequence-key--><!--#if
sequence-item-->
,
<!--#var sequence-item--><!--#/if-->
</option-->
<!--#/in-->
</select></td>
</tr>
<tr>
<th
align=
"LEFT"
valign=
"TOP"
>
Connect immediately
</th>
<td
align=
"LEFT"
valign=
"TOP"
>
<input
name=
"check"
type=
"CHECKBOX"
value=
"YES"
CHECKED
>
</td>
</tr>
<tr>
<td></td>
<td><br><input
type=
"SUBMIT"
value=
"Change"
></td>
</tr>
</table>
</form>
</body>
</html>
lib/python/Products/ZGadflyDA/db.py
View file @
8982f867
...
...
@@ -95,13 +95,14 @@
#
##############################################################################
'''$Id: db.py,v 1.
4 1998/12/16 15:28:47
jim Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
'''$Id: db.py,v 1.
5 1998/12/17 18:48:36
jim Exp $'''
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
string
,
sys
,
os
from
string
import
strip
,
split
,
find
,
join
import
os
from
string
import
strip
,
split
from
gadfly
import
gadfly
import
Globals
from
DateTime
import
DateTime
data_dir
=
os
.
path
.
join
(
Globals
.
data_dir
,
'gadfly'
)
...
...
@@ -136,20 +137,24 @@ def manage_DataSources():
class
DB
:
database_error
=
gadfly
.
error
opened
=
''
def
tables
(
self
,
*
args
,
**
kw
):
if
self
.
db
is
None
:
self
.
open
()
return
map
(
lambda
name
:
{
'TABLE_NAME'
:
name
,
'TABLE_TYPE'
:
'TABLE'
,
},
self
.
db
.
table_names
())
def
columns
(
self
,
table_name
):
if
self
.
db
is
None
:
self
.
open
()
return
map
(
lambda
col
:
{
'Name'
:
col
.
colid
,
'Type'
:
col
.
datatype
,
'Precision'
:
0
,
'Scale'
:
0
,
'Nullable'
:
'with Null'
},
self
.
db
.
database
.
datadefs
[
table_name
].
colelts
)
def
__init__
(
self
,
connection
):
def
open
(
self
):
connection
=
self
.
connection
path
=
os
.
path
dir
=
path
.
join
(
data_dir
,
connection
)
if
not
path
.
isdir
(
dir
):
...
...
@@ -159,45 +164,57 @@ class DB:
db
=
gadfly
.
gadfly
()
db
.
startup
(
connection
,
dir
)
else
:
db
=
gadfly
.
gadfly
(
connection
,
dir
)
self
.
db
=
db
self
.
opened
=
DateTime
()
def
close
(
self
):
self
.
db
=
None
del
self
.
opened
def
__init__
(
self
,
connection
):
self
.
connection
=
connection
self
.
db
=
db
self
.
cursor
=
db
.
cursor
()
self
.
open
()
def
query
(
self
,
query_string
,
max_rows
=
9999999
):
if
self
.
db
is
None
:
self
.
open
()
self
.
_register
()
c
=
self
.
db
.
cursor
()
queries
=
filter
(
None
,
map
(
strip
,
split
(
query_string
,
'
\
0
'
)))
if
not
queries
:
raise
'Query Error'
,
'empty query'
names
=
None
result
=
'cool
\
n
s
\
n
'
desc
=
None
result
=
[]
for
qs
in
queries
:
c
.
execute
(
qs
)
d
=
c
.
description
if
d
is
None
:
continue
if
names
is
not
None
:
if
desc
is
None
:
desc
=
d
elif
d
!=
desc
:
raise
'Query Error'
,
(
'select in multiple sql-statement query'
'Multiple incompatible selects in '
'multiple sql-statement query'
)
names
=
map
(
lambda
d
:
d
[
0
],
d
)
results
=
c
.
fetchmany
(
max_rows
)
nv
=
len
(
names
)
indexes
=
range
(
nv
)
row
=
[
''
]
*
nv
defs
=
[
maybe_int
]
*
nv
j
=
join
rdb
=
[
j
(
names
,
'
\
t
'
),
None
]
append
=
rdb
.
append
for
result
in
results
:
for
i
in
indexes
:
try
:
row
[
i
]
=
defs
[
i
](
result
[
i
])
except
NewType
,
v
:
row
[
i
],
defs
[
i
]
=
v
append
(
j
(
row
,
'
\
t
'
))
rdb
[
1
]
=
j
(
map
(
lambda
d
,
Defs
=
Defs
:
Defs
[
d
],
defs
),
'
\
t
'
)
rdb
.
append
(
''
)
result
=
j
(
rdb
,
'
\
n
'
)
return
result
if
not
result
:
result
=
c
.
fetchmany
(
max_rows
)
elif
len
(
result
)
<
max_rows
:
result
=
result
+
c
.
fetchmany
(
max_rows
-
len
(
result
))
if
desc
is
None
:
return
(),()
items
=
[]
for
name
,
type
,
width
,
ds
,
p
,
scale
,
null_ok
in
desc
:
if
type
==
'NUMBER'
:
if
scale
==
0
:
type
=
'i'
else
:
type
=
'n'
elif
type
==
'DATE'
:
type
=
'd'
else
:
type
=
's'
items
.
append
({
'name'
:
name
,
'type'
:
type
,
'width'
:
width
,
'null'
:
null_ok
,
})
return
items
,
result
class
_p_jar
:
# This is place holder for new transaction machinery 2pc
...
...
@@ -223,35 +240,3 @@ class DB:
self
.
db
.
rollback
()
self
.
db
.
checkpoint
()
self
.
_registered
=
0
NewType
=
"Excecption to raise when sniffing types, blech"
def
maybe_int
(
v
,
int_type
=
type
(
0
),
float_type
=
type
(
0.0
),
t
=
type
):
t
=
t
(
v
)
if
t
is
int_type
:
return
str
(
v
)
if
v
is
None
or
v
==
''
:
return
''
if
t
is
float_type
:
raise
NewType
,
(
maybe_float
(
v
),
maybe_float
)
raise
NewType
,
(
maybe_string
(
v
),
maybe_string
)
def
maybe_float
(
v
,
int_type
=
type
(
0
),
float_type
=
type
(
0.0
),
t
=
type
):
t
=
t
(
v
)
if
t
is
int_type
or
t
is
float_type
:
return
str
(
v
)
if
v
is
None
or
v
==
''
:
return
''
raise
NewType
,
(
maybe_string
(
v
),
maybe_string
)
def
maybe_string
(
v
):
v
=
str
(
v
)
if
find
(
v
,
'
\
t
'
)
>=
0
or
find
(
v
,
'
\
t
'
):
raise
NewType
,
(
must_be_text
(
v
),
must_be_text
)
return
v
def
must_be_text
(
v
,
f
=
find
,
j
=
join
,
s
=
split
):
if
f
(
v
,
'
\
\
'
):
v
=
j
(
s
(
v
,
'
\
\
'
),
'
\
\
\
\
'
)
v
=
j
(
s
(
v
,
'
\
t
'
),
'
\
\
t'
)
v
=
j
(
s
(
v
,
'
\
n
'
),
'
\
\
n'
)
return
v
Defs
=
{
maybe_int
:
'i'
,
maybe_float
:
'n'
,
maybe_string
:
's'
,
must_be_text
:
't'
}
lib/python/Products/ZSQLMethods/SQL.py
View file @
8982f867
...
...
@@ -97,8 +97,8 @@
__doc__
=
'''SQL Methods
$Id: SQL.py,v 1.
8 1998/12/16 15:29:22
jim Exp $'''
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
$Id: SQL.py,v 1.
9 1998/12/17 18:49:09
jim Exp $'''
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
Shared.DC.ZRDB.DA
from
Globals
import
HTMLFile
...
...
@@ -133,7 +133,7 @@ def SQLConnectionIDs(self):
manage_addZSQLMethodForm
=
HTMLFile
(
'add'
,
globals
())
def
manage_addZSQLMethod
(
self
,
id
,
title
,
connection_id
,
arguments
,
template
,
REQUEST
=
None
):
REQUEST
=
None
,
submit
=
None
):
"""Add an SQL Method
The 'connection_id' argument is the id of a database connection
...
...
@@ -147,7 +147,17 @@ def manage_addZSQLMethod(self, id, title,
SQL Template.
"""
self
.
_setObject
(
id
,
SQL
(
id
,
title
,
connection_id
,
arguments
,
template
))
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
if
REQUEST
is
not
None
:
u
=
REQUEST
[
'URL1'
]
if
submit
==
" Add and Edit "
:
u
=
"%s/%s/manage_main"
%
(
u
,
id
)
elif
submit
==
" Add and Test "
:
u
=
"%s/%s/manage_testForm"
%
(
u
,
id
)
else
:
u
=
u
+
'/manage_main'
REQUEST
.
RESPONSE
.
redirect
(
u
)
return
''
class
SQL
(
Shared
.
DC
.
ZRDB
.
DA
.
DA
):
"""SQL Database methods
...
...
lib/python/Products/ZSQLMethods/add.dtml
View file @
8982f867
...
...
@@ -27,8 +27,11 @@
<textarea name="template:text" rows=9 cols=50>select *
from data</textarea></td></tr>
<tr><td><input type="hidden" name="key" value=""></td><td>
<input type="SUBMIT" name="SUBMIT" value="Add">
<tr><td colspan=2>
<input type="hidden" name="key" value="">
<input type="SUBMIT" name="submit" value=" Add ">
<input type="SUBMIT" name="submit" value=" Add and Edit ">
<input type="SUBMIT" name="submit" value=" Add and Test ">
</td></tr>
</table>
...
...
lib/python/Products/ZSQLMethods/edit.dtml
View file @
8982f867
...
...
@@ -53,10 +53,10 @@
src fmt=html-quote--></textarea></td></tr>
<tr>
<TD align=left>
<TD
colspan=2
align=left>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
</TD
>
<TD align=left
>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change and Test"
>
<br
>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider">
...
...
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