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
6f8fe146
Commit
6f8fe146
authored
Dec 02, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parent
703f905d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
lib/python/Shared/DC/ZRDB/Connection.py
lib/python/Shared/DC/ZRDB/Connection.py
+97
-0
No files found.
lib/python/Shared/DC/ZRDB/Connection.py
0 → 100644
View file @
6f8fe146
##############################################################################
#
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
#
##############################################################################
__doc__
=
'''Generic Database Connection Support
$Id: Connection.py,v 1.1 1997/12/02 17:22:02 jim Exp $'''
__version__
=
'$Revision: 1.1 $'
[
11
:
-
2
]
import
Globals
,
OFS
.
SimpleItem
,
AccessControl
.
Role
,
Persistence
,
Acquisition
from
DateTime
import
DateTime
connection_page
=
Globals
.
HTMLFile
(
'AqueductDA/connection'
)
def
addForm
(
self
,
REQUEST
,
database_type
):
return
connection_page
(
self
,
REQUEST
,
action
=
'manage_addAqueduct%sConnection'
%
database_type
,
database_type
=
database_type
,
connection_string
=
''
,
connected
=
''
)
def
add
(
self
,
class_
,
connection_string
,
check
,
REQUEST
):
"""Add a new Folder object"""
i
=
class_
()
i
.
connection_string
=
connection_string
if
check
:
i
.
connect
(
connection_string
)
self
.
_setObject
(
i
.
id
,
i
)
return
self
.
manage_main
(
self
,
REQUEST
)
class
Connection
(
Persistence
.
Persistent
,
AccessControl
.
Role
.
RoleManager
,
OFS
.
SimpleItem
.
Item
,
Acquisition
.
Implicit
,
):
icon
=
'AqueductDA/DBAdapterFolder_icon.gif'
meta_type
=
'Aqueduct Database Adapter Folder'
_v_connected
=
''
connection_string
=
''
def
manage
(
self
,
REQUEST
):
"Change the database connection string"
return
connection_page
(
self
,
REQUEST
,
action
=
'manage_connection'
,
database_type
=
self
.
database_type
)
def
connected
(
self
):
return
self
.
_v_connected
def
manage_connection
(
self
,
value
,
check
=
None
,
action
=
''
,
REQUEST
=
None
):
'change database connection data'
if
check
:
self
.
connect
(
value
)
else
:
self
.
manage_close_connection
(
REQUEST
)
self
.
connection_string
=
value
return
'This needs to be changed'
def
manage_close_connection
(
self
,
REQUEST
):
" "
try
:
self
.
_v_database_connection
.
close
()
except
:
pass
self
.
_v_connected
=
''
return
'This needs to be changed'
def
__call__
(
self
,
v
=
None
):
try
:
return
self
.
_v_database_connection
except
AttributeError
:
s
=
self
.
connection_string
if
s
:
return
self
.
connect
(
s
)
raise
'Database Not Connected'
,(
'''The database connection is not connected'''
)
def
connect
(
self
,
s
):
try
:
self
.
_v_database_connection
.
close
()
except
:
pass
self
.
_v_connected
=
''
DB
=
self
.
factory
()
try
:
self
.
_v_database_connection
=
DB
(
s
)
except
:
raise
'BadRequest'
,
(
'<strong>Invalid connection string:</strong><br>'
+
s
)
self
.
_v_connected
=
DateTime
()
return
self
##############################################################################
#
# $Log: Connection.py,v $
# Revision 1.1 1997/12/02 17:22:02 jim
# initial
#
#
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