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
Hide 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 @@
...
@@ -97,17 +97,17 @@
database_type
=
'Gadfly'
database_type
=
'Gadfly'
__doc__
=
'''%s Database Connection
__doc__
=
'''%s Database Connection
$Id: DA.py,v 1.
5 1998/12/16 15:28:47
jim Exp $'''
%
database_type
$Id: DA.py,v 1.
6 1998/12/17 18:48:36
jim Exp $'''
%
database_type
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
from
db
import
DB
,
manage_DataSources
from
db
import
DB
,
manage_DataSources
import
sys
,
DABase
,
Globals
import
sys
,
DABase
,
Globals
import
Shared.DC.ZRDB.Connection
_Connection
=
Shared
.
DC
.
ZRDB
.
Connection
.
Connection
_connections
=
{}
_connections
=
{}
def
data_sources
():
data_sources
=
manage_DataSources
return
filter
(
lambda
ds
,
used
=
_connections
.
has_key
:
not
used
(
ds
[
0
]),
manage_DataSources
())
addConnectionForm
=
Globals
.
HTMLFile
(
'connectionAdd'
,
globals
())
addConnectionForm
=
Globals
.
HTMLFile
(
'connectionAdd'
,
globals
())
def
manage_addZGadflyConnection
(
def
manage_addZGadflyConnection
(
...
@@ -122,28 +122,53 @@ class Connection(DABase.Connection):
...
@@ -122,28 +122,53 @@ class Connection(DABase.Connection):
" "
" "
database_type
=
database_type
database_type
=
database_type
id
=
'%s_database_connection'
%
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
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
):
def
connect
(
self
,
s
):
c
=
_connections
c
=
_connections
if
c
.
has_key
(
s
)
and
c
[
s
]
!=
self
.
_p_oid
:
if
c
.
has_key
(
s
):
raise
'In Use'
,
(
c
=
self
.
_v_database_connection
=
c
[
s
]
'The database <em>%s</em> is in use.'
%
s
)
if
not
c
.
opened
:
c
.
open
()
c
[
s
]
=
self
.
_p_oid
return
self
return
Connection
.
inheritedAttribute
(
'connect'
)(
self
,
s
)
def
__del__
(
self
):
try
:
s
=
self
.
connection_string
try
:
c
=
_connections
self
.
_v_database_connection
=
c
[
s
]
=
DB
(
s
)
if
c
.
has_key
(
s
)
and
c
[
s
]
==
self
.
_p_oid
:
del
c
[
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 @@
...
@@ -28,11 +28,12 @@
</tr>
</tr>
<tr>
<tr>
<td
align=
"LEFT"
valign=
"TOP"
><strong>
Select a Data Source
</strong>
<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
directories in the
<code>
var/gadfly
</code>
subdirectory of
your Principia installation.
</font></em>
your Principia installation.
</font></em>
</td>
</td>
<td
align=
"LEFT"
valign=
"TOP"
><select
name=
connection
size=
7
>
<td
align=
"LEFT"
valign=
"TOP"
><select
name=
connection
size=
5
>
<!--#in data_sources-->
<!--#in data_sources-->
<option
value=
"<!--#var sequence-key-->"
>
<option
value=
"<!--#var sequence-key-->"
>
<!--#var sequence-key--><!--#if
<!--#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 @@
...
@@ -95,13 +95,14 @@
#
#
##############################################################################
##############################################################################
'''$Id: db.py,v 1.
4 1998/12/16 15:28:47
jim Exp $'''
'''$Id: db.py,v 1.
5 1998/12/17 18:48:36
jim Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
string
,
sys
,
os
import
os
from
string
import
strip
,
split
,
find
,
join
from
string
import
strip
,
split
from
gadfly
import
gadfly
from
gadfly
import
gadfly
import
Globals
import
Globals
from
DateTime
import
DateTime
data_dir
=
os
.
path
.
join
(
Globals
.
data_dir
,
'gadfly'
)
data_dir
=
os
.
path
.
join
(
Globals
.
data_dir
,
'gadfly'
)
...
@@ -136,20 +137,24 @@ def manage_DataSources():
...
@@ -136,20 +137,24 @@ def manage_DataSources():
class
DB
:
class
DB
:
database_error
=
gadfly
.
error
database_error
=
gadfly
.
error
opened
=
''
def
tables
(
self
,
*
args
,
**
kw
):
def
tables
(
self
,
*
args
,
**
kw
):
if
self
.
db
is
None
:
self
.
open
()
return
map
(
lambda
name
:
{
return
map
(
lambda
name
:
{
'TABLE_NAME'
:
name
,
'TABLE_NAME'
:
name
,
'TABLE_TYPE'
:
'TABLE'
,
'TABLE_TYPE'
:
'TABLE'
,
},
self
.
db
.
table_names
())
},
self
.
db
.
table_names
())
def
columns
(
self
,
table_name
):
def
columns
(
self
,
table_name
):
if
self
.
db
is
None
:
self
.
open
()
return
map
(
lambda
col
:
{
return
map
(
lambda
col
:
{
'Name'
:
col
.
colid
,
'Type'
:
col
.
datatype
,
'Precision'
:
0
,
'Name'
:
col
.
colid
,
'Type'
:
col
.
datatype
,
'Precision'
:
0
,
'Scale'
:
0
,
'Nullable'
:
'with Null'
'Scale'
:
0
,
'Nullable'
:
'with Null'
},
self
.
db
.
database
.
datadefs
[
table_name
].
colelts
)
},
self
.
db
.
database
.
datadefs
[
table_name
].
colelts
)
def
__init__
(
self
,
connection
):
def
open
(
self
):
connection
=
self
.
connection
path
=
os
.
path
path
=
os
.
path
dir
=
path
.
join
(
data_dir
,
connection
)
dir
=
path
.
join
(
data_dir
,
connection
)
if
not
path
.
isdir
(
dir
):
if
not
path
.
isdir
(
dir
):
...
@@ -159,45 +164,57 @@ class DB:
...
@@ -159,45 +164,57 @@ class DB:
db
=
gadfly
.
gadfly
()
db
=
gadfly
.
gadfly
()
db
.
startup
(
connection
,
dir
)
db
.
startup
(
connection
,
dir
)
else
:
db
=
gadfly
.
gadfly
(
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
.
connection
=
connection
self
.
db
=
db
self
.
open
()
self
.
cursor
=
db
.
cursor
()
def
query
(
self
,
query_string
,
max_rows
=
9999999
):
def
query
(
self
,
query_string
,
max_rows
=
9999999
):
if
self
.
db
is
None
:
self
.
open
()
self
.
_register
()
self
.
_register
()
c
=
self
.
db
.
cursor
()
c
=
self
.
db
.
cursor
()
queries
=
filter
(
None
,
map
(
strip
,
split
(
query_string
,
'
\
0
'
)))
queries
=
filter
(
None
,
map
(
strip
,
split
(
query_string
,
'
\
0
'
)))
if
not
queries
:
raise
'Query Error'
,
'empty query'
if
not
queries
:
raise
'Query Error'
,
'empty query'
names
=
None
desc
=
None
result
=
'cool
\
n
s
\
n
'
result
=
[]
for
qs
in
queries
:
for
qs
in
queries
:
c
.
execute
(
qs
)
c
.
execute
(
qs
)
d
=
c
.
description
d
=
c
.
description
if
d
is
None
:
continue
if
d
is
None
:
continue
if
names
is
not
None
:
if
desc
is
None
:
desc
=
d
elif
d
!=
desc
:
raise
'Query Error'
,
(
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
)
if
not
result
:
result
=
c
.
fetchmany
(
max_rows
)
nv
=
len
(
names
)
elif
len
(
result
)
<
max_rows
:
indexes
=
range
(
nv
)
result
=
result
+
c
.
fetchmany
(
max_rows
-
len
(
result
))
row
=
[
''
]
*
nv
defs
=
[
maybe_int
]
*
nv
if
desc
is
None
:
return
(),()
j
=
join
rdb
=
[
j
(
names
,
'
\
t
'
),
None
]
items
=
[]
append
=
rdb
.
append
for
name
,
type
,
width
,
ds
,
p
,
scale
,
null_ok
in
desc
:
for
result
in
results
:
if
type
==
'NUMBER'
:
for
i
in
indexes
:
if
scale
==
0
:
type
=
'i'
try
:
row
[
i
]
=
defs
[
i
](
result
[
i
])
else
:
type
=
'n'
except
NewType
,
v
:
row
[
i
],
defs
[
i
]
=
v
elif
type
==
'DATE'
:
append
(
j
(
row
,
'
\
t
'
))
type
=
'd'
rdb
[
1
]
=
j
(
map
(
lambda
d
,
Defs
=
Defs
:
Defs
[
d
],
defs
),
'
\
t
'
)
else
:
type
=
's'
rdb
.
append
(
''
)
items
.
append
({
result
=
j
(
rdb
,
'
\
n
'
)
'name'
:
name
,
'type'
:
type
,
return
result
'width'
:
width
,
'null'
:
null_ok
,
})
return
items
,
result
class
_p_jar
:
class
_p_jar
:
# This is place holder for new transaction machinery 2pc
# This is place holder for new transaction machinery 2pc
...
@@ -223,35 +240,3 @@ class DB:
...
@@ -223,35 +240,3 @@ class DB:
self
.
db
.
rollback
()
self
.
db
.
rollback
()
self
.
db
.
checkpoint
()
self
.
db
.
checkpoint
()
self
.
_registered
=
0
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 @@
...
@@ -97,8 +97,8 @@
__doc__
=
'''SQL Methods
__doc__
=
'''SQL Methods
$Id: SQL.py,v 1.
8 1998/12/16 15:29:22
jim Exp $'''
$Id: SQL.py,v 1.
9 1998/12/17 18:49:09
jim Exp $'''
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
Shared.DC.ZRDB.DA
import
Shared.DC.ZRDB.DA
from
Globals
import
HTMLFile
from
Globals
import
HTMLFile
...
@@ -133,7 +133,7 @@ def SQLConnectionIDs(self):
...
@@ -133,7 +133,7 @@ def SQLConnectionIDs(self):
manage_addZSQLMethodForm
=
HTMLFile
(
'add'
,
globals
())
manage_addZSQLMethodForm
=
HTMLFile
(
'add'
,
globals
())
def
manage_addZSQLMethod
(
self
,
id
,
title
,
def
manage_addZSQLMethod
(
self
,
id
,
title
,
connection_id
,
arguments
,
template
,
connection_id
,
arguments
,
template
,
REQUEST
=
None
):
REQUEST
=
None
,
submit
=
None
):
"""Add an SQL Method
"""Add an SQL Method
The 'connection_id' argument is the id of a database connection
The 'connection_id' argument is the id of a database connection
...
@@ -147,7 +147,17 @@ def manage_addZSQLMethod(self, id, title,
...
@@ -147,7 +147,17 @@ def manage_addZSQLMethod(self, id, title,
SQL Template.
SQL Template.
"""
"""
self
.
_setObject
(
id
,
SQL
(
id
,
title
,
connection_id
,
arguments
,
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
):
class
SQL
(
Shared
.
DC
.
ZRDB
.
DA
.
DA
):
"""SQL Database methods
"""SQL Database methods
...
...
lib/python/Products/ZSQLMethods/add.dtml
View file @
8982f867
...
@@ -27,8 +27,11 @@
...
@@ -27,8 +27,11 @@
<textarea name="template:text" rows=9 cols=50>select *
<textarea name="template:text" rows=9 cols=50>select *
from data</textarea></td></tr>
from data</textarea></td></tr>
<tr><td><input type="hidden" name="key" value=""></td><td>
<tr><td colspan=2>
<input type="SUBMIT" name="SUBMIT" value="Add">
<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>
</td></tr>
</table>
</table>
...
...
lib/python/Products/ZSQLMethods/edit.dtml
View file @
8982f867
...
@@ -53,10 +53,10 @@
...
@@ -53,10 +53,10 @@
src fmt=html-quote--></textarea></td></tr>
src fmt=html-quote--></textarea></td></tr>
<tr>
<tr>
<TD align=left>
<TD
colspan=2
align=left>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
</TD
>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change and Test"
>
<TD align=left
>
<br
>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider">
<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