Ejemplo n.º 1
0
def manage_addZSQLiteConnection(self,
                                id: str,
                                title: str,
                                data_dir: str,
                                connection: str = '',
                                REQUEST=None) -> 'manage_main':
    """Add a DB connection to a folder"""

    db_path = os.path.join(data_dir, connection)

    if not id:
        return MessageDialog(
            title='Edited',
            message='Please provide an id for the database adapter!',
            action='javascript:history.back()')

    try:
        check_database(dbpath=db_path)
    except sqlite3_OperationalError as e:
        return MessageDialog(title='Edited',
                             message=extract_error(e),
                             action='javascript:history.back()')
    # Note - ZSQLiteDA's connect immediately check is alway false
    self._setObject(id, Connection(id, title, connection, REQUEST))
    if REQUEST is not None:
        return self.manage_main(self, REQUEST)
Ejemplo n.º 2
0
def manage_addZSQLiteConnection(self, id, title, connection, REQUEST=None):
    """Add a DB connection to a folder"""

    # Note - ZSQLiteDA's connect immediately check is alway false
    self._setObject(id, Connection(id, title, connection, None))
    if REQUEST is not None:
        return self.manage_main(self, REQUEST)
Ejemplo n.º 3
0
def manage_addZPsycopgConnection(self, id, title, connection_string,
                                 zdatetime=None, tilevel=DEFAULT_TILEVEL,
                                 encoding='', check=None, REQUEST=None):
    """Add a DB connection to a folder."""
    self._setObject(id, Connection(id, title, connection_string,
                                   zdatetime, check, tilevel, encoding))
    if REQUEST is not None:
        return self.manage_main(self, REQUEST)
Ejemplo n.º 4
0
def manage_addZMySQLConnection(self,
                               id,
                               title,
                               connection_string,
                               check=None,
                               REQUEST=None):
    """Add a 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)
Ejemplo n.º 5
0
def manage_addZGadflyConnection(self,
                                id,
                                title,
                                connection,
                                check=None,
                                REQUEST=None):
    """Add a DB connection to a folder"""

    # Note - type checking is taken care of by _setObject
    # and the Connection object constructor.
    self._setObject(id, Connection(id, title, connection, check))
    if REQUEST is not None: return self.manage_main(self, REQUEST)