mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 02:43:43 +03:00
Does not crash on importing needed modules. (Closes: #32)
This commit is contained in:
parent
164eb32817
commit
65fe7db04d
|
@ -1,3 +1,8 @@
|
|||
2005-11-15 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/psycopgmodule.c: now bails out with correct exception when one
|
||||
of the needed modules can't be imported (should fix #32.)
|
||||
|
||||
2005-11-14 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/typecast.c: added typecast_parse_date and typecast_parse_time
|
||||
|
|
|
@ -42,7 +42,6 @@ from psycopg2.extensions import INTEGER, LONGINTEGER, FLOAT, BOOLEAN, DATE
|
|||
from psycopg2.extensions import TIME, INTERVAL
|
||||
from psycopg2.extensions import new_type, register_type
|
||||
|
||||
|
||||
|
||||
# add a new connection to a folder
|
||||
|
||||
|
@ -56,17 +55,16 @@ def manage_addZPsycopgConnection(self, id, title, connection_string,
|
|||
zdatetime, check, tilevel))
|
||||
if REQUEST is not None: return self.manage_main(self, REQUEST)
|
||||
|
||||
|
||||
|
||||
# the connection object
|
||||
|
||||
class Connection(Shared.DC.ZRDB.Connection.Connection):
|
||||
"""ZPsycopg Connection."""
|
||||
"""ZPsycopg 2 Connection."""
|
||||
_isAnSQLConnection = 1
|
||||
|
||||
id = 'Psycopg_database_connection'
|
||||
database_type = 'Psycopg'
|
||||
meta_type = title = 'Z Psycopg Database Connection'
|
||||
id = 'Psycopg2_database_connection'
|
||||
database_type = 'Psycopg2'
|
||||
meta_type = title = 'Z Psycopg 2 Database Connection'
|
||||
icon = 'misc_/ZPsycopgDA/conn'
|
||||
|
||||
def __init__(self, id, title, connection_string,
|
||||
|
@ -187,7 +185,7 @@ class Connection(Shared.DC.ZRDB.Connection.Connection):
|
|||
|
||||
classes = (Connection,)
|
||||
|
||||
meta_types = ({'name':'Z Psycopg Database Connection',
|
||||
meta_types = ({'name':'Z Psycopg 2 Database Connection',
|
||||
'action':'manage_addZPsycopgConnectionForm'},)
|
||||
|
||||
folder_methods = {
|
||||
|
@ -195,7 +193,7 @@ folder_methods = {
|
|||
'manage_addZPsycopgConnectionForm': manage_addZPsycopgConnectionForm}
|
||||
|
||||
__ac_permissions__ = (
|
||||
('Add Z Psycopg Database Connections',
|
||||
('Add Z Psycopg 2 Database Connections',
|
||||
('manage_addZPsycopgConnectionForm', 'manage_addZPsycopgConnection')),)
|
||||
|
||||
# add icons
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#
|
||||
# See the LICENSE file for details.
|
||||
|
||||
__doc__ = "ZPsycopg Database Adalper Registration."
|
||||
__doc__ = "ZPsycopg 2 Database Adapter Registration."
|
||||
__version__ = '2.0'
|
||||
|
||||
import DA
|
||||
|
@ -27,12 +27,15 @@ classes = DA.classes
|
|||
meta_types = DA.meta_types
|
||||
misc_ = DA.misc_
|
||||
|
||||
__ac_permissions__=DA.__ac_permissions__
|
||||
__ac_permissions__ = DA.__ac_permissions__
|
||||
|
||||
def initialize(context):
|
||||
context.registerClass(
|
||||
DA.Connection,
|
||||
permission = 'Add Z Psycopg Database Connections',
|
||||
constructors = (DA.manage_addZPsycopgConnectionForm,
|
||||
DA.manage_addZPsycopgConnection),
|
||||
icon = SOFTWARE_HOME + '/Shared/DC/ZRDB/www/DBAdapterFolder_icon.gif')
|
||||
# FIXME: isn't this crazy? Apparently the variables above are enough
|
||||
# to have the ZPsycopgDA product installed and working. :/
|
||||
#
|
||||
#def initialize(context):
|
||||
# context.registerClass(
|
||||
# DA.Connection,
|
||||
# permission = 'Add Z Psycopg 2 Database Connections',
|
||||
# constructors = (DA.manage_addZPsycopgConnectionForm,
|
||||
# DA.manage_addZPsycopgConnection),
|
||||
# icon = SOFTWARE_HOME + '/Shared/DC/ZRDB/www/DBAdapterFolder_icon.gif')
|
||||
|
|
|
@ -484,7 +484,11 @@ init_psycopg(void)
|
|||
/* import python builtin datetime module, if available */
|
||||
#ifdef HAVE_PYDATETIME
|
||||
pyDateTimeModuleP = PyImport_ImportModule("datetime");
|
||||
|
||||
if (pyDateTimeModuleP == NULL) {
|
||||
Dprintf("initpsycopg: can't import datetime module");
|
||||
PyErr_SetString(PyExc_ImportError, "can't import datetime module");
|
||||
return;
|
||||
}
|
||||
pydatetimeType.ob_type = &PyType_Type;
|
||||
if (PyType_Ready(&pydatetimeType) == -1) return;
|
||||
|
||||
|
@ -498,6 +502,11 @@ init_psycopg(void)
|
|||
|
||||
/* import psycopg2.tz anyway (TODO: replace with C-level module?) */
|
||||
pyPsycopgTzModule = PyImport_ImportModule("psycopg2.tz");
|
||||
if (pyPsycopgTzModule == NULL) {
|
||||
Dprintf("initpsycopg: can't import psycopg2.tz module");
|
||||
PyErr_SetString(PyExc_ImportError, "can't import psycopg2.tz module");
|
||||
return;
|
||||
}
|
||||
pyPsycopgTzLOCAL =
|
||||
PyObject_GetAttrString(pyPsycopgTzModule, "LOCAL");
|
||||
pyPsycopgTzFixedOffsetTimezone =
|
||||
|
|
Loading…
Reference in New Issue
Block a user