[Zope3-checkins] CVS: zopeproducts/sqliteda - __init__.py:1.1 adapter.py:1.1 configure.zcml:1.1

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Aug 19 04:12:18 EDT 2003


Update of /cvs-repository/zopeproducts/sqliteda
In directory cvs.zope.org:/tmp/cvs-serv17486/sqliteda

Added Files:
	__init__.py adapter.py configure.zcml 
Log Message:
Updated all Database Adaptors.


=== Added File zopeproducts/sqliteda/__init__.py ===
# make this a python package



=== Added File zopeproducts/sqliteda/adapter.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# 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.
#
##############################################################################
"""SQLITE database adapter.

$Id: adapter.py,v 1.1 2003/08/19 07:12:13 srichter Exp $
"""
import sqlite
from zope.app.rdb.ZopeDatabaseAdapter import ZopeDatabaseAdapter, parseDSN

class SQLiteAdapter(ZopeDatabaseAdapter):
    """A sqlite adapter for Zope3"""

    __implements__ = ZopeDatabaseAdapter.__implements__

    def _connection_factory(self):
        """Create a sqlite connection based on the DSN"""
        # XXX this database supports setting the mode
        # of the file. Example:
        # dbi://mydatabase/mode=755

        # XXX The dbname is actually a filename. How should
        # it be modified to stay/get in a specific directory?
        # E.g. var/sqlite/dbname
        
        conn_info = parseDSN(self.dsn)
        return sqlite.connect(db=conn_info['dbname'])



=== Added File zopeproducts/sqliteda/configure.zcml ===
<configure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser"
   i18n_domain="sqlite">

  <content class=".adapter.SQLiteAdapter">
    <factory
        id="zope.da.SQLiteDA"
        permission="zope.Public"/>
    <require 
        permission="zope.Public"
        interface="zope.app.interfaces.rdb.IZopeDatabaseAdapter"/>
  </content>

  <browser:addform
      name="AddSQLiteDA"
      schema="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
      label="Add SQLite Database Adapter"
      content_factory=".adapter.SQLiteAdapter"
      arguments="dsn"
      fields="dsn"
      permission="zope.ManageContent" />

  <!-- Menu entry for "add component" menu -->
  <browser:menuItem 
      menu="add_component"
      for="zope.app.interfaces.container.IAdding"
      title="SQLite DA" 
      description="An SAP Database Adapter"
      action="AddSQLiteDA" />

  <!-- Menu entry for "add utility" menu -->
  <browser:menuItem
      menu="add_utility"
      for="zope.app.interfaces.container.IAdding"
      title="SQLite DA" 
      description="An SAP Database Adapter"
      action="AddSQLiteDA" />

  <!-- Menu entry for "add connection" menu -->
  <browser:menuItem
      menu="add_connection"
      for="zope.app.interfaces.container.IAdding"
      title="SQLite DA" 
      description="An SQLite Database Adapter"
      action="AddSQLiteDA" />

</configure>




More information about the Zope3-Checkins mailing list