Skip to content

Commit

Permalink
Merging with ZcxOracleDA v0.6 from google code http://code.google.com…
Browse files Browse the repository at this point in the history
…/p/z-cxoracle-da/. Not fully tested yet, please be careful as my initial version implementing bind variables had a different connection object storing oracle user/password outside ZODB to prevent from storing password in clear
  • Loading branch information
MordicusEtCubitus committed Jan 8, 2013
1 parent 2f65cdf commit 2aaa28a
Show file tree
Hide file tree
Showing 23 changed files with 1,908 additions and 0 deletions.
78 changes: 78 additions & 0 deletions DA.py
@@ -0,0 +1,78 @@
##############################################################################
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
database_type='cxOracle'
__doc__='''%s Database Connection''' % database_type
__version__='$Revision: 0.6 $'[11:-2]

from db import DB
import sys, DABase, os.path
from Globals import HTMLFile
from ImageFile import ImageFile
from ExtensionClass import Base

manage_addZcxOracleConnectionForm=HTMLFile('connectionAdd', globals())

def manage_addZcxOracleConnection(self, id, title,
connection_string,
check=None, REQUEST=None):
"""Add a cxOracle DB connection to a folder"""
self._setObject(id, Connection(
id, title, connection_string, check))
if REQUEST is not None: return self.manage_main(self, REQUEST)

class Connection(DABase.Connection):
" "
database_type = database_type
id='%s_database_connection' % database_type
meta_type=title='Z %s Database Connection' % database_type

manage_properties=HTMLFile('connectionEdit', globals())

# The TM that DB inherits from doesn't have a link back to its Connection,
# and so can't tell those above when it discovers that the connection has
# gone down, or when it has brought the connection back up again.
# This replacement factory returns a modified DB that has a link back to
# the Connection.
def _factory(self, connection):
ret = DB(connection)
ret._Connection = self
return ret

def factory(self):
return self._factory

classes=('DA.Connection',)

meta_types=(
{'name':'Z %s Database Connection' % database_type,
'action':'manage_addZ%sConnectionForm' % database_type,
},
)

folder_methods={
'manage_addZcxOracleConnection':
manage_addZcxOracleConnection,
'manage_addZcxOracleConnectionForm':
manage_addZcxOracleConnectionForm,
}

__ac_permissions__=(
('Add Z cxOracle Database Connections',
('manage_addZcxOracleConnectionForm',
'manage_addZcxOracleConnection')),
)


misc_={
'conn': ImageFile(
os.path.join('Shared','DC','ZRDB','www','DBAdapterFolder_icon.gif'))}

# vim:ts=4:sts=4:sw=4:expandtab
33 changes: 33 additions & 0 deletions DABase.py
@@ -0,0 +1,33 @@
##############################################################################
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__doc__='''Database Connection adaptor for cxOracle'''
__version__='$Revision: 0.6 $'[11:-2]

import Shared.DC.ZRDB.Connection, sys
from Globals import HTMLFile
from ImageFile import ImageFile
from ExtensionClass import Base
import Acquisition

class Connection(Shared.DC.ZRDB.Connection.Connection):
_isAnSQLConnection=1

manage_options=Shared.DC.ZRDB.Connection.Connection.manage_options

info=None

# No browsing for you....
def tpValues(self):
return []

def __getitem__(self, name):
raise KeyError, name

0 comments on commit 2aaa28a

Please sign in to comment.