2004-10-29 20:15:45 +04:00
|
|
|
|
# ZPsycopgDA/DABase.py - ZPsycopgDA Zope product: Database inspection
|
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2004 Federico Di Gregorio <fog@initd.org>
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the
|
|
|
|
|
# Free Software Foundation; either version 2, or (at your option) any later
|
|
|
|
|
# version.
|
|
|
|
|
#
|
|
|
|
|
# Or, at your option this program (ZPsycopgDA) can be distributed under the
|
|
|
|
|
# Zope Public License (ZPL) Version 1.0, as published on the Zope web site,
|
|
|
|
|
# http://www.zope.org/Resources/ZPL.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
#
|
|
|
|
|
# See the LICENSE file for details.
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
import Shared.DC.ZRDB.Connection
|
|
|
|
|
|
|
|
|
|
from db import DB
|
|
|
|
|
from Globals import HTMLFile
|
|
|
|
|
from ImageFile import ImageFile
|
|
|
|
|
from ExtensionClass import Base
|
|
|
|
|
from DateTime import DateTime
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
# import psycopg and functions/singletons needed for date/time conversions
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
import psycopg
|
|
|
|
|
from psycopg.extensions import INTEGER, LONGINTEGER, FLOAT, BOOLEAN
|
|
|
|
|
from psycopg import NUMBER, STRING, ROWID, DATETIME
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
|
|
|
|
class Connection(Shared.DC.ZRDB.Connection.Connection):
|
|
|
|
|
_isAnSQLConnection = 1
|
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
info = None
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
#manage_options = Shared.DC.ZRDB.Connection.Connection.manage_options + (
|
|
|
|
|
# {'label': 'Browse', 'action':'manage_browse'},)
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
#manage_tables = HTMLFile('tables', globals())
|
|
|
|
|
#manage_browse = HTMLFile('browse',globals())
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
|
|
|
|
def __getitem__(self, name):
|
2004-10-29 20:15:45 +04:00
|
|
|
|
if name == 'tableNamed':
|
2004-10-19 07:17:12 +04:00
|
|
|
|
if not hasattr(self, '_v_tables'): self.tpValues()
|
|
|
|
|
return self._v_tables.__of__(self)
|
|
|
|
|
raise KeyError, name
|
|
|
|
|
|
2004-10-29 20:15:45 +04:00
|
|
|
|
|
|
|
|
|
## old stuff from ZPsycopgDA 1.1 (never implemented) ##
|
|
|
|
|
|
2004-10-19 07:17:12 +04:00
|
|
|
|
def manage_wizard(self, tables):
|
2004-10-29 20:15:45 +04:00
|
|
|
|
"Wizard of what? Oozing?"
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
|
|
|
|
def manage_join(self, tables, select_cols, join_cols, REQUEST=None):
|
|
|
|
|
"""Create an SQL join"""
|
|
|
|
|
|
|
|
|
|
def manage_insert(self, table, cols, REQUEST=None):
|
|
|
|
|
"""Create an SQL insert"""
|
|
|
|
|
|
|
|
|
|
def manage_update(self, table, keys, cols, REQUEST=None):
|
|
|
|
|
"""Create an SQL update"""
|