Author: phd
Date: 2004-12-07 17:58:06 +0000 (Tue, 07 Dec 2004)
New Revision: 464
Added:
home/phd/SQLObject/inheritance/sqlobject/util/
Removed:
home/phd/SQLObject/inheritance/sqlobject/dbm/
Modified:
home/phd/SQLObject/inheritance/README.txt
home/phd/SQLObject/inheritance/docs/Authors.txt
home/phd/SQLObject/inheritance/docs/News.txt
home/phd/SQLObject/inheritance/docs/SQLObject.txt
home/phd/SQLObject/inheritance/examples/config.py
home/phd/SQLObject/inheritance/setup.py
home/phd/SQLObject/inheritance/sqlobject/__init__.py
home/phd/SQLObject/inheritance/sqlobject/col.py
home/phd/SQLObject/inheritance/tests/SQLObjectTest.py
home/phd/SQLObject/inheritance/tests/test_sqlobject.py
Log:
Merged patches from revisions 455:463: removed deadly broken dbm connection; updated docs.
Modified: home/phd/SQLObject/inheritance/README.txt
===================================================================
--- home/phd/SQLObject/inheritance/README.txt 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/README.txt 2004-12-07 17:58:06 UTC (rev 464)
@@ -10,9 +10,9 @@
mapper, i.e., a library that will wrap your database tables in Python
classes, and your rows in Python instances.
-It absolutely requires Python 2.2 or higher. It currently supports
-MySQL through the `MySQLdb` package, PostgreSQL through the
-`psycopg` package, SQLite, Firebird, and a DBM-based backend.
+It absolutely requires Python 2.2 or higher. It currently supports
+MySQL through the `MySQLdb` package, PostgreSQL through the
+`psycopg` package, SQLite, Firebird, MaxDB (SAP DB) and Sybase.
For more information please see the documentation in
``docs/SQLObject.html``
Modified: home/phd/SQLObject/inheritance/docs/Authors.txt
===================================================================
--- home/phd/SQLObject/inheritance/docs/Authors.txt 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/docs/Authors.txt 2004-12-07 17:58:06 UTC (rev 464)
@@ -16,4 +16,4 @@
* Daniel Savard, Xsoli Inc <sqlobject at xsoli.com>
* alexander smishlajev <alex at ank-sia.com>
* Yaroslav Samchuk <yarcat at ank-sia.com>
-* Oleg Broytmann <ph...@ph...>
+* Oleg Broytmann <phd at phd.pp.ru>
Modified: home/phd/SQLObject/inheritance/docs/News.txt
===================================================================
--- home/phd/SQLObject/inheritance/docs/News.txt 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/docs/News.txt 2004-12-07 17:58:06 UTC (rev 464)
@@ -7,6 +7,22 @@
.. _start:
+SQLObject 0.6.2
+===============
+
+Interface Changes
+-----------------
+
+* The long broken and unused ``DBMConnection`` has been removed.
+
+* Removed DBMConnection.
+
+Features
+--------
+
+* New ``UnicodeCol()`` that converts to and from Unicode
+ in the database.
+
SQLObject 0.6.1
===============
Modified: home/phd/SQLObject/inheritance/docs/SQLObject.txt
===================================================================
--- home/phd/SQLObject/inheritance/docs/SQLObject.txt 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/docs/SQLObject.txt 2004-12-07 17:58:06 UTC (rev 464)
@@ -43,8 +43,7 @@
============
Currently SQLObject supports MySQL_, PostgreSQL_ (via ``psycopg``),
-SQLite_, Firebird_, and a DBM-based store. The DBM backend is
-experimental.
+SQLite_, Firebird_, Sybase_, and `MAX DB`_ (also known as SAP DB).
.. _PostgreSQL: http://postgresql.org
.. _SQLite: http://sqlite.org
@@ -97,9 +96,7 @@
SQLObject provides a strong database abstraction, allowing
cross-database compatibility (so long as you don't sidestep
-SQLObject). This compatibility extends not just to several databases,
-but also to currently one non-SQL, non-relational backend (based on
-the `dbm` module).
+SQLObject).
SQLObject has joins, one-to-many, and many-to-many, something which
many ORMs do not have. The join system is also intended to be
@@ -615,26 +612,34 @@
Will create a ``BOOLEAN`` column in Postgres, or ``INT`` in other
databses. It will also convert values to ``"t"/"f"`` or ``0/1``
according to the database backend.
+
`CurrencyCol`:
Equivalent to ``DecimalCol(size=10, precision=2)``.
+
`DateTimeCol`:
A date and time (usually returned as an mxDateTime object).
+
`DecimalCol`:
Base-10, precise number. Uses the keyword arguments `size` for
number of digits stored, and `precision` for the number of digits
after the decimal point.
+
`EnumCol`:
One of several string values -- give the possible strings as a
list, with the `enumValues` keyword argument. MySQL has a native
``ENUM`` type, but will work with other databases too (storage
just won't be as efficient).
+
`FloatCol`:
Floats.
+
`ForeignKey`:
A key to another table/class. Use like ``user =
ForeignKey('User')``.
+
`IntCol`:
Integers.
+
`StringCol`:
A string (character) column. Extra keywords:
@@ -646,6 +651,15 @@
``CHAR`` and ``VARCHAR``, default True, i.e., use
``VARCHAR``.
+`UnicodeCol`:
+ A subclass of `StringCol`. Also accepts a dbEncoding keyword
+ argument, which defaults to ``"UTF-8"``. Values coming in and
+ out from the database will be encoded and decoded. **Note**:
+ parameters in queries will not be automatically encoded, so if
+ you do a query matching a UnicodeCol column you must apply the
+ encoding yourself.
+
+
SQLObject Class: Specifying Your Class
--------------------------------------
@@ -792,8 +806,7 @@
All the connections support creating and droping tables based on the
class definition. First you have to prepare your class definition,
-which means including type information in your columns (though
-DBMConnection_ do not require or use type information).
+which means including type information in your columns.
Columns Types
~~~~~~~~~~~~~
@@ -942,7 +955,7 @@
While SQLObject tries not to make too many requirements on your
schema, some assumptions are made. Some of these may be relaxed in
-the future. (Of course, none of this applies to DBMConnection)
+the future.
All tables that you want to turn into a class need to have an integer
primary key. That key should be defined like:
@@ -1032,7 +1045,7 @@
The `DBConnection` module currently has four external classes,
`MySQLConnection`, `PostgresConnection`, `SQLiteConnection`,
-and `DBMConnection`.
+`SybaseConnection`, and `MaxdbConnection`.
You can pass the keyword argument `debug` to any connector. If set to
true, then any SQL sent to the database will also be printed to the
@@ -1097,46 +1110,46 @@
.. _this page: http://www.volny.cz/iprenosil/interbase/ip_ib_indexcalculator.htm
-DBMConnection
--------------
+SybaseConnection
+----------------
-`DBMConnection` takes a single string, which is the path to a
-directory in which to store the database.
+`SybaseConnection` takes the arguments `host`, `db`, `user`, and
+`passwd`. It also takes the extra boolean argument `locking` (default
+True), which is passed through when performing a connection. You may
+use a False value for `locking` if you are not using multiple threads,
+for a slight performance boost.
-DBMConnection uses flat hash databases to store all the data. These
-databases are created by the standard `anydbm` module. This is
-something of an experiment, and things like safety under concurrent
-access (multithreaded or multiprocess) should not be expected. The
-select interface using the magic ``q`` attribute is supported, though
-other SQL is not supported.
+It uses the Sybase_ module.
-DBMConnection allows any kind of objects to be put in columns -- all
-values are pickled, and so only normal pickling restrictions apply.
+.. _Sybase: http://www.object-craft.com.au/projects/sybase/
-DBMConnection does not support `automatic class generation` or
-transactions_.
+MAX DB
+------
+MAX DB, also known as SAP DB, is available from a partnership of SAP
+and MySQL. It takes the typical arguments: `host`, `database`,
+`user`, `password`. It also takes the arguments `sqlmode` (default
+``"internal"``), `isolation`, and `timeout`, which are passed through
+when creating the connection to the database.
+
+It uses the sapdb_ module.
+
+.. _sapdb: http://www.sapdb.org/sapdbPython.html
+
Exported Symbols
================
-You can use ``from SQLObject import *``, though you don't have to. It
+You can use ``from sqlobject import *``, though you don't have to. It
exports a minimal number of symbols. The symbols exported:
-From `SQLObject.SQLObject`:
+From `sqlobject.main`:
* `NoDefault`
* `SQLObject`
* `getID`
* `getObject`
-From `SQLObject.DBConnection`:
-
-* `MySQLConnection`
-* `PostgresConnection`
-* `SQLiteConnection`
-* `DBMConnection`
-
-From `SQLObject.Col`:
+From `sqlobject.col`:
* `Col`
* `StringCol`
* `IntCol`
@@ -1148,17 +1161,17 @@
* `DecimalCol`
* `CurrencyCol`
-From `SQLObject.Join`:
+From `sqlobject.joins`:
* `MultipleJoin`
* `RelatedJoin`
-From `SQLObject.Style`:
+From `sqlobject.styles`:
* `Style`
* `MixedCaseUnderscoreStyle`
* `DefaultStyle`
* `MixedCaseStyle`
-From `SQLObject.SQLBuilder`:
+From `sqlobject.sqlbuilder`:
* `AND`
* `OR`
Modified: home/phd/SQLObject/inheritance/examples/config.py
===================================================================
--- home/phd/SQLObject/inheritance/examples/config.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/examples/config.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -13,8 +13,6 @@
conn = 'postgres://test@localhost/testdb'
conn = SQLiteConnection('database.db')
conn = 'sqlite://path/to/database.db'
-conn = DBMConnection('database/')
-conn = 'dbm://path/to/database/'
## end snippet
"""
#conn = MySQLConnection(user='test', db='test')
Modified: home/phd/SQLObject/inheritance/setup.py
===================================================================
--- home/phd/SQLObject/inheritance/setup.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/setup.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -2,7 +2,7 @@
import warnings
warnings.filterwarnings("ignore", "Unknown distribution option")
-subpackages = ['dbm', 'firebird', 'include', 'mysql', 'postgres',
+subpackages = ['firebird', 'include', 'mysql', 'postgres',
'sqlite', 'sybase', 'maxdb']
import sys
Modified: home/phd/SQLObject/inheritance/sqlobject/__init__.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/__init__.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/sqlobject/__init__.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -34,11 +34,6 @@
_warn('SQLiteConnection is deprecated; use connectionForURI("sqlite://...") or "from sqlobject.sqlite import builder; SQLiteConnection = builder()"')
return _sqlite.builder()(*args, **kw)
-import dbm as _dbm
-def DBMConnection(*args, **kw):
- _warn('DBMConnection is deprecated; use connectionForURI("dbm://...") or "from sqlobject.dbm import builder; DBMConnection = builder()"')
- return _dbm.builder()(*args, **kw)
-
import sybase as _sybase
def SybaseConnection(*args, **kw):
_warn('SybaseConnection is deprecated; use connectionForURI("sybase://...") or "from sqlobject.sybase import builder; SybaseConnection = builder()"')
Modified: home/phd/SQLObject/inheritance/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/inheritance/sqlobject/col.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/sqlobject/col.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -338,6 +338,28 @@
class StringCol(Col):
baseClass = SOStringCol
+class UnicodeStringValidator(validators.Validator):
+
+ def __init__(self, db_encoding='UTF-8'):
+ self.db_encoding = db_encoding
+
+ def fromPython(self, value, state):
+ return value.encode(self.db_encoding)
+
+ def toPython(self, value, state):
+ return unicode(value, self.db_encoding)
+
+class SOUnicodeCol(SOStringCol):
+
+ def __init__(self, **kw):
+ self.dbEncoding = popKey(kw, 'dbEncoding', 'UTF-8')
+ SOStringCol.__init__(self, **kw)
+ self.validator = validators.All.join(
+ UnicodeStringValidator(self.dbEncoding), self.validator)
+
+class UnicodeCol(Col):
+ baseClass = SOUnicodeCol
+
class SOIntCol(SOCol):
# 3-03 @@: support precision, maybe max and min directly
Copied: home/phd/SQLObject/inheritance/sqlobject/util (from rev 463, trunk/SQLObject/sqlobject/util)
Modified: home/phd/SQLObject/inheritance/tests/SQLObjectTest.py
===================================================================
--- home/phd/SQLObject/inheritance/tests/SQLObjectTest.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/tests/SQLObjectTest.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -28,12 +28,6 @@
supportTransactions=False,
supportExpressionIndex=False)
-def dbmConnection():
- return 'dbm:///data', d(
- supportAuto=False,
- supportRestrictedEnum=False,
- supportTransactions=False)
-
def postgresConnection():
return 'postgres:///test', d()
Modified: home/phd/SQLObject/inheritance/tests/test_sqlobject.py
===================================================================
--- home/phd/SQLObject/inheritance/tests/test_sqlobject.py 2004-12-07 17:53:51 UTC (rev 463)
+++ home/phd/SQLObject/inheritance/tests/test_sqlobject.py 2004-12-07 17:58:06 UTC (rev 464)
@@ -1254,6 +1254,39 @@
{0: 1, 1:1})
########################################
+## Unicode columns
+########################################
+
+class Unicode1(SQLObject):
+ count = IntCol(alternateID=True)
+ col1 = UnicodeCol()
+ col2 = UnicodeCol(dbEncoding='latin-1')
+
+class UnicodeTest(SQLObjectTest):
+
+ classes = [Unicode1]
+
+ data = [u'\u00f0', u'test', 'ascii test']
+
+ def testCreate(self):
+ items = []
+ for i, n in enumerate(self.data):
+ items.append(Unicode1(count=i, col1=n, col2=n))
+ for n, item in zip(self.data, items):
+ item.col1 = item.col2 = n
+ for n, item in zip(self.data, items):
+ self.assertEqual(item.col1, item.col2, n)
+ conn = Unicode1._connection
+ rows = conn.queryAll("""
+ SELECT count, col1, col2
+ FROM unicode1
+ ORDER BY count
+ """)
+ for count, col1, col2 in rows:
+ self.assertEqual(self.data[count].encode('utf-8'), col1)
+ self.assertEqual(self.data[count].encode('latin1'), col2)
+
+########################################
## Run from command-line:
########################################
|