sqlobject-cvs Mailing List for SQLObject (Page 183)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: <ian...@us...> - 2003-11-01 20:30:26
|
Update of /cvsroot/sqlobject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv19662
Modified Files:
setup.py
Log Message:
Forgot to save first...
Index: setup.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/setup.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** setup.py 1 Nov 2003 20:29:13 -0000 1.13
--- setup.py 1 Nov 2003 20:30:22 -0000 1.14
***************
*** 16,21 ****
Classes created using SQLObject wrap database rows, presenting a
friendly-looking Python object instead of a database/SQL interface.
! Emphasizes convenience. Works with MySQL, Postgres, SQLite, and a
! native anydbm-based backend. Requires Python 2.2+.
""",
classifiers=["Development Status :: 4 - Beta",
--- 16,21 ----
Classes created using SQLObject wrap database rows, presenting a
friendly-looking Python object instead of a database/SQL interface.
! Emphasizes convenience. Works with MySQL, Postgres, SQLite, Firebird.
! Requires Python 2.2+.
""",
classifiers=["Development Status :: 4 - Beta",
|
|
From: <ian...@us...> - 2003-11-01 20:29:15
|
Update of /cvsroot/sqlobject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv19436
Modified Files:
setup.py
Log Message:
Updated version numbers
Index: setup.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/setup.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** setup.py 7 Sep 2003 22:35:09 -0000 1.12
--- setup.py 1 Nov 2003 20:29:13 -0000 1.13
***************
*** 11,15 ****
setup(name="SQLObject",
! version="0.4",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
--- 11,15 ----
setup(name="SQLObject",
! version="0.5",
description="Object-Relational Manager, aka database wrapper",
long_description="""\
***************
*** 32,36 ****
license="LGPL",
packages=["SQLObject", "SQLObject.include"],
! download_url="http://prdownloads.sourceforge.net/sqlobject/SQLObject-0.4.tar.gz?download")
# Send announce to:
--- 32,36 ----
license="LGPL",
packages=["SQLObject", "SQLObject.include"],
! download_url="http://prdownloads.sourceforge.net/sqlobject/SQLObject-0.5.tar.gz?download")
# Send announce to:
|
|
From: <ian...@us...> - 2003-11-01 20:28:16
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv19190 Modified Files: SQLObject.txt Log Message: Fixed version number, added link to kinterbasdb Index: SQLObject.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/SQLObject.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SQLObject.txt 1 Nov 2003 20:24:24 -0000 1.16 --- SQLObject.txt 1 Nov 2003 20:28:13 -0000 1.17 *************** *** 1,4 **** ``````````````` ! SQLObject 0.4 ``````````````` --- 1,4 ---- ``````````````` ! SQLObject 0.5 ``````````````` *************** *** 980,983 **** --- 980,987 ---- concurrent cursors if you have problems (using ``list()`` will pre-fetch all the results of a select). + + Firebird support uses the kinterbasdb_ Python library. + + .. _kinterbasdb: http://kinterbasdb.sourceforge.net/ DBMConnection |
|
From: <ian...@us...> - 2003-11-01 20:24:28
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv18590 Modified Files: SQLObject.txt Log Message: Updated for 0.5 Index: SQLObject.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/SQLObject.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SQLObject.txt 10 Jul 2003 19:28:50 -0000 1.15 --- SQLObject.txt 1 Nov 2003 20:24:24 -0000 1.16 *************** *** 43,49 **** ============ ! Currently SQLObject supports MySQL, PostgreSQL (via ``psycopg``), ! SQLite, and a DBM-based store. The DBM backend is the youngest, ! and somewhat experimental. Python 2.2 or higher is required. SQLObject makes extensive use of --- 43,53 ---- ============ ! Currently SQLObject supports MySQL_, PostgreSQL_ (via ``psycopg``), ! SQLite_, Firebird_, and a DBM-based store. The DBM backend is ! experimental. ! ! .. _PostgreSQL: http://postgresql.org ! .. _SQLite: http://sqlite.org ! .. _Firebird: http://firebird.sourceforge.net Python 2.2 or higher is required. SQLObject makes extensive use of *************** *** 113,127 **** Here are some things I plan: ! * More databases supported. SQL databases (like Oracle or Firebird) ! should be easy, non-SQL databases like Metakit should be possible. * Better transaction support -- right now you can use transactions for the database, but the object isn't transaction-aware, so non-database persistence won't be able to be rolled back. ! Locking and other techniques to handle concurrency will also be ! implemented (probably in 0.5). * Profile of SQLObject performance, so that I can identify bottlenecks. ! * Makes hooks with a validation and form generation package, so ! SQLObject classes (read: schemas) can be published for editing ! more directly and easily. * Automatic joins in select queries. * More kinds of joins, and more powerful join results (closer to how --- 117,130 ---- Here are some things I plan: ! * More databases supported. There has been interest and some work in ! the progress for Oracle, Sybase, and MS-SQL support. * Better transaction support -- right now you can use transactions for the database, but the object isn't transaction-aware, so non-database persistence won't be able to be rolled back. ! * Optimistic locking and other techniques to handle concurrency. * Profile of SQLObject performance, so that I can identify bottlenecks. ! * Increase hooks with FormEncode (unreleased) validation and form ! generation package, so SQLObject classes (read: schemas) can be ! published for editing more directly and easily. * Automatic joins in select queries. * More kinds of joins, and more powerful join results (closer to how *************** *** 138,142 **** To begin with, let's make a database connection. Choose from one of `MySQLConnection`, `PostgresConnection`, `SQLiteConnection`, and ! `DBMConnection`, depending on what database you use. .. raw:: html --- 141,145 ---- To begin with, let's make a database connection. Choose from one of `MySQLConnection`, `PostgresConnection`, `SQLiteConnection`, and ! `FirebirdConnection`, depending on what database you use. .. raw:: html *************** *** 144,150 **** The rest of this will be written more-or-less in a database-agnostic ! manner, using the connection you define. (Use `DBMConnection` if you ! don't have another database installed or ready -- it only uses ! standard Python modules, and writes to a directory) We'll develop a simple addressbook-like database. We could create the --- 147,155 ---- The rest of this will be written more-or-less in a database-agnostic ! manner, using the connection you define. Use `SQLite` if you don't ! have another database installed or ready -- it requires PySQLite_, but ! doesn't require a client/server setup. ! ! .. _PySQLite: http://pysqlite.sourceforge.net/ We'll develop a simple addressbook-like database. We could create the *************** *** 166,174 **** :file: ../examples/snippets/simpleaddress-schema-person1.html ! This is for MySQL. The schema for Postgres or SQLite looks a little different (especially the ``id`` column). You'll notice the names were changed from mixedCase to underscore_separated -- this is done by ! the `style object`_. There are a variety of ways to handle ! other names that are not as SQLObject expects (see `Irregular Naming`_). .. _`style object`: `Changing the Naming Style`_ --- 171,179 ---- :file: ../examples/snippets/simpleaddress-schema-person1.html ! This is for MySQL. The schema for other databases looks slightly different (especially the ``id`` column). You'll notice the names were changed from mixedCase to underscore_separated -- this is done by ! the `style object`_. There are a variety of ways to handle that names ! that don't fit conventions (see `Irregular Naming`_). .. _`style object`: `Changing the Naming Style`_ *************** *** 193,199 **** as ``INT PRIMARY KEY AUTO_INCREMENT``, in Postgres ``SERIAL PRIMARY KEY``, and in SQLite as ``INTEGER PRIMARY KEY``. You can `override the ! name`__, but some integer primary key must exist. __ idName_ Using the Class --- 198,206 ---- as ``INT PRIMARY KEY AUTO_INCREMENT``, in Postgres ``SERIAL PRIMARY KEY``, and in SQLite as ``INTEGER PRIMARY KEY``. You can `override the ! name`__, but some integer primary key must exist (though `you can use ! non-integer keys`_ with some extra effort). __ idName_ + .. _`you can use non-integer keys`: `Non-Integer Keys`_ Using the Class *************** *** 350,354 **** :file: ../examples/snippets/person-select3.html ! You may wish to use `SQLBuilder.sqlRepr` to quote any values you use if you use this technique (quoting is automatic if you use ``q``). Tables given in `clauseTables` will be added to the ``FROM`` portion --- 357,361 ---- :file: ../examples/snippets/person-select3.html ! You may wish to use `MyClass.sqlrepr` to quote any values you use if you use this technique (quoting is automatic if you use ``q``). Tables given in `clauseTables` will be added to the ``FROM`` portion *************** *** 533,536 **** --- 540,567 ---- different types of columns, when SQLObject creates your tables. + `BoolCol`: + 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: *************** *** 543,566 **** ``CHAR`` and ``VARCHAR``, default True, i.e., use ``VARCHAR``. - `IntCol`: - Integers, real simple. - `FloatCol`: - Floats. - `ForeignKey`: - A key to another table/class. Use like ``user = - ForeignKey('User')``. - `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). - `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. - `CurrencyCol`: - Equivalent to ``DecimalCol(size=10, precision=2)``. SQLObject Class: Specifying Your Class --- 574,577 ---- *************** *** 784,788 **** columns will be added. ! *This is only supported in MySQL and Postgres* Runtime Column Changes --- 795,799 ---- columns will be added. ! *This is not supported in SQLite* Runtime Column Changes *************** *** 901,904 **** --- 912,924 ---- column name. + Non-Integer Keys + ---------------- + + While not strictly a legacy database issue, this fits into the + category of "irregularities". If you use non-integer keys, all + primary key management is up to you. You must create the table + yourself, and when you create instances you must pass a ``id`` keyword + argument into ``new`` (like ``Person.new(id='555-55-5555', ...)``). + DBConnection: Database Connections ================================== *************** *** 920,924 **** MySQLConnection supports all the features, though MySQL does not support transactions_ (except using a special proprietary backend that ! no one I've seen uses). Postgres --- 940,944 ---- MySQLConnection supports all the features, though MySQL does not support transactions_ (except using a special proprietary backend that ! I haven't used). Postgres *************** *** 948,951 **** --- 968,983 ---- SQLite may have concurrency issues, depending on your usage in a multi-threaded environment. + + Firebird + -------- + + `FirebirdConnection` takes the arguments `host`, `db`, `user` (default + ``"sysdba"``), `passwd` (default ``"masterkey"``). + + Firebird supports all the features. Support is still young, so there + may be some issues, especially with concurrent access, and especially + using lazy selects. Try ``list(MyClass.select())`` to avoid + concurrent cursors if you have problems (using ``list()`` will + pre-fetch all the results of a select). DBMConnection |
|
From: <ian...@us...> - 2003-11-01 19:54:32
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv13345 Modified Files: News.txt Log Message: Added notes for 0.5 Index: News.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/News.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** News.txt 26 Jun 2003 08:34:38 -0000 1.8 --- News.txt 1 Nov 2003 19:54:28 -0000 1.9 *************** *** 8,11 **** --- 8,67 ---- .. _start: + SQLObject 0.5 + ============= + + Features + -------- + + * Firebird_ support. + + * Database-specific literal quoting (motivation: MySQL and Postgres + use backslashes, Firebird and SQLite do not). + + * Generic conversion/validation can be added to columns. + + * BoolCol for portable boolean columns (BOOL on Postgres, INT on + MySQL, etc.) + + * Non-integer IDs. (Automatic table creation is not supported for + non-integer IDs) + * Explicit IDs for new instances/rows (required for non-integer IDs). + * Instances can be synced with the database (in case there have been + updates to the object since it was first fetched). + * Instances can be expired, so that they will be synced when they are + next accessed. + + .. _Firebird: http://firebird.sourceforge.net/ + + Bugs + ---- + + * Released all locks with ``finally:``, so that bugs won't cause + frozen locks. + * Tons of transaction fixes. Transactions pretty much work. + * A class can have multiple foreign keys pointing to the same table + (e.g., ``spouse = ForeignKey("Person"); supervisor = + ForeignKey("Person")``) + + Changed Usage Notes + ------------------- + + * `SQLBuilder.sqlRepr` renamed to `SQLBuilder.sqlrepr`, signature + changed to ``sqlrepr(value, databaseName)`` to quote ``value``, + where ``databaseName`` is one of ``"mysql"``, ``"postgres"``, + ``"sqlite"``, ``"firebird"``. + + * ``sqlRepr`` magic method renamed to ``__sqlrepr__``, and takes new + ``databaseName`` argument. + + * When using explicit booleans, use ``Col.TRUE`` and ``Col.FALSE`` for + backward compatibility with Python 2.2. This is not required for + ``BoolCol``, however (which converts all true values to TRUE and + false values to FALSE) + + * SQLObject has a ``sqlrepr`` method, so you can construct queries + with something like ``"WHERE last_name = %s" % + Person.sqlrepr('Bob')`` + SQLObject 0.4 ============= |
|
From: <ian...@us...> - 2003-11-01 19:53:11
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv13112
Modified Files:
SQLObject.py
Log Message:
Changed self argument to cls for a classmethod (sqlrepr)
Index: SQLObject.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** SQLObject.py 24 Oct 2003 19:18:52 -0000 1.61
--- SQLObject.py 1 Nov 2003 19:53:07 -0000 1.62
***************
*** 1026,1031 ****
' '.join(['%s=%s' % (name, repr(value)) for name, value in self._reprItems()]))
! def sqlrepr(self, value):
! return self._connection.sqlrepr(value)
sqlrepr = classmethod(sqlrepr)
--- 1026,1031 ----
' '.join(['%s=%s' % (name, repr(value)) for name, value in self._reprItems()]))
! def sqlrepr(self, cls):
! return cls._connection.sqlrepr(value)
sqlrepr = classmethod(sqlrepr)
|
|
From: <dre...@us...> - 2003-10-24 19:22:32
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv16384
Modified Files:
DBConnection.py SQLBuilder.py SQLObject.py
Log Message:
Added sqlrepr() classmethod to SQLObject (so you dont have to pass in 'db' if you have a class with a connection at hand). Fixed a bug in SQLExprConverter (missing argument). Fixed conversion to string on _addWhereClause (__str__ of SQLExpression calls __sqlrelr__ with db=None, so we use DBConnection.sqlrepr)
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** DBConnection.py 11 Oct 2003 07:39:43 -0000 1.53
--- DBConnection.py 24 Oct 2003 19:18:52 -0000 1.54
***************
*** 209,213 ****
def _addWhereClause(self, select, startSelect, limit=1, order=1):
! q = str(select.clause)
ops = select.ops
--- 209,215 ----
def _addWhereClause(self, select, startSelect, limit=1, order=1):
! q = select.clause
! if type(q) not in [type(''), type(u'')]:
! q = self.sqlrepr(q)
ops = select.ops
***************
*** 791,795 ****
# need to worry about that.
pass
!
def makeConnection(self):
return kinterbasdb.connect(
--- 793,797 ----
# need to worry about that.
pass
!
def makeConnection(self):
return kinterbasdb.connect(
***************
*** 868,872 ****
(tableName,
column.dbName))
!
def columnsFromSchema(self, tableName, soClass):
"""
--- 870,874 ----
(tableName,
column.dbName))
!
def columnsFromSchema(self, tableName, soClass):
"""
***************
*** 884,890 ****
RDB$FIELDS.RDB$FIELD_SUB_TYPE as blobtype
FROM RDB$RELATION_FIELDS
! INNER JOIN RDB$FIELDS ON
(RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME)
! INNER JOIN RDB$TYPES ON (RDB$FIELDS.RDB$FIELD_TYPE =
RDB$TYPES.RDB$TYPE)
WHERE
--- 886,892 ----
RDB$FIELDS.RDB$FIELD_SUB_TYPE as blobtype
FROM RDB$RELATION_FIELDS
! INNER JOIN RDB$FIELDS ON
(RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME)
! INNER JOIN RDB$TYPES ON (RDB$FIELDS.RDB$FIELD_TYPE =
RDB$TYPES.RDB$TYPE)
WHERE
***************
*** 906,910 ****
_intTypes=['INT64', 'SHORT','LONG']
_dateTypes=['DATE','TIME','TIMESTAMP']
!
def guessClass(self, t, flength, fscale=None):
"""
--- 908,912 ----
_intTypes=['INT64', 'SHORT','LONG']
_dateTypes=['DATE','TIME','TIMESTAMP']
!
def guessClass(self, t, flength, fscale=None):
"""
***************
*** 913,917 ****
available -- both very database-specific.
"""
!
if t in self._intTypes:
return Col.IntCol, {}
--- 915,919 ----
available -- both very database-specific.
"""
!
if t in self._intTypes:
return Col.IntCol, {}
Index: SQLBuilder.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLBuilder.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SQLBuilder.py 11 Oct 2003 07:39:43 -0000 1.12
--- SQLBuilder.py 24 Oct 2003 19:18:52 -0000 1.13
***************
*** 188,192 ****
#######################################
! def SQLExprConverter(value):
return value.__sqlrepr__()
--- 188,192 ----
#######################################
! def SQLExprConverter(value, db):
return value.__sqlrepr__()
Index: SQLObject.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** SQLObject.py 26 Sep 2003 20:05:14 -0000 1.60
--- SQLObject.py 24 Oct 2003 19:18:52 -0000 1.61
***************
*** 1026,1029 ****
--- 1026,1034 ----
' '.join(['%s=%s' % (name, repr(value)) for name, value in self._reprItems()]))
+ def sqlrepr(self, value):
+ return self._connection.sqlrepr(value)
+
+ sqlrepr = classmethod(sqlrepr)
+
def _reprItems(self):
items = []
|
|
From: <dre...@us...> - 2003-10-22 18:56:56
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv29062
Modified Files:
Converters.py
Log Message:
Oops. That would only work in 2.3, afaict.
Index: Converters.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Converters.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Converters.py 11 Oct 2003 07:39:43 -0000 1.7
--- Converters.py 22 Oct 2003 18:11:56 -0000 1.8
***************
*** 103,107 ****
def BoolConverter(value, db):
! if db in ('postgres'):
if value:
return "'t'"
--- 103,107 ----
def BoolConverter(value, db):
! if db in ('postgres',):
if value:
return "'t'"
|
|
From: <ian...@us...> - 2003-10-11 07:39:48
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv6652/SQLObject
Modified Files:
Col.py Converters.py DBConnection.py SQLBuilder.py
Log Message:
* Renamed sqlRepr() function to sqlrepr(), and sqlRepr magic method to
__sqlrepr. Added db argument to both.
* Made string and boolean quoting database-sensitive.
* Added TRUE and FALSE objects, which are distinct from 1 and 0 even on
Python versions without bool types. (True and False are used if they
are distinctive)
Index: Col.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** Col.py 6 Oct 2003 00:37:13 -0000 1.30
--- Col.py 11 Oct 2003 07:39:43 -0000 1.31
***************
*** 126,130 ****
if self._default is NoDefault:
return NoDefault
! elif hasattr(self._default, 'sqlRepr'):
return self._default
elif callable(self._default):
--- 126,130 ----
if self._default is NoDefault:
return NoDefault
! elif hasattr(self._default, '__sqlrepr__'):
return self._default
elif callable(self._default):
***************
*** 276,282 ****
def fromPython(self, value, state):
if value:
! return 't'
else:
! return 'f'
class SOBoolCol(SOCol):
--- 276,282 ----
def fromPython(self, value, state):
if value:
! return SQLBuilder.TRUE
else:
! return SQLBuilder.FALSE
class SOBoolCol(SOCol):
***************
*** 363,371 ****
def _mysqlType(self):
! return "ENUM(%s)" % ', '.join(map(SQLBuilder.sqlRepr, self.enumValues))
def _postgresType(self):
length = max(map(len, self.enumValues))
! enumValues = ', '.join(map(SQLBuilder.sqlRepr, self.enumValues))
checkConstraint = "CHECK (%s in (%s))" % (self.dbName, enumValues)
return "VARCHAR(%i) %s" % (length, checkConstraint)
--- 363,371 ----
def _mysqlType(self):
! return "ENUM(%s)" % ', '.join([SQLBuilder.sqlrepr(v, 'mysql') for v in self.enumValues])
def _postgresType(self):
length = max(map(len, self.enumValues))
! enumValues = ', '.join([SQLBuilder.sqlrepr(v, 'postgres') for v in self.enumValues])
checkConstraint = "CHECK (%s in (%s))" % (self.dbName, enumValues)
return "VARCHAR(%i) %s" % (length, checkConstraint)
Index: Converters.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Converters.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Converters.py 26 Sep 2003 07:12:59 -0000 1.6
--- Converters.py 11 Oct 2003 07:39:43 -0000 1.7
***************
*** 17,21 ****
datetime = None
! True, False = (1==1), (0==1)
from types import InstanceType, ClassType, TypeType
--- 17,36 ----
datetime = None
! if type(1==1) == type(1):
! class BOOL:
! def __init__(self, value):
! self.value = not not value
! def __nonzero__(self):
! return self.value
! def __repr__(self):
! if self:
! return 'TRUE'
! else:
! return 'FALSE'
! TRUE = BOOL(1)
! FALSE = BOOL(0)
! else:
! TRUE = 1==1
! FALSE = 0==1
from types import InstanceType, ClassType, TypeType
***************
*** 36,40 ****
def isoStr(val):
! """Gets rid of time zone information"""
val = origISOStr(val)
if val.find('+') == -1:
--- 51,58 ----
def isoStr(val):
! """
! Gets rid of time zone information
! (@@: should we convert to GMT?)
! """
val = origISOStr(val)
if val.find('+') == -1:
***************
*** 65,71 ****
lookupConverter = converters.lookupConverter
! def StringLikeConverter(value):
! for orig, repl in sqlStringReplace:
! value = value.replace(orig, repl)
return "'%s'" % value
--- 83,94 ----
lookupConverter = converters.lookupConverter
! def StringLikeConverter(value, db):
! if db in ('mysql', 'postgres'):
! for orig, repl in sqlStringReplace:
! value = value.replace(orig, repl)
! elif db in ('sqlite', 'firebird'):
! value = value.replace("'", "''")
! else:
! assert 0, "Database %s unknown" % db
return "'%s'" % value
***************
*** 73,77 ****
registerConverter(type(u""), StringLikeConverter)
! def IntConverter(value):
return repr(int(value))
--- 96,100 ----
registerConverter(type(u""), StringLikeConverter)
! def IntConverter(value, db):
return repr(int(value))
***************
*** 79,92 ****
registerConverter(type(0L), IntConverter)
! def BoolConverter(value):
! if value:
! return '1'
else:
! return '0'
! if type(True) != type(1):
! registerConverter(type(True), BoolConverter)
! def FloatConverter(value):
return repr(value)
--- 102,120 ----
registerConverter(type(0L), IntConverter)
! def BoolConverter(value, db):
! if db in ('postgres'):
! if value:
! return "'t'"
! else:
! return "'f'"
else:
! if value:
! return '1'
! else:
! return '0'
! registerConverter(type(TRUE), BoolConverter)
! def FloatConverter(value, db):
return repr(value)
***************
*** 94,109 ****
if DateTimeType:
! def DateTimeConverter(value):
return "'%s'" % isoStr(value)
registerConverter(DateTimeType, DateTimeConverter)
! def NoneConverter(value):
return "NULL"
registerConverter(type(None), NoneConverter)
! def SequenceConverter(value):
! return "(%s)" % ", ".join(map(sqlRepr, value))
registerConverter(type(()), SequenceConverter)
--- 122,137 ----
if DateTimeType:
! def DateTimeConverter(value, db):
return "'%s'" % isoStr(value)
registerConverter(DateTimeType, DateTimeConverter)
! def NoneConverter(value, db):
return "NULL"
registerConverter(type(None), NoneConverter)
! def SequenceConverter(value, db):
! return "(%s)" % ", ".join([sqlrepr(v, db) for v in value])
registerConverter(type(()), SequenceConverter)
***************
*** 111,115 ****
if hasattr(time, 'struct_time'):
! def StructTimeConverter(value):
return time.strftime("'%Y-%m-%d %H:%M:%S'", value)
--- 139,143 ----
if hasattr(time, 'struct_time'):
! def StructTimeConverter(value, db):
return time.strftime("'%Y-%m-%d %H:%M:%S'", value)
***************
*** 117,138 ****
if datetime:
! def DateTimeConverter(value):
return value.strftime("'%Y-%m-%d %H:%M:%s'")
registerConverter(datetime.datetime, DateTimeConverter)
! def TimeConverter(value):
return value.strftime("'%H:%M:%s'")
registerConverter(datetime.time, TimeConverter)
! def DateConverter(value):
return value.strftime("'%Y-%m-%d'")
registerConverter(datetime.date, DateConverter)
! def sqlRepr(obj):
try:
! reprFunc = obj.sqlRepr
except AttributeError:
converter = lookupConverter(obj)
--- 145,166 ----
if datetime:
! def DateTimeConverter(value, db):
return value.strftime("'%Y-%m-%d %H:%M:%s'")
registerConverter(datetime.datetime, DateTimeConverter)
! def TimeConverter(value, db):
return value.strftime("'%H:%M:%s'")
registerConverter(datetime.time, TimeConverter)
! def DateConverter(value, db):
return value.strftime("'%Y-%m-%d'")
registerConverter(datetime.date, DateConverter)
! def sqlrepr(obj, db=None):
try:
! reprFunc = obj.__sqlrepr__
except AttributeError:
converter = lookupConverter(obj)
***************
*** 140,145 ****
raise ValueError, "Unknown SQL builtin type: %s for %s" % \
(type(obj), repr(obj))
! return converter(obj)
else:
! return reprFunc()
--- 168,173 ----
raise ValueError, "Unknown SQL builtin type: %s for %s" % \
(type(obj), repr(obj))
! return converter(obj, db)
else:
! return reprFunc(db)
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** DBConnection.py 1 Oct 2003 01:53:48 -0000 1.52
--- DBConnection.py 11 Oct 2003 07:39:43 -0000 1.53
***************
*** 13,16 ****
--- 13,17 ----
import Col
from Join import sorter
+ from Converters import sqlrepr
# We set these up as globals, which will be set if we end up
***************
*** 60,63 ****
--- 61,66 ----
"""
+ dbName = None
+
def __init__(self, **kw):
self._pool = []
***************
*** 149,153 ****
return ("INSERT INTO %s (%s) VALUES (%s)" %
(table, ', '.join(names),
! ', '.join(map(SQLBuilder.sqlRepr, values))))
def transaction(self):
--- 152,156 ----
return ("INSERT INTO %s (%s) VALUES (%s)" %
(table, ', '.join(names),
! ', '.join([self.sqlrepr(v) for v in values])))
def transaction(self):
***************
*** 215,219 ****
if desc:
lst = [SQLBuilder.DESC(i) for i in lst]
! return ', '.join([SQLBuilder.sqlRepr(i) for i in lst])
def clauseQuote(s):
--- 218,222 ----
if desc:
lst = [SQLBuilder.DESC(i) for i in lst]
! return ', '.join([self.sqlrepr(i) for i in lst])
def clauseQuote(s):
***************
*** 295,302 ****
self.query("UPDATE %s SET %s WHERE %s = %s" %
(so._table,
! ", ".join(["%s = %s" % (dbName, SQLBuilder.sqlRepr(value))
for dbName, value in values]),
so._idName,
! SQLBuilder.sqlRepr(so.id)))
def _SO_selectOne(self, so, columnNames):
--- 298,305 ----
self.query("UPDATE %s SET %s WHERE %s = %s" %
(so._table,
! ", ".join(["%s = %s" % (dbName, self.sqlrepr(value))
for dbName, value in values]),
so._idName,
! self.sqlrepr(so.id)))
def _SO_selectOne(self, so, columnNames):
***************
*** 305,309 ****
so._table,
so._idName,
! SQLBuilder.sqlRepr(so.id)))
def _SO_selectOneAlt(self, cls, columnNames, column, value):
--- 308,312 ----
so._table,
so._idName,
! self.sqlrepr(so.id)))
def _SO_selectOneAlt(self, cls, columnNames, column, value):
***************
*** 312,316 ****
cls._table,
column,
! SQLBuilder.sqlRepr(value)))
def _SO_delete(self, so):
--- 315,319 ----
cls._table,
column,
! self.sqlrepr(value)))
def _SO_delete(self, so):
***************
*** 318,322 ****
(so._table,
so._idName,
! SQLBuilder.sqlRepr(so.id)))
def _SO_selectJoin(self, soClass, column, value):
--- 321,325 ----
(so._table,
so._idName,
! self.sqlrepr(so.id)))
def _SO_selectJoin(self, soClass, column, value):
***************
*** 325,329 ****
soClass._table,
column,
! SQLBuilder.sqlRepr(value)))
def _SO_intermediateJoin(self, table, getColumn, joinColumn, value):
--- 328,332 ----
soClass._table,
column,
! self.sqlrepr(value)))
def _SO_intermediateJoin(self, table, getColumn, joinColumn, value):
***************
*** 332,336 ****
table,
joinColumn,
! SQLBuilder.sqlRepr(value)))
def _SO_intermediateDelete(self, table, firstColumn, firstValue,
--- 335,339 ----
table,
joinColumn,
! self.sqlrepr(value)))
def _SO_intermediateDelete(self, table, firstColumn, firstValue,
***************
*** 339,345 ****
(table,
firstColumn,
! SQLBuilder.sqlRepr(firstValue),
secondColumn,
! SQLBuilder.sqlRepr(secondValue)))
def _SO_intermediateInsert(self, table, firstColumn, firstValue,
--- 342,348 ----
(table,
firstColumn,
! self.sqlrepr(firstValue),
secondColumn,
! self.sqlrepr(secondValue)))
def _SO_intermediateInsert(self, table, firstColumn, firstValue,
***************
*** 349,362 ****
firstColumn,
secondColumn,
! SQLBuilder.sqlRepr(firstValue),
! SQLBuilder.sqlRepr(secondValue)))
def _SO_columnClause(self, soClass, kw):
return ' '.join(['%s = %s' %
(soClass._SO_columnDict[key].dbName,
! SQLBuilder.sqlRepr(value))
for key, value
in kw.items()])
class Transaction(object):
--- 352,368 ----
firstColumn,
secondColumn,
! self.sqlrepr(firstValue),
! self.sqlrepr(secondValue)))
def _SO_columnClause(self, soClass, kw):
return ' '.join(['%s = %s' %
(soClass._SO_columnDict[key].dbName,
! self.sqlrepr(value))
for key, value
in kw.items()])
+ def sqlrepr(self, v):
+ return sqlrepr(v, self.dbName)
+
class Transaction(object):
***************
*** 428,431 ****
--- 434,438 ----
supportTransactions = False
+ dbName = 'mysql'
def __init__(self, db, user, passwd='', host='localhost', **kw):
***************
*** 525,528 ****
--- 532,536 ----
supportTransactions = True
+ dbName = 'postgres'
def __init__(self, dsn=None, host=None, db=None,
***************
*** 678,681 ****
--- 686,690 ----
supportTransactions = True
+ dbName = 'sqlite'
def __init__(self, filename, autoCommit=1, **kw):
***************
*** 742,745 ****
--- 751,755 ----
supportTransactions = False
+ dbName = 'firebird'
def __init__(self, host, db, user='sysdba',
***************
*** 1013,1016 ****
--- 1023,1027 ----
supportTransactions = False
+ dbName = 'dbm'
def __init__(self, path, **kw):
Index: SQLBuilder.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLBuilder.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** SQLBuilder.py 1 Aug 2003 01:29:46 -0000 1.11
--- SQLBuilder.py 11 Oct 2003 07:39:43 -0000 1.12
***************
*** 43,47 ****
formed with it will produce SQL statements.
! The ``sqlRepr(obj)`` function gets the SQL representation of these
objects, as well as the proper SQL representation of basic Python
types (None==NULL).
--- 43,47 ----
formed with it will produce SQL statements.
! The ``sqlrepr(obj)`` function gets the SQL representation of these
objects, as well as the proper SQL representation of basic Python
types (None==NULL).
***************
*** 70,74 ****
import re, fnmatch
import operator
! from Converters import sqlRepr, registerConverter
safeSQLRE = re.compile(r'^[a-zA-Z][a-zA-Z0-9_\.]*$')
--- 70,74 ----
import re, fnmatch
import operator
! from Converters import sqlrepr, registerConverter, TRUE, FALSE
safeSQLRE = re.compile(r'^[a-zA-Z][a-zA-Z0-9_\.]*$')
***************
*** 153,159 ****
def __repr__(self):
! return self.sqlRepr()
def __str__(self):
! return self.sqlRepr()
def __cmp__(self, other):
--- 153,159 ----
def __repr__(self):
! return self.__sqlrepr__(None)
def __str__(self):
! return self.__sqlrepr__(None)
def __cmp__(self, other):
***************
*** 166,169 ****
--- 166,171 ----
def endswith(self, s):
return ENDSWITH(self, s)
+ def contains(self, s):
+ return CONTAINSSTRING(self, s)
def components(self):
***************
*** 187,191 ****
def SQLExprConverter(value):
! return value.sqlRepr()
registerConverter(SQLExpression, SQLExprConverter)
--- 189,193 ----
def SQLExprConverter(value):
! return value.__sqlrepr__()
registerConverter(SQLExpression, SQLExprConverter)
***************
*** 216,221 ****
self.expr1 = expr1
self.expr2 = expr2
! def sqlRepr(self):
! return "(%s %s %s)" % (sqlRepr(self.expr1), self.op, sqlRepr(self.expr2))
def components(self):
return [self.expr1, self.expr2]
--- 218,223 ----
self.expr1 = expr1
self.expr2 = expr2
! def __sqlrepr__(self, db):
! return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, sqlrepr(self.expr2, db))
def components(self):
return [self.expr1, self.expr2]
***************
*** 248,253 ****
self.expr = expr
self.args = args
! def sqlRepr(self):
! return "%s%s" % (sqlRepr(self.expr), sqlRepr(self.args))
def components(self):
return [self.expr] + list(self.args)
--- 250,255 ----
self.expr = expr
self.args = args
! def __sqlrepr__(self, db):
! return "%s%s" % (sqlrepr(self.expr, db), sqlrepr(self.args, db))
def components(self):
return [self.expr] + list(self.args)
***************
*** 261,266 ****
self.prefix = prefix
self.expr = expr
! def sqlRepr(self):
! return "%s %s" % (self.prefix, sqlRepr(self.expr))
def components(self):
return [self.expr]
--- 263,268 ----
self.prefix = prefix
self.expr = expr
! def __sqlrepr__(self, db):
! return "%s %s" % (self.prefix, sqlrepr(self.expr, db))
def components(self):
return [self.expr]
***************
*** 279,283 ****
def __init__(self, const):
self.const = const
! def sqlRepr(self):
return self.const
def execute(self, executor):
--- 281,285 ----
def __init__(self, const):
self.const = const
! def __sqlrepr__(self, db):
return self.const
def execute(self, executor):
***************
*** 287,291 ****
class SQLTrueClauseClass(SQLExpression):
! def sqlRepr(self):
return "1 = 1"
def execute(self, executor):
--- 289,293 ----
class SQLTrueClauseClass(SQLExpression):
! def __sqlrepr__(self, db):
return "1 = 1"
def execute(self, executor):
***************
*** 313,317 ****
raise AttributeError
return Field(self.tableName, attr)
! def sqlRepr(self):
return str(self.tableName)
def execute(self, executor):
--- 315,319 ----
raise AttributeError
return Field(self.tableName, attr)
! def __sqlrepr__(self, db):
return str(self.tableName)
def execute(self, executor):
***************
*** 338,342 ****
self.tableName = tableName
self.fieldName = fieldName
! def sqlRepr(self):
return self.tableName + "." + self.fieldName
def tablesUsedImmediate(self):
--- 340,344 ----
self.tableName = tableName
self.fieldName = fieldName
! def __sqlrepr__(self, db):
return self.tableName + "." + self.fieldName
def tablesUsedImmediate(self):
***************
*** 375,380 ****
self.limit = limit
! def sqlRepr(self):
! select = "SELECT %s" % ", ".join(map(sqlRepr, self.items))
tables = {}
--- 377,382 ----
self.limit = limit
! def __sqlrepr__(self, db):
! select = "SELECT %s" % ", ".join([sqlrepr(v, db) for v in self.items])
tables = {}
***************
*** 390,402 ****
if self.whereClause is not NoDefault:
! select += " WHERE %s" % sqlRepr(self.whereClause)
if self.groupBy is not NoDefault:
! select += " GROUP BY %s" % sqlRepr(self.groupBy)
if self.having is not NoDefault:
! select += " HAVING %s" % sqlRepr(self.having)
if self.orderBy is not NoDefault:
! select += " ORDER BY %s" % sqlRepr(self.orderBy)
if self.limit is not NoDefault:
! select += " LIMIT %s" % sqlRepr(self.limit)
return select
--- 392,404 ----
if self.whereClause is not NoDefault:
! select += " WHERE %s" % sqlrepr(self.whereClause, db)
if self.groupBy is not NoDefault:
! select += " GROUP BY %s" % sqlrepr(self.groupBy, db)
if self.having is not NoDefault:
! select += " HAVING %s" % sqlrepr(self.having, db)
if self.orderBy is not NoDefault:
! select += " ORDER BY %s" % sqlrepr(self.orderBy, db)
if self.limit is not NoDefault:
! select += " LIMIT %s" % sqlrepr(self.limit, db)
return select
***************
*** 413,417 ****
else:
self.valueList = [values]
! def sqlRepr(self):
if not self.valueList:
return ''
--- 415,419 ----
else:
self.valueList = [values]
! def __sqlrepr__(self, db):
if not self.valueList:
return ''
***************
*** 437,441 ****
elif not allowNonDict:
raise TypeError, "You can't mix non-dictionaries with dictionaries in an INSERT if you don't provide a template (%s)" % repr(value)
! insert += "(%s)" % ", ".join(map(sqlRepr, value))
return insert
--- 439,443 ----
elif not allowNonDict:
raise TypeError, "You can't mix non-dictionaries with dictionaries in an INSERT if you don't provide a template (%s)" % repr(value)
! insert += "(%s)" % ", ".join([sqlrepr(v, db) for v in value])
return insert
***************
*** 456,460 ****
self.template = template
self.whereClause = where
! def sqlRepr(self):
update = "%s %s" % (self.sqlName(), self.table)
update += " SET"
--- 458,462 ----
self.template = template
self.whereClause = where
! def __sqlrepr__(self, db):
update = "%s %s" % (self.sqlName(), self.table)
update += " SET"
***************
*** 466,470 ****
else:
update += ","
! update += " %s=%s" % (self.template[i], sqlRepr(self.values[i]))
else:
for key, value in self.values.items():
--- 468,472 ----
else:
update += ","
! update += " %s=%s" % (self.template[i], sqlrepr(self.values[i], db))
else:
for key, value in self.values.items():
***************
*** 473,477 ****
else:
update += ","
! update += " %s=%s" % (key, sqlRepr(value))
if self.whereClause is not NoDefault:
update += " WHERE %s" % repr(self.whereClause)
--- 475,479 ----
else:
update += ","
! update += " %s=%s" % (key, sqlrepr(value, db))
if self.whereClause is not NoDefault:
update += " WHERE %s" % repr(self.whereClause)
***************
*** 490,498 ****
raise TypeError, "You must give a where clause or pass in None to indicate no where clause"
self.whereClause = where
! def sqlRepr(self):
if self.whereClause is None:
return "DELETE FROM %s" % self.table
return "DELETE FROM %s WHERE %s" \
! % (self.table, sqlRepr(self.whereClause))
registerConverter(Delete, SQLExprConverter)
--- 492,500 ----
raise TypeError, "You must give a where clause or pass in None to indicate no where clause"
self.whereClause = where
! def __sqlrepr__(self, db):
if self.whereClause is None:
return "DELETE FROM %s" % self.table
return "DELETE FROM %s WHERE %s" \
! % (self.table, sqlrepr(self.whereClause, db))
registerConverter(Delete, SQLExprConverter)
***************
*** 513,520 ****
self.expr = expr
! def sqlRepr(self):
if isinstance(self.expr, DESC):
! return sqlRepr(self.expr.expr)
! return '%s DESC' % sqlRepr(self.expr)
def AND(*ops):
--- 515,522 ----
self.expr = expr
! def __sqlrepr__(self, db):
if isinstance(self.expr, DESC):
! return sqlrepr(self.expr.expr, db)
! return '%s DESC' % sqlrepr(self.expr, db)
def AND(*ops):
|
|
From: <ian...@us...> - 2003-10-11 07:39:47
|
Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv6652/tests
Modified Files:
test_converters.py
Log Message:
* Renamed sqlRepr() function to sqlrepr(), and sqlRepr magic method to
__sqlrepr. Added db argument to both.
* Made string and boolean quoting database-sensitive.
* Added TRUE and FALSE objects, which are distinct from 1 and 0 even on
Python versions without bool types. (True and False are used if they
are distinctive)
Index: test_converters.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/test_converters.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_converters.py 25 Sep 2003 20:40:25 -0000 1.4
--- test_converters.py 11 Oct 2003 07:39:43 -0000 1.5
***************
*** 1,4 ****
import unittest
! from SQLObject.SQLBuilder import sqlRepr
from SQLObject.SQLBuilder import SQLExpression, SQLObjectField, \
Select, Insert, Update, Delete, Replace, \
--- 1,4 ----
import unittest
! from SQLObject.SQLBuilder import sqlrepr, TRUE, FALSE
from SQLObject.SQLBuilder import SQLExpression, SQLObjectField, \
Select, Insert, Update, Delete, Replace, \
***************
*** 28,136 ****
registerConverter(NewTestClass, NewTestClassConverter)
! def _sqlRepr(self):
return '<%s>' % self.__class__.__name__
! SQLExpression.sqlRepr = _sqlRepr
class ConvertersTest(unittest.TestCase):
def test_simple_string(self):
! self.assertEqual(sqlRepr('A String'), "'A String'")
def test_string_newline(self):
! self.assertEqual(sqlRepr('A String\nAnother'), "'A String\\nAnother'")
def test_string_tab(self):
! self.assertEqual(sqlRepr('A String\tAnother'), "'A String\\tAnother'")
def test_string_r(self):
! self.assertEqual(sqlRepr('A String\rAnother'), "'A String\\rAnother'")
def test_string_b(self):
! self.assertEqual(sqlRepr('A String\bAnother'), "'A String\\bAnother'")
def test_string_000(self):
! self.assertEqual(sqlRepr('A String\000Another'), "'A String\\0Another'")
def test_string_(self):
! self.assertEqual(sqlRepr('A String\'Another'), "'A String\\\'Another'")
def test_simple_unicode(self):
! self.assertEqual(sqlRepr(u'A String'), "'A String'")
def test_integer(self):
! self.assertEqual(sqlRepr(10), "10")
def test_float(self):
! self.assertEqual(sqlRepr(10.01), "10.01")
def test_none(self):
! self.assertEqual(sqlRepr(None), "NULL")
def test_list(self):
! self.assertEqual(sqlRepr(['one','two','three']), "('one', 'two', 'three')")
def test_tuple(self):
! self.assertEqual(sqlRepr(('one','two','three')), "('one', 'two', 'three')")
def test_bool(self):
! self.assertEqual(sqlRepr(True), 'True')
! self.assertEqual(sqlRepr(False), 'False')
def test_instance(self):
instance = TestClass()
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_newstyle(self):
instance = NewTestClass()
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_sqlexpr(self):
instance = SQLExpression()
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_sqlobjectfield(self):
instance = SQLObjectField('test', 'test', 'test')
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_select(self):
instance = Select('test')
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_insert(self):
instance = Insert('test', ('test',))
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_update(self):
instance = Update('test', {'test':'test'})
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_delete(self):
instance = Delete('test', None)
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_replace(self):
instance = Replace('test', {'test':'test'})
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_trueclause(self):
instance = SQLTrueClauseClass()
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_op(self):
instance = SQLOp('and', 'this', 'that')
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_call(self):
instance = SQLCall('test', 'test')
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_constant(self):
instance = SQLConstant('test')
! self.assertEqual(sqlRepr(instance), repr(instance))
def test_prefix(self):
instance = SQLPrefix('test', 'test')
! self.assertEqual(sqlRepr(instance), repr(instance))
if __name__ == "__main__":
--- 28,140 ----
registerConverter(NewTestClass, NewTestClassConverter)
! def _sqlrepr(self):
return '<%s>' % self.__class__.__name__
! SQLExpression.sqlrepr = _sqlrepr
class ConvertersTest(unittest.TestCase):
def test_simple_string(self):
! self.assertEqual(sqlrepr('A String'), "'A String'")
def test_string_newline(self):
! self.assertEqual(sqlrepr('A String\nAnother', 'postgres'), "'A String\\nAnother'")
! self.assertEqual(sqlrepr('A String\nAnother', 'sqlite'), "'A String\nAnother'")
def test_string_tab(self):
! self.assertEqual(sqlRepr('A String\tAnother', 'postgres'), "'A String\\tAnother'")
def test_string_r(self):
! self.assertEqual(sqlRepr('A String\rAnother', 'postgres'), "'A String\\rAnother'")
def test_string_b(self):
! self.assertEqual(sqlRepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
def test_string_000(self):
! self.assertEqual(sqlRepr('A String\000Another', 'postgres'), "'A String\\0Another'")
def test_string_(self):
! self.assertEqual(sqlRepr('A String\'Another', 'postgres'), "'A String\\\'Another'")
! self.assertEqual(sqlRepr('A String\'Another', 'firebird'), "'A String''Another'")
def test_simple_unicode(self):
! self.assertEqual(sqlrepr(u'A String', 'postgres'), "'A String'")
def test_integer(self):
! self.assertEqual(sqlrepr(10), "10")
def test_float(self):
! self.assertEqual(sqlrepr(10.01), "10.01")
def test_none(self):
! self.assertEqual(sqlrepr(None), "NULL")
def test_list(self):
! self.assertEqual(sqlrepr(['one','two','three'], 'postgres'), "('one', 'two', 'three')")
def test_tuple(self):
! self.assertEqual(sqlrepr(('one','two','three'), 'postgres'), "('one', 'two', 'three')")
def test_bool(self):
! self.assertEqual(sqlRepr(TRUE, 'postgres'), "'t'")
! self.assertEqual(sqlRepr(FALSE, 'postgres'), "'f'")
! self.assertEqual(sqlRepr(TRUE, 'mysql'), "1")
! self.assertEqual(sqlRepr(FALSE, 'mysql'), "0")
def test_instance(self):
instance = TestClass()
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_newstyle(self):
instance = NewTestClass()
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_sqlexpr(self):
instance = SQLExpression()
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_sqlobjectfield(self):
instance = SQLObjectField('test', 'test', 'test')
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_select(self):
instance = Select('test')
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_insert(self):
instance = Insert('test', ('test',))
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_update(self):
instance = Update('test', {'test':'test'})
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_delete(self):
instance = Delete('test', None)
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_replace(self):
instance = Replace('test', {'test':'test'})
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_trueclause(self):
instance = SQLTrueClauseClass()
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_op(self):
instance = SQLOp('and', 'this', 'that')
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_call(self):
instance = SQLCall('test', 'test')
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_constant(self):
instance = SQLConstant('test')
! self.assertEqual(sqlrepr(instance), repr(instance))
def test_prefix(self):
instance = SQLPrefix('test', 'test')
! self.assertEqual(sqlrepr(instance), repr(instance))
if __name__ == "__main__":
|
|
From: <jr...@us...> - 2003-10-06 00:38:53
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv26668/SQLObject
Modified Files:
Col.py
Log Message:
added minor change to account for the position of NOT NULL when creating an SOEnumCol (firebird only).
Index: Col.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** Col.py 27 Sep 2003 22:56:41 -0000 1.29
--- Col.py 6 Oct 2003 00:37:13 -0000 1.30
***************
*** 196,200 ****
def firebirdCreateSQL(self):
! return ' '.join([self.dbName, self._firebirdType()] + self._extraSQL())
class Col(object):
--- 196,206 ----
def firebirdCreateSQL(self):
! # Ian Sparks pointed out that fb is picky about the order
! # of the NOT NULL clause in a create statement. So, we handle
! # them differently for Enum columns.
! if not isinstance(self, SOEnumCol):
! return ' '.join([self.dbName, self._firebirdType()] + self._extraSQL())
! else:
! return ' '.join([self.dbName] + self._extraSQL() + [self._firebirdType()])
class Col(object):
|
|
From: <ian...@us...> - 2003-10-01 02:42:05
|
Update of /cvsroot/sqlobject/SOWeb In directory sc8-pr-cvs1:/tmp/cvs-serv27582 Modified Files: index-header.ht index.html index.txt Log Message: Changes to index Index: index-header.ht =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/index-header.ht,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index-header.ht 29 Sep 2003 07:25:13 -0000 1.1 --- index-header.ht 1 Oct 2003 02:42:01 -0000 1.2 *************** *** 1,4 **** <center> ! <img src="images/sqlobject-700.png" height="117" width="700"> <br> --- 1,4 ---- <center> ! <img src="images/sqlobject-700.png" height="117" width="700" alt="SQLObject"> <br> *************** *** 7,8 **** --- 7,9 ---- <a class="reference" href="#documentation" id="id15" name="id15">Documentation</a> </center> + Index: index.html =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/index.html,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** index.html 29 Sep 2003 07:23:24 -0000 1.10 --- index.html 1 Oct 2003 02:42:01 -0000 1.11 *************** *** 5,14 **** <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" /> <link rel="stylesheet" href="default.css" type="text/css" /> </head> <body> ! <div class="document"> <center> ! <img src="images/sqlobject-700.png" height="117" width="700"> <br> --- 5,16 ---- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" /> + <title>SQLObject</title> <link rel="stylesheet" href="default.css" type="text/css" /> </head> <body> ! <div class="document" id="sqlobject"> ! <center> ! <img src="images/sqlobject-700.png" height="117" width="700" alt="SQLObject"> <br> *************** *** 17,20 **** --- 19,23 ---- <a class="reference" href="#documentation" id="id15" name="id15">Documentation</a> </center> + <div class="section" id="introduction"> <h1><a name="introduction">Introduction</a></h1> Index: index.txt =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/index.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** index.txt 29 Sep 2003 07:23:24 -0000 1.9 --- index.txt 1 Oct 2003 02:42:01 -0000 1.10 *************** *** 1,4 **** --- 1,10 ---- + +++++++++ + SQLObject + +++++++++ + .. raw:: html :file: index-header.ht + + Introduction |
|
From: <ian...@us...> - 2003-10-01 02:40:50
|
Update of /cvsroot/sqlobject/SOWeb/docs In directory sc8-pr-cvs1:/tmp/cvs-serv27218 Modified Files: build default.css Log Message: Get title back in page Index: build =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/docs/build,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** build 5 Jul 2003 04:47:02 -0000 1.5 --- build 1 Oct 2003 02:40:46 -0000 1.6 *************** *** 7,8 **** --- 7,9 ---- cd .. buildhtml.py --no-toc-backlinks + sed 's!<h1 class=.title.>SQLObject<\/h1>!!g' < index.html > tmp && mv tmp index.html \ No newline at end of file Index: default.css =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/docs/default.css,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 |
|
From: <ian...@us...> - 2003-10-01 01:53:53
|
Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv18791/tests
Modified Files:
SQLObjectTest.py test.py
Log Message:
Firebird fixes:
* "name" is a reserved word; fixed tests.
* Limit/offset (slices)
* columnsFromSchema support
* ALTER TABLE fix
Index: SQLObjectTest.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** SQLObjectTest.py 27 Sep 2003 22:56:14 -0000 1.17
--- SQLObjectTest.py 1 Oct 2003 01:53:48 -0000 1.18
***************
*** 47,54 ****
def firebirdConnection():
! SQLObjectTest.supportDynamic = False
SQLObjectTest.supportAuto = False
SQLObjectTest.supportRestrictedEnum = True
! SQLObjectTest.supportTransactions = False
return FirebirdConnection('localhost', '/var/lib/firebird/data/test.gdb',
user='sysdba', passwd='masterkey')
--- 47,54 ----
def firebirdConnection():
! SQLObjectTest.supportDynamic = True
SQLObjectTest.supportAuto = False
SQLObjectTest.supportRestrictedEnum = True
! SQLObjectTest.supportTransactions = True
return FirebirdConnection('localhost', '/var/lib/firebird/data/test.gdb',
user='sysdba', passwd='masterkey')
Index: test.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** test.py 27 Sep 2003 22:55:40 -0000 1.32
--- test.py 1 Oct 2003 01:53:48 -0000 1.33
***************
*** 27,31 ****
class TestSO1(SQLObject):
! name = StringCol(length=50)
_cacheValues = False
_columns = [
--- 27,31 ----
class TestSO1(SQLObject):
! name = StringCol(length=50, dbName='name_col')
_cacheValues = False
_columns = [
***************
*** 70,74 ****
class TestSO2(SQLObject):
! name = StringCol(length=50)
passwd = StringCol(length=10)
--- 70,74 ----
class TestSO2(SQLObject):
! name = StringCol(length=50, dbName='name_col')
passwd = StringCol(length=10)
***************
*** 82,86 ****
class TestSO3(SQLObject):
! name = StringCol(length=10)
other = ForeignKey('TestSO4', default=None)
other2 = KeyCol(foreignKey='TestSO4', default=None)
--- 82,86 ----
class TestSO3(SQLObject):
! name = StringCol(length=10, dbName='name_col')
other = ForeignKey('TestSO4', default=None)
other2 = KeyCol(foreignKey='TestSO4', default=None)
***************
*** 127,130 ****
--- 127,132 ----
class Names(SQLObject):
+ _table = 'names_table'
+
fname = StringCol(length=30)
lname = StringCol(length=30)
***************
*** 159,163 ****
class IterTest(SQLObject):
! name = StringCol()
class IterationTestCase(SQLObjectTest):
--- 161,165 ----
class IterTest(SQLObject):
! name = StringCol(dbName='name_col')
class IterationTestCase(SQLObjectTest):
***************
*** 239,243 ****
class TestSOTrans(SQLObject):
#_cacheValues = False
! name = StringCol(length=10, alternateID=True)
_defaultOrderBy = 'name'
--- 241,245 ----
class TestSOTrans(SQLObject):
#_cacheValues = False
! name = StringCol(length=10, alternateID=True, dbName='name_col')
_defaultOrderBy = 'name'
***************
*** 371,375 ****
class Person(SQLObject):
! _columns = [StringCol('name', length=100)]
_defaultOrder = 'name'
--- 373,377 ----
class Person(SQLObject):
! _columns = [StringCol('name', length=100, dbName='name_col')]
_defaultOrder = 'name'
***************
*** 608,612 ****
class SyncTest(SQLObject):
! name = StringCol(length=50, alternateID=True)
class ExpireTest(SQLObjectTest):
--- 610,614 ----
class SyncTest(SQLObject):
! name = StringCol(length=50, alternateID=True, dbName='name_col')
class ExpireTest(SQLObjectTest):
***************
*** 621,630 ****
conn = SyncTest._connection
b = SyncTest.byName('bob')
! conn.query("UPDATE sync_test SET name = 'robert' WHERE id = %i"
% b.id)
self.assertEqual(b.name, 'bob')
b.expire()
self.assertEqual(b.name, 'robert')
! conn.query("UPDATE sync_test SET name = 'bobby' WHERE id = %i"
% b.id)
b.sync()
--- 623,632 ----
conn = SyncTest._connection
b = SyncTest.byName('bob')
! conn.query("UPDATE sync_test SET name_col = 'robert' WHERE id = %i"
% b.id)
self.assertEqual(b.name, 'bob')
b.expire()
self.assertEqual(b.name, 'robert')
! conn.query("UPDATE sync_test SET name_col = 'bobby' WHERE id = %i"
% b.id)
b.sync()
***************
*** 637,643 ****
class SOValidation(SQLObject):
! name = StringCol(validator=Validator.PlainText(), default='x')
name2 = StringCol(validator=Validator.ConfirmType(str), default='y')
! name3 = StringCol(validator=Validator.Wrapper(fromPython=int), default=100)
class ValidationTest(SQLObjectTest):
--- 639,645 ----
class SOValidation(SQLObject):
! name = StringCol(validator=Validator.PlainText(), default='x', dbName='name_col')
name2 = StringCol(validator=Validator.ConfirmType(str), default='y')
! name3 = IntCol(validator=Validator.Wrapper(fromPython=int), default=100)
class ValidationTest(SQLObjectTest):
|
|
From: <ian...@us...> - 2003-10-01 01:53:53
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv18791/SQLObject
Modified Files:
DBConnection.py
Log Message:
Firebird fixes:
* "name" is a reserved word; fixed tests.
* Limit/offset (slices)
* columnsFromSchema support
* ALTER TABLE fix
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** DBConnection.py 27 Sep 2003 22:56:41 -0000 1.51
--- DBConnection.py 1 Oct 2003 01:53:48 -0000 1.52
***************
*** 182,188 ****
def countSelect(self, select):
! q = "SELECT COUNT(*) FROM %s WHERE %s" % \
! (", ".join(select.tables),
! self.whereClauseForSelect(select, limit=0, order=0))
val = int(self.queryOne(q)[0])
return val
--- 182,188 ----
def countSelect(self, select):
! q = "SELECT COUNT(*) FROM %s WHERE" % \
! ", ".join(select.tables)
! q = self._addWhereClause(select, q, limit=0, order=0)
val = int(self.queryOne(q)[0])
return val
***************
*** 202,208 ****
", ".join(select.tables))
! return q + self.whereClauseForSelect(select)
! def whereClauseForSelect(self, select, limit=1, order=1):
q = str(select.clause)
--- 202,208 ----
", ".join(select.tables))
! return self._addWhereClause(select, q)
! def _addWhereClause(self, select, startSelect, limit=1, order=1):
q = str(select.clause)
***************
*** 242,245 ****
--- 242,247 ----
end = ops.get('end', None)
+ q = startSelect + ' ' + q
+
if limit and (start or end):
# @@: Raising an error might be an annoyance, but some warning is
***************
*** 775,778 ****
--- 777,785 ----
return val
+ def _setAutoCommit(self, conn, auto):
+ # Only _runWithConnection does "autocommit", so we don't
+ # need to worry about that.
+ pass
+
def makeConnection(self):
return kinterbasdb.connect(
***************
*** 839,843 ****
def addColumn(self, tableName, column):
! self.query('ALTER TABLE %s ADD COLUMN %s' %
(tableName,
column.firebirdCreateSQL()))
--- 846,850 ----
def addColumn(self, tableName, column):
! self.query('ALTER TABLE %s ADD %s' %
(tableName,
column.firebirdCreateSQL()))
***************
*** 848,854 ****
def delColumn(self, tableName, column):
! self.query('ALTER TABLE %s DROP COLUMN %s' %
(tableName,
column.dbName))
########################################
--- 855,918 ----
def delColumn(self, tableName, column):
! self.query('ALTER TABLE %s DROP %s' %
(tableName,
column.dbName))
+
+ def columnsFromSchema(self, tableName, soClass):
+ """
+ Look at the given table and create Col instances (or
+ subclasses of Col) for the fields it finds in that table.
+ """
+
+ fieldqry = """\
+ SELECT RDB$RELATION_FIELDS.RDB$FIELD_NAME as field,
+ RDB$TYPES.RDB$TYPE_NAME as t,
+ RDB$FIELDS.RDB$FIELD_LENGTH as flength,
+ RDB$FIELDS.RDB$FIELD_SCALE as fscale,
+ RDB$RELATION_FIELDS.RDB$NULL_FLAG as nullAllowed,
+ RDB$RELATION_FIELDS.RDB$DEFAULT_VALUE as thedefault,
+ RDB$FIELDS.RDB$FIELD_SUB_TYPE as blobtype
+ FROM RDB$RELATION_FIELDS
+ INNER JOIN RDB$FIELDS ON
+ (RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME)
+ INNER JOIN RDB$TYPES ON (RDB$FIELDS.RDB$FIELD_TYPE =
+ RDB$TYPES.RDB$TYPE)
+ WHERE
+ (RDB$RELATION_FIELDS.RDB$RELATION_NAME = '%s')
+ AND (RDB$TYPES.RDB$FIELD_NAME = 'RDB$FIELD_TYPE')"""
+
+ colData = self.queryAll(fieldqry % tableName.upper())
+ results = []
+ for field, t, flength, fscale, nullAllowed, thedefault, blobType in colData:
+ if field == 'id':
+ continue
+ colClass, kw = self.guessClass(t, flength, fscale)
+ kw['name'] = soClass._style.dbColumnToPythonAttr(field)
+ kw['notNone'] = not nullAllowed
+ kw['default'] = thedefault
+ results.append(colClass(**kw))
+ return results
+
+ _intTypes=['INT64', 'SHORT','LONG']
+ _dateTypes=['DATE','TIME','TIMESTAMP']
+
+ def guessClass(self, t, flength, fscale=None):
+ """
+ An internal method that tries to figure out what Col subclass
+ is appropriate given whatever introspective information is
+ available -- both very database-specific.
+ """
+
+ if t in self._intTypes:
+ return Col.IntCol, {}
+ elif t == 'VARYING':
+ return Col.StringCol, {'length': flength}
+ elif t == 'TEXT':
+ return Col.StringCol, {'length': flength,
+ 'varchar': False}
+ elif t in self._dateTypes:
+ return Col.DateTimeCol, {}
+ else:
+ return Col.Col, {}
########################################
|
|
From: <ian...@us...> - 2003-09-29 07:49:04
|
Update of /cvsroot/sqlobject/SOWeb/images In directory sc8-pr-cvs1:/tmp/cvs-serv26292/images Log Message: Directory /cvsroot/sqlobject/SOWeb/images added to the repository |
|
From: <ian...@us...> - 2003-09-29 07:26:51
|
Update of /cvsroot/sqlobject/SOWeb/images In directory sc8-pr-cvs1:/tmp/cvs-serv26752 Added Files: sqlobject-300-blue.png sqlobject-300-green.png sqlobject-300-invert.png sqlobject-300-white.png sqlobject-550.png sqlobject-700.png sqlobject-800.png sqlobject-invert.png sqlobject-white.png sqlobject.png sqlobject.svg sqlobject.svg-sodipodi Log Message: Added images --- NEW FILE: sqlobject-300-blue.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-300-green.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-300-invert.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-300-white.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-550.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-700.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-800.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-invert.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject-white.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sqlobject.svg --- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [ <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"> ]> <!-- Created with Sodipodi ("http://www.sodipodi.com/") --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1" x="0.00000000" y="0.00000000" width="744.094482" height="1052.36218" id="svg548"> <defs id="defs550"> <linearGradient x1="0.00000000" y1="0.00000000" x2="1.00000000" y2="0.00000000" id="linearGradient554" gradientUnits="objectBoundingBox" spreadMethod="pad"> <stop style="stop-color:#000000;stop-opacity:1;" offset="0.00000000" id="stop555" /> <stop style="stop-color:#ffffff;stop-opacity:1;" offset="1.00000000" id="stop556" /> </linearGradient> <linearGradient x1="0.00000000" y1="0.00000000" x2="1.00000000" y2="0.00000000" id="linearGradient557" xlink:href="#linearGradient554" gradientUnits="objectBoundingBox" spreadMethod="pad" /> </defs> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,555.7013,182.0295)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path649" /> <rect width="27.8743572" height="47.6601410" ry="0.00000000" x="666.420898" y="436.291992" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect650" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.873500,0.000000,0.000000,0.873500,521.3927,93.15701)" style="font-size:12;fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:14.3102;stroke-linejoin:round;" id="path595" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.873500,0.000000,0.000000,0.873500,-43.57762,93.15587)" style="font-size:12;fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:14.3102;stroke-linejoin:round;" id="path593" /> <rect width="552.054138" height="100.000046" x="96.2147751" y="397.662964" style="font-size:12;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:12.2158;" id="rect594" /> <rect width="566.531982" height="87.5000000" x="88.3386612" y="404.061798" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect600" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,255.7533,181.6918)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path607" /> <rect width="64.5665894" height="125.044479" x="556.576172" y="331.942291" transform="matrix(0.600000,0.000000,0.000000,0.600000,-17.61180,210.9868)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect608" /> <rect width="24.0686455" height="82.2298965" x="315.082977" y="406.279694" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect609" /> <polygon points="678.207,399.934 711.429,381.933 715.433,344.36 742.82,370.393 779.791,362.591 763.495,396.682 782.34,429.432 744.882,424.469 719.557,452.512 712.703,415.353 678.207,399.934 " transform="matrix(0.600000,0.000000,0.000000,0.600000,-35.39216,208.9630)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="polygon611" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,201.7186,-58.22986)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path578" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,329.4796,180.9532)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path624" /> <ellipse cx="106.645721" cy="563.086609" rx="14.651012" ry="14.991760" transform="matrix(0.600000,0.000000,0.000000,0.600000,364.0406,105.9777)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="path625" /> <rect width="16.1842632" height="58.9448395" x="115.334183" y="501.245270" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect626" /> <rect width="62.6075401" height="18.3137760" x="53.8339767" y="556.356995" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect627" /> <rect width="36.1632957" height="34.6002426" x="391.609222" y="408.666992" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect628" /> <rect width="48.9786835" height="60.5631943" x="131.518433" y="503.800751" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect629" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,142.0343,180.7290)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path585" /> <rect width="45.9684639" height="44.6768036" x="233.382538" y="407.911102" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect595" /> <rect width="61.5564613" height="52.7024384" x="402.707062" y="403.850739" transform="matrix(0.600000,0.000000,0.000000,0.600000,-0.218759,210.3134)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect597" /> <rect width="49.3545303" height="60.7133179" x="339.981659" y="333.078033" transform="matrix(0.600000,0.000000,0.000000,0.600000,-0.218759,210.3134)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect598" /> <rect width="20.8160076" height="41.8808365" x="262.005005" y="447.383087" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect599" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,200.8305,181.7070)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path606" /> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,-10.32342,181.6008)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path553" /> <rect width="69.3865204" height="20.2377319" x="119.430473" y="360.424194" transform="matrix(0.600000,0.000000,0.000000,0.600000,18.61804,212.3417)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect559" /> <rect width="34.4046211" height="15.6119566" x="50.3876419" y="450.568665" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect560" /> <g transform="matrix(0.600000,0.000000,0.000000,0.600000,346.5045,107.5938)" style="font-size:12;" id="g640"> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(1.091875,0.000000,0.000000,1.091874,99.13016,123.5966)" style="fill-rule:evenodd;stroke-width:1pt;" id="path637" /> <rect width="71.7218781" height="22.9987183" x="260.000000" y="536.680115" style="fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect638" /> <rect width="71.7218781" height="22.9987183" x="260.000000" y="575.863098" style="fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect639" /> </g> <g transform="matrix(0.600000,0.000000,0.000000,0.600000,7.529845,211.2961)" style="font-size:12;" id="g586"> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(1.091875,0.000000,0.000000,1.091874,97.35168,-49.30736)" style="fill-rule:evenodd;stroke-width:1pt;" id="path583" /> <rect width="53.9673195" height="29.8747749" x="498.032471" y="52.9684486" transform="matrix(0.665559,0.746346,-0.746346,0.665559,0.000000,0.000000)" style="fill-rule:evenodd;stroke-width:1pt;" id="rect584" /> </g> <g transform="translate(35.77560,-4.770081)" style="font-size:12;" id="g680"> <ellipse cx="151.450073" cy="406.016205" rx="57.240971" ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,446.8023,187.2025)" style="fill-rule:evenodd;stroke-width:1pt;" id="path644" /> <rect width="53.7748337" height="24.9999962" x="536.133972" y="441.112091" style="fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect645" /> </g> <path d="M 160.269485,462.573700 A 57.240971,57.240997 0 1 1 156.971634,349.042145" transform="matrix(0.655125,0.000000,0.000000,0.655124,555.7013,182.0295)" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path601" /> <rect width="28.1883945" height="48.9203377" x="579.183472" y="441.066284" transform="translate(35.77560,-4.770081)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect651" /> <rect width="45.3159485" height="1.71423304" ry="0.85711652" x="610.496643" y="403.779297" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect620" /> <ellipse cx="654.726562" cy="404.256714" rx="2.812500" ry="0.371094" transform="matrix(1.569445,0.000000,0.000000,2.631578,-372.4788,-659.0883)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="path622" /> <ellipse cx="106.054688" cy="404.198120" rx="20.078125" ry="0.390625" transform="matrix(1.899805,0.000000,0.000000,1.050000,-77.36215,-20.22945)" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="path623" /> </svg> --- NEW FILE: sqlobject.svg-sodipodi --- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- Created with Sodipodi ("http://www.sodipodi.com/") --> <svg id="svg548" sodipodi:version="0.32" width="210mm" height="297mm" sodipodi:docbase="/usr/home/ianb/j/professional" sodipodi:docname="/usr/home/ianb/j/professional/sqlobject.svg-sodipodi" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs id="defs550"> <linearGradient id="linearGradient554"> <stop style="stop-color:#000;stop-opacity:1;" offset="0" id="stop555" /> <stop style="stop-color:#fff;stop-opacity:1;" offset="1" id="stop556" /> </linearGradient> <linearGradient xlink:href="#linearGradient554" id="linearGradient557" /> </defs> <sodipodi:namedview id="base" showgrid="true" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path649" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,555.7013,182.0295)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect650" width="27.8743572" height="47.6601410" x="666.420898" y="436.291992" ry="0.00000000" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:14.3102;fill:#ffffff;fill-opacity:0;stroke:#000000;stroke-opacity:1;stroke-dasharray:none;stroke-linejoin:round;" id="path595" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.873500,0.000000,0.000000,0.873500,521.3927,93.15701)" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:14.3102;fill:#ffffff;fill-opacity:0;stroke:#000000;stroke-opacity:1;stroke-dasharray:none;stroke-linejoin:round;" id="path593" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.873500,0.000000,0.000000,0.873500,-43.57762,93.15587)" /> <rect style="font-size:12;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:12.2158;" id="rect594" width="552.054111" height="100.000046" x="96.214773" y="397.662964" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;fill-opacity:1;" id="rect600" width="566.531971" height="87.500000" x="88.338664" y="404.061798" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path607" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,255.7533,181.6918)" /> <rect style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect608" width="64.566589" height="125.044479" x="556.576202" y="331.942291" transform="matrix(0.600000,0.000000,0.000000,0.600000,-17.61180,210.9868)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect609" width="24.068645" height="82.229894" x="315.082984" y="406.279707" /> <polygon sodipodi:type="star" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="polygon611" sodipodi:sides="5" sodipodi:cx="735.065613" sodipodi:cy="397.765930" sodipodi:r1="56.8999100" sodipodi:r2="28.4499550" sodipodi:arg1="3.10347652" sodipodi:arg2="3.73179507" points="678.207,399.934 711.429,381.933 715.433,344.36 742.82,370.393 779.791,362.591 763.495,396.682 782.34,429.432 744.882,424.469 719.557,452.512 712.703,415.353 678.207,399.934 " transform="matrix(0.600000,0.000000,0.000000,0.600000,-35.39216,208.9630)" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path578" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,201.7186,-58.22986)" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path624" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,329.4796,180.9532)" /> <path sodipodi:type="arc" style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="path625" d="M 121.296738 563.086609 A 14.651012 14.991760 0 1 0 91.994705,563.086609 A 14.651 14.9918 0 1 0 121.297 563.087 L 106.645721 563.086609 z" sodipodi:cx="106.645721" sodipodi:cy="563.086609" sodipodi:rx="14.651012" sodipodi:ry="14.991760" transform="matrix(0.600000,0.000000,0.000000,0.600000,364.0406,105.9777)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect626" width="16.184263" height="58.944839" x="115.334183" y="501.245257" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect627" width="62.607542" height="18.313776" x="53.833975" y="556.357025" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect628" width="36.163297" height="34.600242" x="391.609216" y="408.666992" /> <rect style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect629" width="48.978684" height="60.563194" x="131.518438" y="503.800751" transform="matrix(0.600000,0.000000,0.000000,0.600000,357.9076,108.0220)" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path585" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,142.0343,180.7290)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect595" width="45.968465" height="44.676802" x="233.382538" y="407.911105" /> <rect style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect597" width="61.556461" height="52.702438" x="402.707065" y="403.850739" transform="matrix(0.600000,0.000000,0.000000,0.600000,-0.218759,210.3134)" /> <rect style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="rect598" width="49.354530" height="60.713318" x="339.981646" y="333.078033" transform="matrix(0.600000,0.000000,0.000000,0.600000,-0.218759,210.3134)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect599" width="20.816007" height="41.880835" x="262.005000" y="447.383102" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path606" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,200.8305,181.7070)" /> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path553" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,-10.32342,181.6008)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect559" width="69.386520" height="20.237732" x="119.430477" y="360.424194" transform="matrix(0.600000,0.000000,0.000000,0.600000,18.61804,212.3417)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect560" width="34.404622" height="15.611957" x="50.387641" y="450.568665" /> <g id="g640" transform="matrix(0.600000,0.000000,0.000000,0.600000,346.5045,107.5938)"> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path637" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(1.091875,0.000000,0.000000,1.091874,99.13016,123.5966)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;fill-opacity:1;" id="rect638" width="71.721878" height="22.998718" x="259.999992" y="536.680145" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;fill-opacity:1;" id="rect639" width="71.721878" height="22.998718" x="259.999996" y="575.863068" /> </g> <g id="g586" transform="matrix(0.600000,0.000000,0.000000,0.600000,7.529845,211.2961)"> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path583" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(1.091875,0.000000,0.000000,1.091874,97.35168,-49.30736)" /> <rect style="font-size:12;fill:#000000;fill-rule:evenodd;stroke-width:1pt;fill-opacity:1;" id="rect584" width="53.967318" height="29.874774" x="498.032462" y="52.968447" transform="matrix(0.665559,0.746346,-0.746346,0.665559,0.000000,0.000000)" /> </g> <g id="g680" transform="translate(35.77560,-4.770081)"> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path644" d="M 208.691040 406.016205 A 57.240971 57.240997 0 1 0 94.209106,406.016205 A 57.241 57.241 0 1 0 208.691 406.016 L 151.450073 406.016205 z" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,446.8023,187.2025)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect645" width="53.774834" height="24.999997" x="536.133972" y="441.112083" /> </g> <path sodipodi:type="arc" style="font-size:12;fill-rule:evenodd;stroke-width:1pt;" id="path601" d="M 160.269485,462.573700 A 57.240971,57.240997 0 1 1 156.971634,349.042145" sodipodi:cx="151.450073" sodipodi:cy="406.016205" sodipodi:rx="57.240971" sodipodi:ry="57.240997" transform="matrix(0.655125,0.000000,0.000000,0.655124,555.7013,182.0295)" sodipodi:start="1.416105" sodipodi:end="4.809001" sodipodi:open="true" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect651" width="28.188395" height="48.920336" x="579.183472" y="441.066277" transform="translate(35.77560,-4.770081)" /> <rect style="font-size:12;fill:#ffffff;fill-rule:evenodd;stroke-width:1pt;" id="rect620" width="45.315948" height="1.714233" x="610.496613" y="403.779297" ry="0.85711652" /> <path sodipodi:type="arc" style="fill-rule:evenodd;stroke:none;fill:#ffffff;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;" id="path622" d="M 657.539062 404.256714 A 2.812500 0.371094 0 1 0 651.914062,404.256714 A 2.8125 0.371094 0 1 0 657.539 404.257 L 654.726562 404.256714 z" sodipodi:cx="654.726562" sodipodi:cy="404.256714" sodipodi:rx="2.812500" sodipodi:ry="0.371094" transform="matrix(1.569445,0.000000,0.000000,2.631578,-372.4788,-659.0883)" /> <path sodipodi:type="arc" style="fill-rule:evenodd;stroke:none;fill:#ffffff;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;" id="path623" d="M 126.132812 404.198120 A 20.078125 0.390625 0 1 0 85.976562,404.198120 A 20.0781 0.390625 0 1 0 126.133 404.198 L 106.054688 404.198120 z" sodipodi:cx="106.054688" sodipodi:cy="404.198120" sodipodi:rx="20.078125" sodipodi:ry="0.390625" transform="matrix(1.899805,0.000000,0.000000,1.050000,-77.36215,-20.22945)" /> </svg> |
|
From: <ian...@us...> - 2003-09-29 07:25:48
|
Update of /cvsroot/sqlobject/SOWeb In directory sc8-pr-cvs1:/tmp/cvs-serv32223 Added Files: index-header.ht Log Message: added HTML fragment for header --- NEW FILE: index-header.ht --- <center> <img src="images/sqlobject-700.png" height="117" width="700"> <br> <a class="reference" href="#community" id="id12" name="id12">Mailing List, Bugs, etc.</a> | <a class="reference" href="#download" id="id14" name="id14">Download</a> | <a class="reference" href="#documentation" id="id15" name="id15">Documentation</a> </center> |
|
From: <ian...@us...> - 2003-09-29 07:23:38
|
Update of /cvsroot/sqlobject/SOWeb In directory sc8-pr-cvs1:/tmp/cvs-serv31905 Modified Files: index.html index.txt Log Message: Added banner image; changed navigation of front page. Index: index.html =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/index.html,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** index.html 7 Sep 2003 18:21:38 -0000 1.9 --- index.html 29 Sep 2003 07:23:24 -0000 1.10 *************** *** 5,25 **** <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" /> - <title>SQLObject</title> <link rel="stylesheet" href="default.css" type="text/css" /> </head> <body> ! <div class="document" id="sqlobject"> ! <h1 class="title">SQLObject</h1> ! <div class="contents topic" id="contents"> ! <p class="topic-title"><a name="contents">Contents</a></p> ! <ul class="simple"> ! <li><a class="reference" href="#introduction" id="id10" name="id10">Introduction</a></li> ! <li><a class="reference" href="#example" id="id11" name="id11">Example</a></li> ! <li><a class="reference" href="#community" id="id12" name="id12">Community</a></li> ! <li><a class="reference" href="#bugs-patches-etc" id="id13" name="id13">Bugs, patches, etc</a></li> ! <li><a class="reference" href="#download" id="id14" name="id14">Download</a></li> ! <li><a class="reference" href="#documentation" id="id15" name="id15">Documentation</a></li> ! </ul> ! </div> <div class="section" id="introduction"> <h1><a name="introduction">Introduction</a></h1> --- 5,20 ---- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" /> <link rel="stylesheet" href="default.css" type="text/css" /> </head> <body> ! <div class="document"> ! <center> ! <img src="images/sqlobject-700.png" height="117" width="700"> ! <br> ! ! <a class="reference" href="#community" id="id12" name="id12">Mailing List, Bugs, etc.</a> | ! <a class="reference" href="#download" id="id14" name="id14">Download</a> | ! <a class="reference" href="#documentation" id="id15" name="id15">Documentation</a> ! </center> <div class="section" id="introduction"> <h1><a name="introduction">Introduction</a></h1> *************** *** 101,104 **** --- 96,101 ---- <p><a class="reference" href="http://sourceforge.net/cvs/?group_id=74338">Read more about CVS access</a> or <a class="reference" href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/sqlobject">browse CVS online</a>.</p> <p>The author sometimes hangs out in IRC on <tt class="literal"><span class="pre">#webware</span></tt> on <tt class="literal"><span class="pre">irc.freenode.net</span></tt>.</p> + <p>If you'd like to use a SQLObject image on your website, see the <a class="reference" href="http://sqlobject.org/images/">images index</a> for images like:</p> + <p><img alt="SQLObject Image sample" height="50" src="http://sqlobject.org/images/sqlobject-300-white.png" width="300" /></p> </div> <div class="section" id="bugs-patches-etc"> Index: index.txt =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/index.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** index.txt 7 Sep 2003 18:19:58 -0000 1.8 --- index.txt 29 Sep 2003 07:23:24 -0000 1.9 *************** *** 1,7 **** ! ~~~~~~~~~ ! SQLObject ! ~~~~~~~~~ ! ! .. contents:: Introduction --- 1,4 ---- ! .. raw:: html ! :file: index-header.ht Introduction *************** *** 106,109 **** --- 103,115 ---- The author sometimes hangs out in IRC on ``#webware`` on ``irc.freenode.net``. + + If you'd like to use a SQLObject image on your website, see the `images index`_ for images like: + + .. image:: http://sqlobject.org/images/sqlobject-300-white.png + :height: 50 + :width: 300 + :alt: SQLObject Image sample + + .. _`images index`: http://sqlobject.org/images/ Bugs, patches, etc |
|
From: <ian...@us...> - 2003-09-29 07:23:38
|
Update of /cvsroot/sqlobject/SOWeb/docs In directory sc8-pr-cvs1:/tmp/cvs-serv31905/docs Modified Files: default.css Log Message: Added banner image; changed navigation of front page. Index: default.css =================================================================== RCS file: /cvsroot/sqlobject/SOWeb/docs/default.css,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 |
|
From: <ian...@us...> - 2003-09-29 07:20:08
|
Update of /cvsroot/sqlobject/SOWeb/images In directory sc8-pr-cvs1:/tmp/cvs-serv31501 Added Files: index.html Log Message: Added index file for images --- NEW FILE: index.html --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"> <title>SQLObject Images</title> <link rel="stylesheet" href="http://sqlobject.org/default.css" type="text/css" /> </head> <body> <h1>SQLObject Images</h1> <p> These images are for use on any webpage where you want to site SQLObject, or just wherever. <p> An <a href="http://sqlobject.org/images/sqlobject.svg">SVG file<a> is also available, and the <a href="http://sqlobject.org/images/sqlobject.svg-sodipodi">SVG file with Sodipodi annotations</a>. <p> <h2>Opaque backgrounds:</h2> <div style="border: thin black solid; background-color: #999999"> <img src="http://sqlobject.org/images/sqlobject-300-white.png" width="300" height="50"><br> <img src="http://sqlobject.org/images/sqlobject-300-white.png" width="300" height="50"><br> </div><br> <div style="border: thin black solid; background-color: #333333; color: #ffffff"> <img src="http://sqlobject.org/images/sqlobject-300-invert.png" width="300" height="50"><br> <img src="http://sqlobject.org/images/sqlobject-300-invert.png" width="300" height="50"><br> </div><br> <div style="border: thin black solid"> <img src="http://sqlobject.org/images/sqlobject-300-green.png" width="300" height="50"><br> <img src="http://sqlobject.org/images/sqlobject-300-green.png" width="300" height="50"><br> </div><br> <div style="border: thin black solid; background-color: #333333; color: #ffffff"> <img src="http://sqlobject.org/images/sqlobject-300-blue.png" width="300" height="50"><br> <img src="http://sqlobject.org/images/sqlobject-300-blue.png" width="300" height="50"><br> </div><br> <p> <h2>Larger sizes:</h2> <div style="border: thin black solid"> <img src="http://sqlobject.org/images/sqlobject-800.png" width="797" height="133"><br> <img src="http://sqlobject.org/images/sqlobject-800.png" width="797" height="133"><br> </div><br> <div style="border: thin black solid"> <img src="http://sqlobject.org/images/sqlobject-700.png" width="700" height="117"><br> <img src="http://sqlobject.org/images/sqlobject-700.png" width="700" height="117"><br> </div><br> <div style="border: thin black solid"> <img src="http://sqlobject.org/images/sqlobject-550.png" width="551" height="92"><br> <img src="http://sqlobject.org/images/sqlobject-550.png" width="551" height="92"><br> </div><br> <p> <h2>Full-sized transparent PNG:</h2> <div style="border: thin black solid"> <img src="http://sqlobject.org/images/sqlobject.png" width="1019" height="170"><br> <img src="http://sqlobject.org/images/sqlobject.png" width="1019" height="170"> </div> </body> </html> |
|
From: <ian...@us...> - 2003-09-27 22:56:55
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv11176/SQLObject
Modified Files:
Col.py DBConnection.py
Log Message:
Firebird fixes
Index: Col.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Col.py 26 Sep 2003 07:12:59 -0000 1.28
--- Col.py 27 Sep 2003 22:56:41 -0000 1.29
***************
*** 70,77 ****
self.customSQLType = sqlType
# if they don't give us a specific database name for
# the column, we separate the mixedCase into mixed_case
! # and assume that. @@: should be able to define
! # different policies for naming.
if dbName is None:
self.dbName = soClass._style.pythonAttrToDBColumn(self.name)
--- 70,87 ----
self.customSQLType = sqlType
+ self.foreignKey = foreignKey
+ if self.foreignKey:
+ #assert self.name.upper().endswith('ID'), "All foreign key columns must end with 'ID' (%s)" % repr(self.name)
+ if not self.name.upper().endswith('ID'):
+ self.foreignName = self.name
+ self.name = self.name + "ID"
+ else:
+ self.foreignName = self.name[:-2]
+ else:
+ self.foreignName = None
+
# if they don't give us a specific database name for
# the column, we separate the mixedCase into mixed_case
! # and assume that.
if dbName is None:
self.dbName = soClass._style.pythonAttrToDBColumn(self.name)
***************
*** 92,106 ****
self.unique = unique
- self.foreignKey = foreignKey
- if self.foreignKey:
- #assert self.name.upper().endswith('ID'), "All foreign key columns must end with 'ID' (%s)" % repr(self.name)
- if not self.name.upper().endswith('ID'):
- self.foreignName = self.name
- self.name = self.name + "ID"
- else:
- self.foreignName = self.name[:-2]
- else:
- self.foreignName = None
-
self.validator = validator
--- 102,105 ----
***************
*** 245,248 ****
--- 244,253 ----
return 'CHAR(%i)' % self.length
+ def _firebirdType(self):
+ if not self.length:
+ return 'BLOB SUB_TYPE TEXT'
+ else:
+ return self._sqlType()
+
class StringCol(Col):
baseClass = SOStringCol
***************
*** 361,364 ****
--- 366,372 ----
def _sqliteType(self):
+ return self._postgresType()
+
+ def _firebirdType(self):
return self._postgresType()
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** DBConnection.py 26 Sep 2003 20:05:14 -0000 1.50
--- DBConnection.py 27 Sep 2003 22:56:41 -0000 1.51
***************
*** 760,763 ****
--- 760,778 ----
DBAPI.__init__(self, **kw)
+ def _runWithConnection(self, meth, *args):
+ conn = self.getConnection()
+ # @@: Horrible auto-commit implementation. Just horrible!
+ try:
+ conn.begin()
+ except kinterbasdb.ProgrammingError:
+ pass
+ val = meth(conn, *args)
+ try:
+ conn.commit()
+ except kinterbasdb.ProgrammingError:
+ pass
+ self.releaseConnection(conn)
+ return val
+
def makeConnection(self):
return kinterbasdb.connect(
***************
*** 777,784 ****
names = [idName] + names
values = [id] + values
! qry = self._insertSQL(table, names, values)
if self.debug:
self.printDebug(conn, q, 'QueryIns')
! self.query(qry)
if self.debugOutput:
self.printDebug(conn, id, 'QueryIns', 'result')
--- 792,799 ----
names = [idName] + names
values = [id] + values
! q = self._insertSQL(table, names, values)
if self.debug:
self.printDebug(conn, q, 'QueryIns')
! self.query(q)
if self.debugOutput:
self.printDebug(conn, id, 'QueryIns', 'result')
***************
*** 797,801 ****
match = self.limit_re.match(query)
if match and len(match.groups()) == 2:
! return ' '.join([limit_str, match.group(1)])
else:
return query
--- 812,816 ----
match = self.limit_re.match(query)
if match and len(match.groups()) == 2:
! return ' '.join([limit_str, match.group(2)])
else:
return query
|
|
From: <ian...@us...> - 2003-09-27 22:56:28
|
Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv11035/tests
Modified Files:
SQLObjectTest.py
Log Message:
Changed my connection a bit. Firbird transaction support off, but it
probably shouldn't be...
Index: SQLObjectTest.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** SQLObjectTest.py 26 Sep 2003 07:11:46 -0000 1.16
--- SQLObjectTest.py 27 Sep 2003 22:56:14 -0000 1.17
***************
*** 49,54 ****
SQLObjectTest.supportDynamic = False
SQLObjectTest.supportAuto = False
! SQLObjectTest.supportRestrictedEnum = False
! return FirebirdConnection('localhost', '/usr/home/ianb/w/SQLObject/data/firebird.gdb',
user='sysdba', passwd='masterkey')
--- 49,55 ----
SQLObjectTest.supportDynamic = False
SQLObjectTest.supportAuto = False
! SQLObjectTest.supportRestrictedEnum = True
! SQLObjectTest.supportTransactions = False
! return FirebirdConnection('localhost', '/var/lib/firebird/data/test.gdb',
user='sysdba', passwd='masterkey')
|
|
From: <ian...@us...> - 2003-09-27 22:55:53
|
Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv10975/tests
Modified Files:
test.py
Log Message:
* Added a style test. Not very complete yet.
* Some fixes for Firebird tests.
Index: test.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** test.py 26 Sep 2003 07:13:00 -0000 1.31
--- test.py 27 Sep 2003 22:55:40 -0000 1.32
***************
*** 216,220 ****
except IndexError:
pass
! self.failIf(count != len(self.names))
--- 216,220 ----
except IndexError:
pass
! self.assertEqual(count, len(self.names))
***************
*** 692,697 ****
"""
sqliteCreate = postgresCreate
- firebirdCreate = postgresCreate
mysqlDrop = """
--- 692,703 ----
"""
+ firebirdCreate = """
+ CREATE TABLE so_string_id (
+ id VARCHAR(50) NOT NULL PRIMARY KEY,
+ val BLOB SUB_TYPE TEXT
+ )
+ """
+
sqliteCreate = postgresCreate
mysqlDrop = """
***************
*** 718,721 ****
--- 724,756 ----
self.assertEqual(t3, t4)
+
+
+ class AnotherStyle(MixedCaseUnderscoreStyle):
+ def pythonAttrToDBColumn(self, attr):
+ if attr.lower().endswith('id'):
+ return 'id'+MixedCaseUnderscoreStyle.pythonAttrToDBColumn(self, attr[:-2])
+ else:
+ return MixedCaseUnderscoreStyle.pythonAttrToDBColumn(self, attr)
+
+ class SOStyleTest1(SQLObject):
+ a = StringCol()
+ st2 = ForeignKey('SOStyleTest2')
+ _style = AnotherStyle()
+
+ class SOStyleTest2(SQLObject):
+ b = StringCol()
+ _style = AnotherStyle()
+
+ class StyleTest(SQLObjectTest):
+
+ classes = [SOStyleTest1, SOStyleTest2]
+
+
+ def test(self):
+ st1 = SOStyleTest1.new(a='something', st2=None)
+ st2 = SOStyleTest2.new(b='whatever')
+ st1.st2 = st2
+ self.assertEqual(st1._SO_columnDict['st2ID'].dbName, 'idst2')
+ self.assertEqual(st1.st2, st2)
########################################
|
|
From: <ian...@us...> - 2003-09-26 20:54:05
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv29472/SQLObject
Modified Files:
Cache.py DBConnection.py SQLObject.py
Log Message:
Added try:finally: around some locks, so exceptions won't cause
frozen locks.
Index: Cache.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Cache.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Cache.py 7 Sep 2003 07:17:49 -0000 1.9
--- Cache.py 26 Sep 2003 20:05:14 -0000 1.10
***************
*** 120,147 ****
def cull(self):
self.lock.acquire()
! keys = self.cache.keys()
! for i in xrange(self.cullOffset, len(keys), self.cullFraction):
! id = keys[i]
! self.expiredCache[id] = ref(self.cache[id])
! del self.cache[id]
! # This offset tries to balance out which objects we expire, so
! # no object will just hang out in the cache forever.
! self.cullOffset = (self.culldOffset + 1) % self.cullFraction
! self.lock.release()
def expire(self, id):
self.lock.acquire()
! if self.cache.has_key(id):
! del self.cache[id]
! if self.expiredCache.has_key(id):
! del self.expiredCache[id]
! self.lock.release()
def expireAll(self):
self.lock.acquire()
! for key, value in self.cache.items():
! self.expiredCache[key] = ref(obj)
! self.cache = {}
! self.lock.release()
def allIDs(self):
--- 120,154 ----
def cull(self):
self.lock.acquire()
! try:
! keys = self.cache.keys()
! for i in xrange(self.cullOffset, len(keys), self.cullFraction):
! id = keys[i]
! self.expiredCache[id] = ref(self.cache[id])
! del self.cache[id]
! # This offset tries to balance out which objects we
! # expire, so no object will just hang out in the cache
! # forever.
! self.cullOffset = (self.culldOffset + 1) % self.cullFraction
! finally:
! self.lock.release()
def expire(self, id):
self.lock.acquire()
! try:
! if self.cache.has_key(id):
! del self.cache[id]
! if self.expiredCache.has_key(id):
! del self.expiredCache[id]
! finally:
! self.lock.release()
def expireAll(self):
self.lock.acquire()
! try:
! for key, value in self.cache.items():
! self.expiredCache[key] = ref(obj)
! self.cache = {}
! finally:
! self.lock.release()
def allIDs(self):
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** DBConnection.py 26 Sep 2003 07:12:59 -0000 1.49
--- DBConnection.py 26 Sep 2003 20:05:14 -0000 1.50
***************
*** 73,84 ****
def getConnection(self):
self._poolLock.acquire()
! if not self._pool:
! newConn = self.makeConnection()
! self._pool.append(newConn)
! self._connectionNumbers[id(newConn)] = self._connectionCount
! self._connectionCount += 1
! val = self._pool.pop()
! self._poolLock.release()
! return val
def releaseConnection(self, conn):
--- 73,86 ----
def getConnection(self):
self._poolLock.acquire()
! try:
! if not self._pool:
! newConn = self.makeConnection()
! self._pool.append(newConn)
! self._connectionNumbers[id(newConn)] = self._connectionCount
! self._connectionCount += 1
! val = self._pool.pop()
! return val
! finally:
! self._poolLock.release()
def releaseConnection(self, conn):
Index: SQLObject.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** SQLObject.py 26 Sep 2003 07:12:59 -0000 1.59
--- SQLObject.py 26 Sep 2003 20:05:14 -0000 1.60
***************
*** 674,692 ****
return getattr(self, attrName)
except AttributeError:
- self._SO_writeLock.acquire()
try:
! # Maybe, just in the moment since we got the lock,
! # some other thread did a _SO_loadValue and we have
! # the attribute! Let's try and find out! We can keep
! # trying this all day and still beat the performance
! # on the database call (okay, we can keep trying this
! # for a few msecs at least)...
result = getattr(self, attrName)
- except AttributeError:
- pass
- else:
- self._SO_writeLock.release()
return result
! self._expired = False
dbNames = [col.dbName for col in self._SO_columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
--- 674,705 ----
return getattr(self, attrName)
except AttributeError:
try:
! self._SO_writeLock.acquire()
! try:
! # Maybe, just in the moment since we got the lock,
! # some other thread did a _SO_loadValue and we
! # have the attribute! Let's try and find out! We
! # can keep trying this all day and still beat the
! # performance on the database call (okay, we can
! # keep trying this for a few msecs at least)...
! result = getattr(self, attrName)
! except AttributeError:
! pass
! else:
! return result
! self._expired = False
! dbNames = [col.dbName for col in self._SO_columns]
! selectResults = self._connection._SO_selectOne(self, dbNames)
! if not selectResults:
! raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
! self._SO_selectInit(selectResults)
result = getattr(self, attrName)
return result
! finally:
! self._SO_writeLock.release()
!
! def sync(self):
! self._SO_writeLock.acquire()
! try:
dbNames = [col.dbName for col in self._SO_columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
***************
*** 694,710 ****
raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
self._SO_selectInit(selectResults)
! result = getattr(self, attrName)
self._SO_writeLock.release()
- return result
-
- def sync(self):
- self._SO_writeLock.acquire()
- dbNames = [col.dbName for col in self._SO_columns]
- selectResults = self._connection._SO_selectOne(self, dbNames)
- if not selectResults:
- raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
- self._SO_selectInit(selectResults)
- self._expired = False
- self._SO_writeLock.release()
def expire(self):
--- 707,713 ----
raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
self._SO_selectInit(selectResults)
! self._expired = False
! finally:
self._SO_writeLock.release()
def expire(self):
***************
*** 712,723 ****
return
self._SO_writeLock.acquire()
! if self._expired:
self._SO_writeLock.release()
- return
- for column in self._SO_columns:
- delattr(self, instanceName(column.name))
- self._expired = True
- self._connection.cache.expire(self.id, self.__class__)
- self._SO_writeLock.release()
def _SO_setValue(self, name, value, fromPython):
--- 715,727 ----
return
self._SO_writeLock.acquire()
! try:
! if self._expired:
! return
! for column in self._SO_columns:
! delattr(self, instanceName(column.name))
! self._expired = True
! self._connection.cache.expire(self.id, self.__class__)
! finally:
self._SO_writeLock.release()
def _SO_setValue(self, name, value, fromPython):
***************
*** 757,783 ****
self._SO_writeLock.acquire()
! # We have to go through and see if the setters are
! # "plain", that is, if the user has changed their
! # definition in any way (put in something that
! # normalizes the value or checks for consistency,
! # for instance). If so then we have to use plain
! # old setattr() to change the value, since we can't
! # read the user's mind. We'll combine everything
! # else into a single UPDATE, if necessary.
! toUpdate = {}
! for name, value in kw.items():
! if self._SO_plainSetters.has_key(name):
! fromPython = getattr(self, '_SO_fromPython_%s' % name)
! if fromPython:
! value = fromPython(value, self._SO_validatorState)
! toUpdate[name] = value
! if self._cacheValues:
! setattr(self, instanceName(name), value)
! else:
! setattr(self, name, value)
! if toUpdate:
! self._connection._SO_update(self, [(self._SO_columnDict[name].dbName, value) for name, value in toUpdate.items()])
! self._SO_writeLock.release()
def _SO_selectInit(self, row):
--- 761,789 ----
self._SO_writeLock.acquire()
! try:
! # We have to go through and see if the setters are
! # "plain", that is, if the user has changed their
! # definition in any way (put in something that
! # normalizes the value or checks for consistency,
! # for instance). If so then we have to use plain
! # old setattr() to change the value, since we can't
! # read the user's mind. We'll combine everything
! # else into a single UPDATE, if necessary.
! toUpdate = {}
! for name, value in kw.items():
! if self._SO_plainSetters.has_key(name):
! fromPython = getattr(self, '_SO_fromPython_%s' % name)
! if fromPython:
! value = fromPython(value, self._SO_validatorState)
! toUpdate[name] = value
! if self._cacheValues:
! setattr(self, instanceName(name), value)
! else:
! setattr(self, name, value)
! if toUpdate:
! self._connection._SO_update(self, [(self._SO_columnDict[name].dbName, value) for name, value in toUpdate.items()])
! finally:
! self._SO_writeLock.release()
def _SO_selectInit(self, row):
***************
*** 920,925 ****
if not obj._cacheValues:
obj._SO_writeLock.acquire()
! obj._SO_selectInit(result[1:])
! obj._SO_writeLock.release()
return obj
_SO_fetchAlternateID = classmethod(_SO_fetchAlternateID)
--- 926,933 ----
if not obj._cacheValues:
obj._SO_writeLock.acquire()
! try:
! obj._SO_selectInit(result[1:])
! finally:
! obj._SO_writeLock.release()
return obj
_SO_fetchAlternateID = classmethod(_SO_fetchAlternateID)
|