sqlobject-cvs Mailing List for SQLObject (Page 178)
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
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sub...@co...> - 2004-07-29 18:25:50
|
Author: ianb Date: 2004-07-29 10:18:57 -0400 (Thu, 29 Jul 2004) New Revision: 168 Modified: trunk/SQLObject/sqlobject/main.py Log: Fixed little bug in loop Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-07-29 13:18:53 UTC (rev 167) +++ trunk/SQLObject/sqlobject/main.py 2004-07-29 14:18:57 UTC (rev 168) @@ -159,7 +159,7 @@ # _columns where the attribute has been set to None in this # class. If so, then we need to remove that column from # _columns. - for column in newClass._columns: + for column in newClass._columns[:]: if d.has_key(column.name) and d[column.name] is None: newClass._columns.remove(column) =20 |
From: <sub...@co...> - 2004-07-29 17:25:46
|
Author: ianb Date: 2004-07-29 09:18:53 -0400 (Thu, 29 Jul 2004) New Revision: 167 Modified: trunk/SQLObject/sqlobject/dbconnection.py trunk/SQLObject/sqlobject/firebird/firebirdconnection.py trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py trunk/SQLObject/sqlobject/mysql/mysqlconnection.py trunk/SQLObject/sqlobject/postgres/pgconnection.py trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py trunk/SQLObject/sqlobject/sybase/sybaseconnection.py Log: Changed queryInsertID method, so that pgconnection can be provided a custom sequence name for a table/id. Modified: trunk/SQLObject/sqlobject/dbconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/dbconnection.py 2004-07-29 13:18:02 UTC (re= v 166) +++ trunk/SQLObject/sqlobject/dbconnection.py 2004-07-29 13:18:53 UTC (re= v 167) @@ -229,8 +229,8 @@ def transaction(self): return Transaction(self) =20 - def queryInsertID(self, table, idName, id, names, values): - return self._runWithConnection(self._queryInsertID, table, idNam= e, id, names, values) + def queryInsertID(self, soInstance, id, names, values): + return self._runWithConnection(self._queryInsertID, soInstance, = id, names, values) =20 def iterSelect(self, select): return Iteration(self, self.getConnection(), @@ -485,10 +485,10 @@ self.assertActive() return self._dbConnection._queryOne(self._connection, s) =20 - def queryInsertID(self, table, idName, id, names, values): + def queryInsertID(self, soInstance, id, names, values): self.assertActive() return self._dbConnection._queryInsertID( - self._connection, table, idName, id, names, values) + self._connection, soInstance, id, names, values) =20 def iterSelect(self, select): self.assertActive() Modified: trunk/SQLObject/sqlobject/firebird/firebirdconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/firebird/firebirdconnection.py 2004-07-29 1= 3:18:02 UTC (rev 166) +++ trunk/SQLObject/sqlobject/firebird/firebirdconnection.py 2004-07-29 1= 3:18:53 UTC (rev 167) @@ -70,10 +70,13 @@ """Firebird uses 'generators' to create new ids for a table. The users needs to create a generator named GEN_<tablename> for each table this method to work.""" - + table =3D soInstance._table + idName =3D soInstance._idName + sequenceName =3D getattr(soInstance, '_idSequence', + 'GEN_%s' % table) if id is None: - row =3D self.queryOne('SELECT gen_id(GEN_%s,1) FROM rdb$data= base' - % table) + row =3D self.queryOne('SELECT gen_id(%s,1) FROM rdb$database= ' + % sequenceName) id =3D row[0] names =3D [idName] + names values =3D [id] + values Modified: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-07-29 13:18:0= 2 UTC (rev 166) +++ trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-07-29 13:18:5= 3 UTC (rev 167) @@ -106,7 +106,9 @@ conn =3D dbapi.Connection(self.user, self.password, self.database, se= lf.host,**self._getConfigParams(self.sqlmode,self.autoCommit) ) return conn =09 - def _queryInsertID(self, conn, table, idName, id, names, values): + def _queryInsertID(self, conn, soInstance, id, names, values): + table =3D soInstance._table + idName =3D soInstance._idName c =3D conn.cursor() if id is None: c.execute('SELECT %s.NEXTVAL FROM DUAL' % (self.createSequenceName(ta= ble))) @@ -274,4 +276,4 @@ return CurrencyCol,{'size':flength, 'precision':fscale} else: - return col.Col, {} \ No newline at end of file + return col.Col, {} Modified: trunk/SQLObject/sqlobject/mysql/mysqlconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2004-07-29 13:18:0= 2 UTC (rev 166) +++ trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2004-07-29 13:18:5= 3 UTC (rev 167) @@ -40,7 +40,9 @@ else: raise =20 - def _queryInsertID(self, conn, table, idName, id, names, values): + def _queryInsertID(self, conn, soInstance, id, names, values): + table =3D soInstance._table + idName =3D soInstance._idName c =3D conn.cursor() if id is not None: names =3D [idName] + names Modified: trunk/SQLObject/sqlobject/postgres/pgconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/postgres/pgconnection.py 2004-07-29 13:18:0= 2 UTC (rev 166) +++ trunk/SQLObject/sqlobject/postgres/pgconnection.py 2004-07-29 13:18:5= 3 UTC (rev 167) @@ -56,10 +56,14 @@ conn.autocommit(1) return conn =20 - def _queryInsertID(self, conn, table, idName, id, names, values): + def _queryInsertID(self, conn, soInstance, id, names, values): + table =3D soInstance._table + idName =3D soInstance._idName + sequenceName =3D getattr(soInstance, '_idSequence', + '%s_%s_seq' % (table, idName)) c =3D conn.cursor() if id is None: - c.execute("SELECT NEXTVAL('%s_%s_seq')" % (table, idName)) + c.execute("SELECT NEXTVAL('%s')" % sequenceName) id =3D c.fetchone()[0] names =3D [idName] + names values =3D [id] + values Modified: trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-07-29 13:18= :02 UTC (rev 166) +++ trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2004-07-29 13:18= :53 UTC (rev 167) @@ -33,7 +33,9 @@ def makeConnection(self): return self._conn =20 - def _queryInsertID(self, conn, table, idName, id, names, values): + def _queryInsertID(self, conn, soInstance, id, names, values): + table =3D soInstance._table + idName =3D soInstance._idName c =3D conn.cursor() if id is not None: names =3D [idName] + names Modified: trunk/SQLObject/sqlobject/sybase/sybaseconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/sybase/sybaseconnection.py 2004-07-29 13:18= :02 UTC (rev 166) +++ trunk/SQLObject/sqlobject/sybase/sybaseconnection.py 2004-07-29 13:18= :53 UTC (rev 167) @@ -67,7 +67,9 @@ r =3D c.fetchone() return r is not None =20 - def _queryInsertID(self, conn, table, idName, id, names, values): + def _queryInsertID(self, conn, soInstance, id, names, values): + table =3D soInstance._table + idName =3D soInstance._idName c =3D conn.cursor() if id is not None: names =3D [idName] + names |
From: <sub...@co...> - 2004-07-29 17:25:00
|
Author: ianb Date: 2004-07-29 09:18:02 -0400 (Thu, 29 Jul 2004) New Revision: 166 Modified: trunk/SQLObject/sqlobject/main.py Log: * Fix some issues related to subclassing and removing columns=20 from subclasses * Added a new _create method for intercepting row inserts. * Changed insertQueryID usage Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-07-27 16:38:43 UTC (rev 165) +++ trunk/SQLObject/sqlobject/main.py 2004-07-29 13:18:02 UTC (rev 166) @@ -65,12 +65,12 @@ implicitJoins =3D [] for attr, value in d.items(): if isinstance(value, col.Col): - value.setName(attr) + value.name =3D attr implicitColumns.append(value) del d[attr] continue if isinstance(value, joins.Join): - value.setName(attr) + value.joinMethodName =3D attr implicitJoins.append(value) del d[attr] continue @@ -155,7 +155,15 @@ # more. newClass.q =3D sqlbuilder.SQLObjectTable(newClass) =20 - for column in newClass._columns[:]: + # We have to check if there are columns in the inherited + # _columns where the attribute has been set to None in this + # class. If so, then we need to remove that column from + # _columns. + for column in newClass._columns: + if d.has_key(column.name) and d[column.name] is None: + newClass._columns.remove(column) + + for column in newClass._columns: newClass.addColumn(column) if newClass._fromDatabase: newClass.addColumnsFromDatabase() @@ -318,14 +326,17 @@ =20 _lazyUpdate =3D False =20 + # This function is used to coerce IDs into the proper format, + # so you should replace it with str, or another function, if you + # aren't using integer IDs + _idType =3D int + def get(cls, id, connection=3DNone, selectResults=3DNone): =20 assert id is not None, 'None is not a possible id for %s' % cls.= __name + =20 + id =3D cls._idType(id) =20 - # Some databases annoyingly return longs for INT - if isinstance(id, long): - id =3D int(id) - if connection is None: cache =3D cls._connection.cache else: @@ -417,7 +428,7 @@ if cls._cacheValues: # self._SO_class_className is a reference # to the class in question. - getter =3D eval('lambda self: self._SO_foreignKey(self.%= s, self._SO_class_%s)' % (instanceName(name), column.foreignKey)) + getter =3D eval('lambda self: self._SO_foreignKey(self._= SO_loadValue(%r), self._SO_class_%s)' % (instanceName(name), column.forei= gnKey)) else: # Same non-caching version as above. getter =3D eval('lambda self: self._SO_foreignKey(self._= SO_getValue(%s), self._SO_class_%s)' % (repr(name), column.foreignKey)) @@ -810,11 +821,15 @@ self._SO_writeLock =3D threading.Lock() =20 if kw.has_key('id'): - id =3D kw['id'] + id =3D self._idType(kw['id']) del kw['id'] else: id =3D None =20 + self._create(id, **kw) + + def _create(self, id, **kw): + self._SO_creating =3D True self._SO_createValues =3D {} self._SO_validatorState =3D SQLObjectState(self) @@ -861,7 +876,10 @@ getattr(self.__class__, name) except AttributeError: raise TypeError, "%s.new() got an unexpected keyword arg= ument %s" % (self.__class__.__name__, name) - setattr(self, name, value) + try: + setattr(self, name, value) + except AttributeError, e: + raise AttributeError, '%s (with attribute %r)' % (e, nam= e) =20 # Then we finalize the process: self._SO_finishCreate(id) @@ -887,7 +905,7 @@ # Do the insert -- most of the SQL in this case is left # up to DBConnection, since getting a new ID is # non-standard. - id =3D self._connection.queryInsertID(self._table, self._idName, + id =3D self._connection.queryInsertID(self, id, names, values) cache =3D self._connection.cache cache.created(id, self.__class__, self) @@ -1043,6 +1061,14 @@ =20 sqlrepr =3D classmethod(sqlrepr) =20 + def coerceID(cls, value): + if isinstance(value, cls): + return value.id + else: + return self._idType(value) + + coerceID =3D classmethod(coerceID) + def _reprItems(self): items =3D [] for col in self._SO_columns: @@ -1246,7 +1272,10 @@ elif type(obj) is type(1L): return int(obj) elif type(obj) is type(""): - return int(obj) + try: + return int(obj) + except ValueError: + return obj elif obj is None: return None =20 |
From: <sub...@co...> - 2004-07-27 20:45:25
|
Author: ianb Date: 2004-07-27 12:38:43 -0400 (Tue, 27 Jul 2004) New Revision: 165 Modified: trunk/SQLObject/sqlobject/col.py trunk/SQLObject/sqlobject/joins.py Log: Made name and joinMethodName more exposed on Col and Join objects Modified: trunk/SQLObject/sqlobject/col.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/col.py 2004-07-27 16:00:29 UTC (rev 164) +++ trunk/SQLObject/sqlobject/col.py 2004-07-27 16:38:43 UTC (rev 165) @@ -263,16 +263,21 @@ baseClass =3D SOCol =20 def __init__(self, name=3DNone, **kw): - kw['name'] =3D name + self._name =3D name kw['columnDef'] =3D self self.kw =3D kw =20 - def setName(self, value): - assert self.kw['name'] is None, "You cannot change a name after = it has already been set (from %s to %s)" % (self.kw['name'], value) - self.kw['name'] =3D value + def _set_name(self, value): + assert self._name is None, "You cannot change a name after it ha= s already been set (from %s to %s)" % (self.name, value) + self._name =3D value =20 + def _get_name(self): + return self._name + + name =3D property(_get_name, _set_name) + def withClass(self, soClass): - return self.baseClass(soClass=3DsoClass, **self.kw) + return self.baseClass(soClass=3DsoClass, name=3Dself._name, **se= lf.kw) =20 class SOStringCol(SOCol): =20 Modified: trunk/SQLObject/sqlobject/joins.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/joins.py 2004-07-27 16:00:29 UTC (rev 164) +++ trunk/SQLObject/sqlobject/joins.py 2004-07-27 16:38:43 UTC (rev 165) @@ -17,13 +17,19 @@ kw['otherClass'] =3D otherClass kw['joinDef'] =3D self self.kw =3D kw + self._joinMethodName =3D None =20 - def setName(self, value): - assert self.kw.get('joinMethodName') is None or self.kw['joinMet= hodName'] =3D=3D value, "You have already given an explicit joinMethodNam= e (%s), and you are now setting it to %s" % (self.kw['joinMethodName'], v= alue) - self.kw['joinMethodName'] =3D value + def _set_joinMethodName(self, value): + assert self._joinMethodName =3D=3D value or self._joinMethodName= is None, "You have already given an explicit joinMethodName (%s), and yo= u are now setting it to %s" % (self._joinMethodName, value) + self._joinMethodName =3D value =20 + def _get_joinMethodName(self): + return self._joinMethodName + def withClass(self, soClass): - return self.baseClass(soClass=3DsoClass, **self.kw) + return self.baseClass(soClass=3DsoClass, + joinMethodName=3Dself._joinMethodName, + **self.kw) =20 # A join is separate from a foreign key, i.e., it is # many-to-many, or one-to-many where the *other* class |
From: <sub...@co...> - 2004-07-27 20:07:17
|
Author: ianb Date: 2004-07-27 12:00:29 -0400 (Tue, 27 Jul 2004) New Revision: 164 Modified: trunk/SQLObject/sqlobject/converters.py Log: Fixed quoting of Python2.3 datetime objects Modified: trunk/SQLObject/sqlobject/converters.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/converters.py 2004-07-15 12:39:00 UTC (rev = 163) +++ trunk/SQLObject/sqlobject/converters.py 2004-07-27 16:00:29 UTC (rev = 164) @@ -154,12 +154,12 @@ =20 if datetime: def DateTimeConverter(value, db): - return value.strftime("'%Y-%m-%d %H:%M:%s'") + return value.strftime("'%Y-%m-%d %H:%M:%S'") =20 registerConverter(datetime.datetime, DateTimeConverter) =20 def TimeConverter(value, db): - return value.strftime("'%H:%M:%s'") + return value.strftime("'%H:%M:%S'") =20 registerConverter(datetime.time, TimeConverter) =20 |
From: <sub...@co...> - 2004-07-13 14:34:59
|
Author: quarl Date: 2004-07-13 06:29:32 -0400 (Tue, 13 Jul 2004) New Revision: 161 Modified: trunk/SQLObject/sqlobject/__init__.py Log: fix import problems; use "import as" construct Modified: trunk/SQLObject/sqlobject/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/__init__.py 2004-07-09 16:53:03 UTC (rev 16= 0) +++ trunk/SQLObject/sqlobject/__init__.py 2004-07-13 10:29:32 UTC (rev 16= 1) @@ -13,52 +13,37 @@ import warnings warnings.warn(msg, DeprecationWarning, stacklevel=3D2) =20 -import firebird -_firebird =3D firebird -del firebird +import firebird as _firebird def FirebirdConnection(*args, **kw): _warn('FirebirdConnection is deprecated; use connectionForURI("fireb= ird://...") or "from sqlobject.firebird import builder; FirebirdConnectio= n =3D builder()"') - _firebird.builder()(*args, **kw) + return _firebird.builder()(*args, **kw) =20 -import mysql -_mysql =3D mysql -del mysql +import mysql as _mysql def MySQLConnection(*args, **kw): _warn('MySQLConnection is deprecated; use connectionForURI("mysql://= ...") or "from sqlobject.mysql import builder; MySQLConnection =3D builde= r()"') - _mysql.builder()(*args, **kw) + return _mysql.builder()(*args, **kw) =20 -import postgres -_postgres =3D postgres -del postgres +import postgres as _postgres def PostgresConnection(*args, **kw): _warn('PostgresConnection is deprecated; use connectionForURI("postg= res://...") or "from sqlobject.postgres import builder; PostgresConnectio= n =3D builder()"') - _postgres.builder()(*args, **kw) + return _postgres.builder()(*args, **kw) =20 -import sqlite -_sqlite =3D sqlite -del sqlite +import sqlite as _sqlite def SQLiteConnection(*args, **kw): _warn('SQLiteConnection is deprecated; use connectionForURI("sqlite:= //...") or "from sqlobject.sqlite import builder; SQLiteConnection =3D bu= ilder()"') - _sqlite.builder()(*args, **kw) + return _sqlite.builder()(*args, **kw) =20 -import dbm -_dbm =3D dbm -del dbm +import dbm as _dbm def DBMConnection(*args, **kw): _warn('DBMConnection is deprecated; use connectionForURI("dbm://..."= ) or "from sqlobject.dbm import builder; DBMConnection =3D builder()"') - _dbm.builder()(*args, **kw) + return _dbm.builder()(*args, **kw) =20 -import sybase -_sybase =3D sybase -del sybase +import sybase as _sybase def SybaseConnection(*args, **kw): _warn('SybaseConnection is deprecated; use connectionForURI("sybase:= //...") or "from sqlobject.sybase import builder; SybaseConnection =3D bu= ilder()"') - _sybase.builder()(*args, **kw) + return _sybase.builder()(*args, **kw) =20 - -import maxdb -_maxdb =3D maxdb -del maxdb +import maxdb as _maxdb def MaxdbConnection(*args, **kw): _warn('MaxdbConnection is deprecated; use connectionForURI("maxdb://= ...") or "from sqlobject.maxdb import builder; MaxdbConnection =3D builde= r()"') - _maxdb.builder()(*args, **kw) \ No newline at end of file + return _maxdb.builder()(*args, **kw) |
From: <sub...@co...> - 2004-07-09 20:58:02
|
Author: ianb Date: 2004-07-09 12:53:03 -0400 (Fri, 09 Jul 2004) New Revision: 160 Modified: trunk/SQLObject/sqlobject/main.py Log: Fix repr() for objects with non-integer IDs Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-07-09 16:40:20 UTC (rev 159) +++ trunk/SQLObject/sqlobject/main.py 2004-07-09 16:53:03 UTC (rev 160) @@ -1033,7 +1033,7 @@ delete =3D classmethod(delete) =20 def __repr__(self): - return '<%s %i %s>' \ + return '<%s %r %s>' \ % (self.__class__.__name__, self.id, ' '.join(['%s=3D%s' % (name, repr(value)) for name, va= lue in self._reprItems()])) |
From: <sub...@co...> - 2004-07-09 20:45:27
|
Author: ianb Date: 2004-07-09 12:40:20 -0400 (Fri, 09 Jul 2004) New Revision: 159 Modified: trunk/SQLObject/sqlobject/main.py Log: Made _idName *not* inherit (as it really shouldn't, especially when the ID includes the table name). Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-07-09 16:24:19 UTC (rev 158) +++ trunk/SQLObject/sqlobject/main.py 2004-07-09 16:40:20 UTC (rev 159) @@ -147,7 +147,7 @@ newClass._table =3D newClass._style.pythonClassToDBTable(cla= ssName) =20 # If _idName isn't given, use style default - if not hasattr(newClass, '_idName'): + if not d.has_key('_idName'): newClass._idName =3D newClass._style.idForTable(newClass._ta= ble) =20 # We use the magic "q" attribute for accessing lazy |
From: <sub...@co...> - 2004-07-09 20:29:19
|
Author: ianb Date: 2004-07-09 12:24:19 -0400 (Fri, 09 Jul 2004) New Revision: 158 Modified: trunk/SQLObject/sqlobject/main.py Log: Allow _connection to be inherited. Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-06-30 12:24:26 UTC (rev 157) +++ trunk/SQLObject/sqlobject/main.py 2004-07-09 16:24:19 UTC (rev 158) @@ -114,7 +114,8 @@ if hasattr(mod, '__connection__'): connection =3D mod.__connection__ =20 - newClass.setConnection(connection) + if connection or not hasattr(newClass, '_connection'): + newClass.setConnection(connection) =20 # The style object tells how to map between Python # identifiers and Database identifiers: |
From: <sub...@co...> - 2004-06-30 16:28:33
|
Author: sidnei Date: 2004-06-30 08:24:26 -0400 (Wed, 30 Jun 2004) New Revision: 157 Modified: trunk/SQLObject/setup.py trunk/SQLObject/sqlobject/main.py Log: maxdb was missing Modified: trunk/SQLObject/setup.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/setup.py 2004-06-25 12:00:22 UTC (rev 156) +++ trunk/SQLObject/setup.py 2004-06-30 12:24:26 UTC (rev 157) @@ -3,7 +3,7 @@ warnings.filterwarnings("ignore", "Unknown distribution option") =20 subpackages =3D ['dbm', 'firebird', 'include', 'mysql', 'postgres', - 'sqlite', 'sybase'] + 'sqlite', 'sybase', 'maxdb'] =20 import sys # patch distutils if it can't cope with the "classifiers" keyword Modified: trunk/SQLObject/sqlobject/main.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/main.py 2004-06-25 12:00:22 UTC (rev 156) +++ trunk/SQLObject/sqlobject/main.py 2004-06-30 12:24:26 UTC (rev 157) @@ -80,6 +80,7 @@ if not d.has_key('_table'): d['_table'] =3D None =20 + if d.has_key('_connection'): connection =3D d['_connection'] del d['_connection'] |
From: <sub...@co...> - 2004-06-23 22:19:15
|
Author: sweafty Date: 2004-06-23 14:15:47 -0400 (Wed, 23 Jun 2004) New Revision: 155 Added: trunk/SQLObject/debian/ trunk/SQLObject/debian/changelog trunk/SQLObject/debian/control trunk/SQLObject/debian/copyright trunk/SQLObject/debian/docs trunk/SQLObject/debian/examples trunk/SQLObject/debian/rules Log: Debian package is finally done. To build it: svn export svn://colorstudy.com/trunk/SQLObject cd SQLObject fakeroot debian/rules binary To build the source, use debbuild: debuild -rfakeroot -d -us -uc Added: trunk/SQLObject/debian/changelog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/changelog 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/changelog 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,19 @@ +sqlobject (0.6-1) unstable; urgency=3Dlow + + * Debian package will be part of the Colorstudy SVN repository + * Added Build-dependencies : python-{mysqldb,sqlite,psycopg,kinterbasd= b,maxdb} + * Fixed copyright to suit new SQLOBject license + + -- Philippe Normand (phil) <sw...@fr...> Tue, 8 Jun 2004 20:39:16= +0200 + +sqlobject (0.5.2-1) unstable; urgency=3Dlow + + * Update to 0.5.2. + + -- Keisuke URAGO <br...@re...> Sat, 5 Jun 2004 02:32:43 +0900 + +sqlobject (0.3-1) unstable; urgency=3Dlow + + * New upstream version. + + -- Keisuke URAGO <br...@re...> Fri, 09 May 2003 17:06:23 +0900 Added: trunk/SQLObject/debian/control =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/control 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/control 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,19 @@ +Source: sqlobject +Section: python +Priority: optional +Maintainer: Philippe Normand (phil) <sw...@fr...> +Build-Depends: debhelper (>=3D 4.0.0), python-dev (>=3D 2.3) +Standards-Version: 3.6.1 + +Package: python-sqlobject +#Section: python +Architecture: any +Depends: ${python:Depends} +Recommends: python-mysqldb (>=3D 0.9.2-0.4), python-sqlite (>=3D 0.4.3-2= ), python-psycopg (>=3D 1.1.13-1), python-kinterbasdb (>=3D 3.0.1-3.1), p= ython-maxdb (>=3D 7.5.00.12-1) +Description: An object-relational mapper for Python + It allows you to translate RDBMS table rows into Python objects, + and manipulate those objects to transparently manipulate the=20 + database. + . + Homepage: http://sqlobject.org + Added: trunk/SQLObject/debian/copyright =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/copyright 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/copyright 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,11 @@ +This package was debianized by Keisuke URAGO <br...@re...> on +Fri, 09 May 2003 17:06:23 +0900 + +It was downloaded from http://sourceforge.net/projects/sqlobject + +Upstream Author: Ian Bicking <ia...@co...> + +Copyright: PSF + +The Python Software Foundation License can be downloaded from +http://www.opensource.org/licenses/PythonSoftFoundation.php Added: trunk/SQLObject/debian/docs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/docs 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/docs 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,2 @@ +README.txt +docs/ Added: trunk/SQLObject/debian/examples =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/examples 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/examples 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,2 @@ +examples/* +tests/ Added: trunk/SQLObject/debian/rules =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/debian/rules 2004-06-19 10:53:00 UTC (rev 154) +++ trunk/SQLObject/debian/rules 2004-06-23 18:15:47 UTC (rev 155) @@ -0,0 +1,61 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=3D1 + + +PYTHON=3Dpython + +configure: configure-stamp +configure-stamp: + dh_testdir + #$(PYTHON) config_unix.py --prefix /usr + #$(PYTHON) setup.py config + touch configure-stamp + +build: build-stamp +build-stamp: configure-stamp=20 + dh_testdir + $(PYTHON) setup.py build + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + -$(PYTHON) setup.py clean --all + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(PYTHON) setup.py install --prefix $(CURDIR)/debian/python-sqlobject/u= sr + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs -X.svn + dh_installexamples -X.svn + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_makeshlibs -V + dh_python + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb -X.svn + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure Property changes on: trunk/SQLObject/debian/rules ___________________________________________________________________ Name: svn:executable + * |
From: <sub...@co...> - 2004-06-19 14:56:03
|
Author: sidnei Date: 2004-06-19 06:53:00 -0400 (Sat, 19 Jun 2004) New Revision: 154 Modified: trunk/SQLObject/sqlobject/dbconnection.py Log: Ops, this change shouldn't have med it. Modified: trunk/SQLObject/sqlobject/dbconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/dbconnection.py 2004-06-19 10:42:01 UTC (re= v 153) +++ trunk/SQLObject/sqlobject/dbconnection.py 2004-06-19 10:53:00 UTC (re= v 154) @@ -553,8 +553,7 @@ self._obsolete =3D False self._connection =3D self._dbConnection.getConnection() =20 - def __xdel__(self): - # XXX Was getting excessive recursion here + def __del__(self): if self._obsolete: return self.rollback() |
From: <sub...@co...> - 2004-06-19 14:45:09
|
Author: sidnei Date: 2004-06-19 06:42:01 -0400 (Sat, 19 Jun 2004) New Revision: 153 Modified: trunk/SQLObject/sqlobject/col.py trunk/SQLObject/sqlobject/converters.py trunk/SQLObject/sqlobject/dbconnection.py trunk/SQLObject/sqlobject/include/validators.py trunk/SQLObject/sqlobject/sybase/sybaseconnection.py trunk/SQLObject/tests/SQLObjectTest.py trunk/SQLObject/tests/test.py Log: Changes to get it to work with sybase. Modified: trunk/SQLObject/sqlobject/col.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/col.py 2004-06-15 11:17:42 UTC (rev 152) +++ trunk/SQLObject/sqlobject/col.py 2004-06-19 10:42:01 UTC (rev 153) @@ -304,6 +304,12 @@ else: return 'CHAR(%i)' % self.length =20 + def _sybaseType(self): + type =3D self._sqlType() + if not self.notNone and not self.alternateID: + type +=3D ' NULL' + return type + def _firebirdType(self): if not self.length: return 'BLOB SUB_TYPE TEXT' @@ -401,7 +407,7 @@ return 'INT' =20 def _sybaseType(self): - return 'INT' + return 'NUMERIC(18,0) NULL' =20 def _firebirdType(self): return 'INT' @@ -445,7 +451,7 @@ return sql =20 def sybaseCreateSQL(self): - from SQLObject import findClass + from sqlobject.main import findClass sql =3D SOKeyCol.sybaseCreateSQL(self) other =3D findClass(self.foreignKey) tName =3D other._table Modified: trunk/SQLObject/sqlobject/converters.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/converters.py 2004-06-15 11:17:42 UTC (rev = 152) +++ trunk/SQLObject/sqlobject/converters.py 2004-06-19 10:42:01 UTC (rev = 153) @@ -89,10 +89,10 @@ lookupConverter =3D converters.lookupConverter =20 def StringLikeConverter(value, db): - if db in ('mysql', 'postgres', 'sybase'): + if db in ('mysql', 'postgres'): for orig, repl in sqlStringReplace: value =3D value.replace(orig, repl) - elif db in ('sqlite', 'firebird','maxdb'): + elif db in ('sqlite', 'firebird', 'sybase', 'maxdb'): value =3D value.replace("'", "''") else: assert 0, "Database %s unknown" % db Modified: trunk/SQLObject/sqlobject/dbconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/dbconnection.py 2004-06-15 11:17:42 UTC (re= v 152) +++ trunk/SQLObject/sqlobject/dbconnection.py 2004-06-19 10:42:01 UTC (re= v 153) @@ -553,7 +553,8 @@ self._obsolete =3D False self._connection =3D self._dbConnection.getConnection() =20 - def __del__(self): + def __xdel__(self): + # XXX Was getting excessive recursion here if self._obsolete: return self.rollback() Modified: trunk/SQLObject/sqlobject/include/validators.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/include/validators.py 2004-06-15 11:17:42 U= TC (rev 152) +++ trunk/SQLObject/sqlobject/include/validators.py 2004-06-19 10:42:01 U= TC (rev 153) @@ -591,9 +591,10 @@ string. """ =20 - def __init__(self, max=3DNone, min=3DNone, **kw): + def __init__(self, max=3DNone, min=3DNone, strip_spaces=3DNone, **kw= ): self.max =3D max self.min =3D min + self.strip_spaces =3D strip_spaces FancyValidator.__init__(self, **kw) =20 def validatePython(self, value, state): @@ -607,6 +608,11 @@ if value =3D=3D 0: return str(value) return "" =20 + def _toPython(self, value, state): + if self.strip_spaces: + return value.strip() + return value + class Set(FancyValidator): """This is for when you think you may return multiple values for a certain field. This way the result will always be a Modified: trunk/SQLObject/sqlobject/sybase/sybaseconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/sybase/sybaseconnection.py 2004-06-15 11:17= :42 UTC (rev 152) +++ trunk/SQLObject/sqlobject/sybase/sybaseconnection.py 2004-06-19 10:42= :01 UTC (rev 153) @@ -3,26 +3,31 @@ =20 class SybaseConnection(DBAPI): =20 - supportTransactions =3D True + supportTransactions =3D False dbName =3D 'sybase' schemes =3D [dbName] =20 def __init__(self, db, user, passwd=3D'', host=3D'localhost', - autoCommit=3D0, **kw): + locking=3D1, **kw): + db =3D db.strip('/') global Sybase if Sybase is None: import Sybase + Sybase._ctx.debug =3D 0 from Sybase import NumericType - from Converters import registerConverter, IntConverter + from sqlobject.converters import registerConverter, IntConve= rter registerConverter(NumericType, IntConverter) - if not autoCommit and not kw.has_key('pool'): - # Pooling doesn't work with transactions... - kw['pool'] =3D 0 - self.autoCommit=3DautoCommit + self.locking =3D int(locking) self.host =3D host self.db =3D db self.user =3D user self.passwd =3D passwd + autoCommit =3D kw.get('autoCommit') + if autoCommit: + autoCommmit =3D int(autoCommit) + else: + autoCommit =3D None + kw['autoCommit'] =3D autoCommit DBAPI.__init__(self, **kw) =20 def connectionFromURI(cls, uri): @@ -42,20 +47,45 @@ =20 def makeConnection(self): return Sybase.connect(self.host, self.user, self.passwd, - database=3Dself.db, auto_commit=3Dself.aut= oCommit) + database=3Dself.db, auto_commit=3Dself.aut= oCommit, + locking=3Dself.locking) =20 + =20 + HAS_IDENTITY =3D """ + SELECT col.name, col.status, obj.name + FROM syscolumns col + JOIN sysobjects obj + ON obj.id =3D col.id + WHERE obj.name =3D '%s' + AND (col.status & 0x80) =3D 0x80 + =20 + """ + def _hasIdentity(self, conn, table): + query =3D self.HAS_IDENTITY % table + c =3D conn.cursor() + c.execute(query) + r =3D c.fetchone() + return r is not None + =20 def _queryInsertID(self, conn, table, idName, id, names, values): c =3D conn.cursor() if id is not None: names =3D [idName] + names values =3D [id] + values - c.execute('SET IDENTITY_INSERT %s ON' % table) - else: - c.execute('SET IDENTITY_INSERT %s OFF' % table) + + has_identity =3D self._hasIdentity(conn, table) + if has_identity: + if id is not None: + c.execute('SET IDENTITY_INSERT %s ON' % table) + else: + c.execute('SET IDENTITY_INSERT %s OFF' % table) + q =3D self._insertSQL(table, names, values) if self.debug: print 'QueryIns: %s' % q c.execute(q) + if has_identity: + c.execute('SET IDENTITY_INSERT %s OFF' % table) if id is None: id =3D self.insert_id(conn) if self.debugOutput: @@ -70,7 +100,7 @@ return col.sybaseCreateSQL() =20 def createIDColumn(self, soClass): - return '%s NUMERIC(18,0) IDENTITY' % soClass._idName + return '%s NUMERIC(18,0) IDENTITY UNIQUE' % soClass._idName =20 def joinSQLType(self, join): return 'NUMERIC(18,0) NOT NULL' @@ -110,6 +140,9 @@ results.append(colClass(**kw)) return results =20 + def _setAutoCommit(self, conn, auto): + conn.auto_commit =3D auto + def guessClass(self, t): if t.startswith('int'): return col.IntCol, {} Modified: trunk/SQLObject/tests/SQLObjectTest.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/tests/SQLObjectTest.py 2004-06-15 11:17:42 UTC (rev 1= 52) +++ trunk/SQLObject/tests/SQLObjectTest.py 2004-06-19 10:42:01 UTC (rev 1= 53) @@ -46,8 +46,8 @@ SQLObjectTest.supportDynamic =3D False SQLObjectTest.supportAuto =3D False SQLObjectTest.supportRestrictedEnum =3D False - SQLObjectTest.supportTransactions =3D True - return 'sybase://sa:sybasesa@localhost/test' + SQLObjectTest.supportTransactions =3D False + return 'sybase://test:test123@sybase/test?autoCommit=3D0' =20 def firebirdConnection(): SQLObjectTest.supportDynamic =3D True @@ -97,9 +97,12 @@ __connection__.debug =3D True __connection__.debugOuput =3D self.debugOutput =20 - for c in self.classes: + classes =3D self.classes[:] + [self] + r_classes =3D classes[:] + r_classes.reverse() + for c in classes: c._connection =3D __connection__ - for c in self.classes + [self]: + for c in r_classes: if hasattr(c, '%sDrop' % self.databaseName): if __connection__.tableExists(c._table): sql =3D getattr(c, '%sDrop' % self.databaseName) @@ -112,6 +115,7 @@ elif hasattr(c, 'dropTable'): c.dropTable(ifExists=3DTrue, cascade=3DTrue) =20 + for c in classes: if hasattr(c, '%sCreate' % self.databaseName): if not __connection__.tableExists(c._table): sql =3D getattr(c, '%sCreate' % self.databaseName) @@ -133,7 +137,9 @@ def tearDown(self): unittest.TestCase.tearDown(self) __connection__.debug =3D 0 - for c in self.classes: + classes =3D self.classes[:] + classes.reverse() + for c in classes: if hasattr(c, 'drop'): __connection__.query(c.drop) =20 Modified: trunk/SQLObject/tests/test.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/tests/test.py 2004-06-15 11:17:42 UTC (rev 152) +++ trunk/SQLObject/tests/test.py 2004-06-19 10:42:01 UTC (rev 153) @@ -20,6 +20,8 @@ from sqlobject.include import validators from sqlobject import classregistry from mx import DateTime +global curr_db +curr_db =3D None =20 ######################################## ## Basic operation @@ -57,7 +59,7 @@ bob =3D self.MyClass.selectBy(name=3D'bob')[0] testString =3D 'hey\nyou\\can\'t you see me?\t' bob.name =3D testString - self.assertEqual(bob.name, testString) + self.failUnless(bob.name =3D=3D testString, (bob.name, testStrin= g)) =20 =20 class TestCaseGetSet(TestCase1): @@ -103,7 +105,7 @@ =20 class TestCase34(SQLObjectTest): =20 - classes =3D [TestSO3, TestSO4] + classes =3D [TestSO4, TestSO3] =20 def testForeignKey(self): tc3 =3D TestSO3(name=3D'a') @@ -189,6 +191,9 @@ self.assertEqual(TestSO7.select().count(), 0) =20 def testForeignKeyDropTableCascade(self): + if curr_db =3D=3D 'sybase': + # XXX This test doesn't pass with sybase. + return tc5a =3D TestSO5(name=3D'a') tc6a =3D TestSO6(name=3D'1') tc5a.other =3D tc6a @@ -526,7 +531,7 @@ self.assertEqual(func([ c.n1 for c in counters]), value) =20 def test1(self): - self.accumulateEqual(sum,Counter2.select('n1', orderBy=3D'n1'), + self.accumulateEqual(sum,Counter2.select(orderBy=3D'n1'), sum(range(10)) * 10) =20 def test2(self): @@ -627,7 +632,7 @@ first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, age INT DEFAULT 0, - created VARCHAT(40) NOT NULL, + created VARCHAR(40) NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL ) """ @@ -873,6 +878,13 @@ ) """ =20 + sybaseCreate =3D """ + CREATE TABLE so_string_id ( + id VARCHAR(50) UNIQUE, + val VARCHAR(50) NULL + ) + """ + firebirdCreate =3D """ CREATE TABLE so_string_id ( id VARCHAR(50) NOT NULL PRIMARY KEY, @@ -925,7 +937,7 @@ =20 class StyleTest(SQLObjectTest): =20 - classes =3D [SOStyleTest1, SOStyleTest2] + classes =3D [SOStyleTest2, SOStyleTest1] =20 =20 def test(self): @@ -1201,6 +1213,7 @@ if dbs =3D=3D ['all']: dbs =3D supportedDatabases() for db in dbs: + curr_db =3D db setDatabaseType(db) print 'Testing %s' % db try: |
From: <sub...@co...> - 2004-06-15 15:20:28
|
Author: ahmedmo Date: 2004-06-15 07:17:42 -0400 (Tue, 15 Jun 2004) New Revision: 152 Modified: trunk/SQLObject/sqlobject/col.py Log: Modified: trunk/SQLObject/sqlobject/col.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/col.py 2004-06-14 09:11:10 UTC (rev 151) +++ trunk/SQLObject/sqlobject/col.py 2004-06-15 11:17:42 UTC (rev 152) @@ -534,7 +534,7 @@ def _firebirdType(self): return 'TIMESTAMP' =20 - def _maxdbType(self): + def _maxdbType(self): return 'TIMESTAMP' =20 class DateTimeCol(Col): @@ -557,8 +557,8 @@ def _firebirdType(self): return 'DATE' =20 - def _maxdbType(self): - return 'DATE' + def _maxdbType(self): + return 'DATE' =20 class DateCol(Col): baseClass =3D SODateCol |
From: <sub...@co...> - 2004-06-14 13:13:43
|
Author: ahmedmo Date: 2004-06-14 05:11:10 -0400 (Mon, 14 Jun 2004) New Revision: 151 Removed: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.pyc Log: Removed file/folder Deleted: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.pyc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) |
From: <sub...@co...> - 2004-06-14 13:13:38
|
Author: ahmedmo Date: 2004-06-14 05:11:03 -0400 (Mon, 14 Jun 2004) New Revision: 150 Removed: trunk/SQLObject/sqlobject/maxdb/__init__.pyc Log: Removed file/folder Deleted: trunk/SQLObject/sqlobject/maxdb/__init__.pyc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) |
From: <sub...@co...> - 2004-06-14 13:12:58
|
Author: ahmedmo Date: 2004-06-14 05:10:24 -0400 (Mon, 14 Jun 2004) New Revision: 149 Modified: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py Log: Modified: trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-06-14 09:09:4= 1 UTC (rev 148) +++ trunk/SQLObject/sqlobject/maxdb/maxdbconnection.py 2004-06-14 09:10:2= 4 UTC (rev 149) @@ -1,5 +1,6 @@ """ -Contributed by Edigram SAS,Paris=20 +Contributed by Edigram SAS,Paris France +Tel:01 44 77 94 00 Ahmed MOHAMED ALI <ahm...@ya...> 27 April 2004 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
From: <sub...@co...> - 2004-06-14 13:12:16
|
Author: ahmedmo Date: 2004-06-14 05:09:41 -0400 (Mon, 14 Jun 2004) New Revision: 148 Modified: trunk/SQLObject/sqlobject/maxdb/readme.txt Log: Modified: trunk/SQLObject/sqlobject/maxdb/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/maxdb/readme.txt 2004-06-14 09:06:19 UTC (r= ev 147) +++ trunk/SQLObject/sqlobject/maxdb/readme.txt 2004-06-14 09:09:41 UTC (r= ev 148) @@ -1,3 +1,12 @@ +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Author: <ah...@wa...> +Edigram SA - Paris France +Tel:0144779400 + SAPDBAPI installation=20 --------------------- The sapdb module can be downloaded from: @@ -16,3 +25,6 @@ =20 uncompress the archive and add the sapdb directory path to your PYTHONPA= TH. =20 + + + |
From: <sub...@co...> - 2004-06-14 13:08:53
|
Author: ahmedmo Date: 2004-06-14 05:06:19 -0400 (Mon, 14 Jun 2004) New Revision: 147 Added: trunk/SQLObject/sqlobject/maxdb/readme.txt Log: Added: trunk/SQLObject/sqlobject/maxdb/readme.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/maxdb/readme.txt 2004-06-14 08:48:30 UTC (r= ev 146) +++ trunk/SQLObject/sqlobject/maxdb/readme.txt 2004-06-14 09:06:19 UTC (r= ev 147) @@ -0,0 +1,18 @@ +SAPDBAPI installation=20 +--------------------- +The sapdb module can be downloaded from: + +Win32 +------- + +ftp://ftp.sap.com/pub/sapdb/bin/win/sapdb-python-win32-7.4.03.31a.zip=20 + + +Linux=20 +------ + +ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-python-linux-i386-7.4.03.31a= .tgz=20 + + +uncompress the archive and add the sapdb directory path to your PYTHONPA= TH. + |
From: <sub...@co...> - 2004-06-14 12:51:03
|
Author: ahmedmo Date: 2004-06-14 04:48:30 -0400 (Mon, 14 Jun 2004) New Revision: 146 Removed: trunk/SQLObject/converters.py Log: Removed file/folder Deleted: trunk/SQLObject/converters.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/converters.py 2004-06-14 08:48:23 UTC (rev 145) +++ trunk/SQLObject/converters.py 2004-06-14 08:48:30 UTC (rev 146) @@ -1,183 +0,0 @@ -try: - import mx.DateTime.ISO - origISOStr =3D mx.DateTime.ISO.strGMT - from mx.DateTime import DateTimeType -except ImportError: - try: - import DateTime.ISO - origISOStr =3D DateTime.ISO.strGMT - from DateTime import DateTimeType - except ImportError: - origISOStr =3D None - DateTimeType =3D None -import time -try: - import datetime -except ImportError: - datetime =3D None - -try: - import Sybase - NumericType=3DSybase.NumericType -except ImportError: - NumericType =3D None=20 - -if type(1=3D=3D1) =3D=3D type(1): - class BOOL(object): - def __init__(self, value): - self.value =3D not not value - def __nonzero__(self): - return self.value - def __repr__(self): - if self: - return 'TRUE' - else: - return 'FALSE' - TRUE =3D BOOL(1) - FALSE =3D BOOL(0) -else: - TRUE =3D 1=3D=3D1 - FALSE =3D 0=3D=3D1 - -from types import InstanceType, ClassType, TypeType - -######################################## -## Quoting -######################################## - -sqlStringReplace =3D [ - ('\\', '\\\\'), - ("'", "''"), - ('\000', '\\0'), - ('\b', '\\b'), - ('\n', '\\n'), - ('\r', '\\r'), - ('\t', '\\t'), - ] - -def isoStr(val): - """ - Gets rid of time zone information - (@@: should we convert to GMT?) - """ - val =3D origISOStr(val) - if val.find('+') =3D=3D -1: - return val - else: - return val[:val.find('+')] - -class ConverterRegistry: - - def __init__(self): - self.basic =3D {} - self.klass =3D {} - - def registerConverter(self, typ, func): - if type(typ) is ClassType: - self.klass[typ] =3D func - else: - self.basic[typ] =3D func - - def lookupConverter(self, value, default=3DNone): - if type(value) =3D=3D InstanceType: - # lookup on klasses dict - return self.klass.get(value.__class__, default) - return self.basic.get(type(value), default) - =20 -converters =3D ConverterRegistry() -registerConverter =3D converters.registerConverter -lookupConverter =3D converters.lookupConverter - -def StringLikeConverter(value, db): - if db in ('mysql', 'postgres', 'sybase'): - for orig, repl in sqlStringReplace: - value =3D value.replace(orig, repl) - elif db in ('sqlite', 'firebird','maxdb'): - value =3D value.replace("'", "''") - else: - assert 0, "Database %s unknown" % db - return "'%s'" % value - -registerConverter(type(""), StringLikeConverter) -registerConverter(type(u""), StringLikeConverter) - -def IntConverter(value, db): - return repr(int(value)) - -registerConverter(type(1), IntConverter) -registerConverter(type(0L), IntConverter) - -if NumericType: - registerConverter(NumericType, 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) - -registerConverter(type(1.0), FloatConverter) - -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) -registerConverter(type([]), SequenceConverter) - -if hasattr(time, 'struct_time'): - def StructTimeConverter(value, db): - return time.strftime("'%Y-%m-%d %H:%M:%S'", value) - - registerConverter(time.struct_time, StructTimeConverter) - -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=3DNone): - try: - reprFunc =3D obj.__sqlrepr__ - except AttributeError: - converter =3D lookupConverter(obj) - if converter is None: - raise ValueError, "Unknown SQL builtin type: %s for %s" % \ - (type(obj), repr(obj)) - return converter(obj, db) - else: - return reprFunc(db) - - |
From: <sub...@co...> - 2004-06-14 12:51:02
|
Author: ahmedmo Date: 2004-06-14 04:48:23 -0400 (Mon, 14 Jun 2004) New Revision: 145 Removed: trunk/SQLObject/col.py Log: Removed file/folder Deleted: trunk/SQLObject/col.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/col.py 2004-06-14 08:47:01 UTC (rev 144) +++ trunk/SQLObject/col.py 2004-06-14 08:48:23 UTC (rev 145) @@ -1,608 +0,0 @@ -""" -Col -""" - -import sqlbuilder -import re -# Sadly the name "constraints" conflicts with many of the function -# arguments in this module, so we rename it: -import constraints as consts -from include import validators - -NoDefault =3D sqlbuilder.NoDefault -True, False =3D 1=3D=3D1, 0=3D=3D1 - =20 - -######################################## -## Columns -######################################## - -# Col is essentially a column definition, it doesn't have -# much logic to it. -class SOCol(object): - - def __init__(self, - name, - soClass, - dbName=3DNone, - default=3DNoDefault, - foreignKey=3DNone, - alternateID=3DFalse, - alternateMethodName=3DNone, - constraints=3DNone, - notNull=3DNoDefault, - notNone=3DNoDefault, - unique=3DNoDefault, - sqlType=3DNone, - columnDef=3DNone, - validator=3DNone, - immutable=3DFalse, - cascade=3DNone, - lazy=3DFalse, - noCache=3DFalse): - - # This isn't strictly true, since we *could* use backquotes or - # " or something (database-specific) around column names, but - # why would anyone *want* to use a name like that? - # @@: I suppose we could actually add backquotes to the - # dbName if we needed to... - assert sqlbuilder.sqlIdentifier(name), 'Name must be SQL-safe (l= etters, numbers, underscores): %s' \ - % repr(name) - assert name !=3D 'id', 'The column name "id" is reserved for SQL= Object use (and is implicitly created).' - assert name, "You must provide a name for all columns" - - self.columnDef =3D columnDef - - self.immutable =3D immutable - - # cascade can be one of: - # None: no constraint is generated - # True: a CASCADE constraint is generated - # False: a RESTRICT constraint is generated - self.cascade =3D cascade - - if type(constraints) not in (type([]), type(())): - constraints =3D [constraints] - self.constraints =3D self.autoConstraints() + constraints - - self.notNone =3D False - if notNull is not NoDefault: - self.notNone =3D notNull - assert notNone is NoDefault or \ - (not notNone) =3D=3D (not notNull), \ - "The notNull and notNone arguments are aliases, and m= ust not conflict. You gave notNull=3D%r, notNone=3D%r" % (notNull, notNo= ne) - elif notNone is not NoDefault: - self.notNone =3D notNone - if self.notNone: - self.constraints =3D [consts.notNull] + self.constraints - - self.name =3D name - self.soClass =3D None - self._default =3D default - self.customSQLType =3D sqlType - - self.foreignKey =3D foreignKey - if self.foreignKey: - #assert self.name.upper().endswith('ID'), "All foreign key c= olumns must end with 'ID' (%s)" % repr(self.name) - if not self.name.upper().endswith('ID'): - self.foreignName =3D self.name - self.name =3D self.name + "ID" - else: - self.foreignName =3D self.name[:-2] - else: - self.foreignName =3D 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 =3D soClass._style.pythonAttrToDBColumn(self.nam= e) - else: - self.dbName =3D dbName - - # alternateID means that this is a unique column that - # can be used to identify rows - self.alternateID =3D alternateID - if self.alternateID and alternateMethodName is None: - self.alternateMethodName =3D 'by' + self.name[0].capitalize(= ) + self.name[1:] - else: - self.alternateMethodName =3D alternateMethodName - - if unique is NoDefault: - self.unique =3D alternateID - else: - self.unique =3D unique - - self.validator =3D validator - self.noCache =3D noCache - self.lazy =3D lazy - - def _set_validator(self, value): - self._validator =3D value - if self._validator: - self.toPython =3D self._validator.toPython - self.fromPython =3D self._validator.fromPython - else: - self.toPython =3D None - self.fromPython =3D None - - def _get_validator(self): - return self._validator - - validator =3D property(_get_validator, _set_validator) - - def autoConstraints(self): - return [] - - def _get_default(self): - # A default can be a callback or a plain value, - # here we resolve the callback - if self._default is NoDefault: - return NoDefault - elif hasattr(self._default, '__sqlrepr__'): - return self._default - elif callable(self._default): - return self._default() - else: - return self._default - default =3D property(_get_default, None, None) - - def _get_joinName(self): - assert self.name[-2:] =3D=3D 'ID' - return self.name[:-2] - joinName =3D property(_get_joinName, None, None) - - def __repr__(self): - r =3D '<%s %s' % (self.__class__.__name__, self.name) - if self.default is not NoDefault: - r +=3D ' default=3D%s' % repr(self.default) - if self.foreignKey: - r +=3D ' connected to %s' % self.foreignKey - if self.alternateID: - r +=3D ' alternate ID' - if self.notNone: - r +=3D ' not null' - return r + '>' - - def createSQL(self): - return ' '.join([self._sqlType() + self._extraSQL()]) - - def _extraSQL(self): - result =3D [] - if self.notNone or self.alternateID: - result.append('NOT NULL') - if self.unique or self.alternateID: - result.append('UNIQUE') - return result - - def _sqlType(self): - if self.customSQLType is None: - raise ValueError, ("Col %s (%s) cannot be used for automatic= " - "schema creation (too abstract)" % - (self.name, self.__class__)) - else: - return self.customSQLType - - def _mysqlType(self): - return self._sqlType() - - def _postgresType(self): - return self._sqlType() - - def _sqliteType(self): - # SQLite is naturally typeless, so as a fallback it uses - # no type. - try: - return self._sqlType() - except ValueError: - return '' - - def _sybaseType(self): - return self._sqlType() - - def _firebirdType(self): - return self._sqlType() - =20 - def _maxdbType(self): - return self._sqlType() - - def mysqlCreateSQL(self): - return ' '.join([self.dbName, self._mysqlType()] + self._extraSQ= L()) - - def postgresCreateSQL(self): - return ' '.join([self.dbName, self._postgresType()] + self._extr= aSQL()) - - def sqliteCreateSQL(self): - return ' '.join([self.dbName, self._sqliteType()] + self._extraS= QL()) - - def sybaseCreateSQL(self): - return ' '.join([self.dbName, self._sybaseType()] + self._extraS= QL()) - - 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._firebirdType()[0]] + = self._extraSQL() + [self._firebirdType()[1]]) -=09 - def maxdbCreateSQL(self): - return ' '.join([self.dbName, self._maxdbType()] + self._extraSQL= ()) - - def __get__(self, obj, type=3DNone): - if obj is None: - # class attribute, return the descriptor itself - return self - if obj.sqlmeta.obsolete: - raise '@@: figure out the exception for a delete' - if obj.sqlmeta.cacheColumns: - columns =3D obj.sqlmeta._columnCache - if columns is None: - obj.sqlmeta.loadValues() - try: - return columns[name] - except KeyError: - return obj.sqlmeta.loadColumn(self) - else: - return obj.sqlmeta.loadColumn(self) - - def __set__(self, obj, value): - if self.immutable: - raise AttributeError("The column %s.%s is immutable" % - (obj.__class__.__name__, - self.name)) - obj.sqlmeta.setColumn(self, value) - - def __delete__(self, obj): - raise AttributeError("I can't be deleted from %r" % obj) - - -class Col(object): - - baseClass =3D SOCol - - def __init__(self, name=3DNone, **kw): - kw['name'] =3D name - kw['columnDef'] =3D self - self.kw =3D kw - - def setName(self, value): - assert self.kw['name'] is None, "You cannot change a name after = it has already been set (from %s to %s)" % (self.kw['name'], value) - self.kw['name'] =3D value - - def withClass(self, soClass): - return self.baseClass(soClass=3DsoClass, **self.kw) - -class SOStringCol(SOCol): - - # 3-03 @@: What about BLOB? - - def __init__(self, **kw): - self.length =3D popKey(kw, 'length') - self.varchar =3D popKey(kw, 'varchar', 'auto') - if not self.length: - assert self.varchar =3D=3D 'auto' or not self.varchar, \ - "Without a length strings are treated as TEXT, not va= rchar" - self.varchar =3D False - elif self.varchar =3D=3D 'auto': - self.varchar =3D True - - SOCol.__init__(self, **kw) - - def autoConstraints(self): - constraints =3D [consts.isString] - if self.length is not None: - constraints +=3D [consts.MaxLength(self.length)] - return constraints - - def _sqlType(self): - if not self.length: - return 'TEXT' - elif self.varchar: - return 'VARCHAR(%i)' % self.length - else: - return 'CHAR(%i)' % self.length - - def _firebirdType(self): - if not self.length: - return 'BLOB SUB_TYPE TEXT' - else: - return self._sqlType() - =20 - def _maxdbType(self): - if not self.length: - return 'LONG ASCII' - else: - return self._sqlType() - -class StringCol(Col): - baseClass =3D SOStringCol - -class SOIntCol(SOCol): - - # 3-03 @@: support precision, maybe max and min directly - - def autoConstraints(self): - return [consts.isInt] - - def _sqlType(self): - return 'INT' - -class IntCol(Col): - baseClass =3D SOIntCol - -class BoolValidator(validators.Validator): - - def fromPython(self, value, state): - if value: - return sqlbuilder.TRUE - else: - return sqlbuilder.FALSE - - def toPython(self, value, state): - if not value or not int(value): - return sqlbuilder.FALSE - else: - return sqlbuilder.TRUE - -class SOBoolCol(SOCol): - - def __init__(self, **kw): - SOCol.__init__(self, **kw) - self.validator =3D validators.All.join(BoolValidator(), self.val= idator) - - def autoConstraints(self): - return [consts.isBool] - - def _postgresType(self): - return 'BOOL' - - def _mysqlType(self): - return "TINYINT" - - def _sybaseType(self): - return "BIT" - - def _firebirdType(self): - return 'INT' - =20 - def _maxdbType(self): - return "BOOLEAN" - -class BoolCol(Col): - baseClass =3D SOBoolCol - -class SOFloatCol(SOCol): - - # 3-03 @@: support precision (e.g., DECIMAL) - - def autoConstraints(self): - return [consts.isFloat] - - def _sqlType(self): - return 'FLOAT' - -class FloatCol(Col): - baseClass =3D SOFloatCol - -class SOKeyCol(SOCol): - - # 3-03 @@: this should have a simplified constructor - # Should provide foreign key information for other DBs. - - def _mysqlType(self): - return 'INT' - - def _sqliteType(self): - return 'INT' - - def _postgresType(self): - return 'INT' - - def _sybaseType(self): - return 'INT' - - def _firebirdType(self): - return 'INT' - =20 - def _maxdbType(self): - return 'INT' - -class KeyCol(Col): - - baseClass =3D SOKeyCol - -class SOForeignKey(SOKeyCol): - - def __init__(self, **kw): - foreignKey =3D kw['foreignKey'] - style =3D kw['soClass']._style - if not kw.get('name'): - kw['name'] =3D style.instanceAttrToIDAttr(style.pythonClassT= oAttr(foreignKey)) - else: - if not kw['name'].upper().endswith('ID'): - kw['name'] =3D style.instanceAttrToIDAttr(kw['name']) - SOKeyCol.__init__(self, **kw) - - def postgresCreateSQL(self): - from main import findClass - sql =3D SOKeyCol.postgresCreateSQL(self) - if self.cascade is not None: - other =3D findClass(self.foreignKey) - tName =3D other._table - idName =3D other._idName - action =3D self.cascade and 'CASCADE' or 'RESTRICT' - constraint =3D ('CONSTRAINT %(tName)s_exists ' - 'FOREIGN KEY(%(colName)s) ' - 'REFERENCES %(tName)s(%(idName)s) ' - 'ON DELETE %(action)s' % - {'tName':tName, - 'colName':self.dbName, - 'idName':idName, - 'action':action}) - sql =3D ', '.join([sql, constraint]) - return sql - - def sybaseCreateSQL(self): - from SQLObject import findClass - sql =3D SOKeyCol.sybaseCreateSQL(self) - other =3D findClass(self.foreignKey) - tName =3D other._table - idName =3D other._idName - reference =3D ('REFERENCES %(tName)s(%(idName)s) ' % - {'tName':tName, - 'idName':idName}) - sql =3D ' '.join([sql, reference]) - return sql - =20 - def maxdbCreateSQL(self): - from main import findClass - other =3D findClass(self.foreignKey) - fidName =3D self.dbName - #I assume that foreign key name is identical to the id of the referen= ce table =09 - sql =3D ' '.join([fidName, self._maxdbType()]) - tName =3D other._table - idName =3D other._idName - sql=3Dsql + ',' + '\n'=20 - sql=3Dsql + 'FOREIGN KEY (%s) REFERENCES %s(%s)'%(fidName,tName,idNam= e) - return sql - -class ForeignKey(KeyCol): - - baseClass =3D SOForeignKey - - def __init__(self, foreignKey=3DNone, **kw): - KeyCol.__init__(self, foreignKey=3DforeignKey, **kw) - -class SOEnumCol(SOCol): - - def __init__(self, **kw): - self.enumValues =3D popKey(kw, 'enumValues', None) - assert self.enumValues is not None, \ - 'You must provide an enumValues keyword argument' - SOCol.__init__(self, **kw) - - def autoConstraints(self): - return [consts.isString, consts.InList(self.enumValues)] - - def _mysqlType(self): - return "ENUM(%s)" % ', '.join([sqlbuilder.sqlrepr(v, 'mysql') fo= r v in self.enumValues]) - - def _postgresType(self): - length =3D max(map(len, self.enumValues)) - enumValues =3D ', '.join([sqlbuilder.sqlrepr(v, 'postgres') for = v in self.enumValues]) - checkConstraint =3D "CHECK (%s in (%s))" % (self.dbName, enumVal= ues) - return "VARCHAR(%i) %s" % (length, checkConstraint) - - def _sqliteType(self): - return self._postgresType() - - def _sybaseType(self): - return self._postgresType() - - def _firebirdType(self): - length =3D max(map(len, self.enumValues)) - enumValues =3D ', '.join([sqlbuilder.sqlrepr(v, 'firebird') for = v in self.enumValues]) - checkConstraint =3D "CHECK (%s in (%s))" % (self.dbName, enumVal= ues) - #NB. Return a tuple, not a string here - return "VARCHAR(%i)" % (length), checkConstraint -=20 - def _maxdbType(self): - raise "Enum type is not supported" - -class EnumCol(Col): - baseClass =3D SOEnumCol - -class SODateTimeCol(SOCol): - - # 3-03 @@: provide constraints; right now we let the database - # do any parsing and checking. And DATE and TIME? - - def _mysqlType(self): - return 'DATETIME' - - def _postgresType(self): - return 'TIMESTAMP' - - def _sybaseType(self): - return 'DATETIME' - - def _sqliteType(self): - return 'TIMESTAMP' - - def _firebirdType(self): - return 'TIMESTAMP' - =20 - def _maxdbType(self): - return 'TIMESTAMP' - -class DateTimeCol(Col): - baseClass =3D SODateTimeCol - -class SODateCol(SOCol): - - # 3-03 @@: provide constraints; right now we let the database - # do any parsing and checking. And DATE and TIME? - - def _mysqlType(self): - return 'DATE' - - def _postgresType(self): - return 'DATE' - - def _sybaseType(self): - return self._postgresType() - - def _firebirdType(self): - return 'DATE' - =20 - def _maxdbType(self): - return 'DATE' - -class DateCol(Col): - baseClass =3D SODateCol - -class SODecimalCol(SOCol): - - def __init__(self, **kw): - self.size =3D popKey(kw, 'size', NoDefault) - assert self.size is not NoDefault, \ - "You must give a size argument" - self.precision =3D popKey(kw, 'precision', NoDefault) - assert self.precision is not NoDefault, \ - "You must give a precision argument" - SOCol.__init__(self, **kw) - - def _sqlType(self): - return 'DECIMAL(%i, %i)' % (self.size, self.precision) - -class DecimalCol(Col): - baseClass =3D SODecimalCol - -class SOCurrencyCol(SODecimalCol): - - def __init__(self, **kw): - pushKey(kw, 'size', 10) - pushKey(kw, 'precision', 2) - SODecimalCol.__init__(self, **kw) - -class CurrencyCol(DecimalCol): - baseClass =3D SOCurrencyCol - -def popKey(kw, name, default=3DNone): - if not kw.has_key(name): - return default - value =3D kw[name] - del kw[name] - return value - -def pushKey(kw, name, value): - if not kw.has_key(name): - kw[name] =3D value - -all =3D [] -for key, value in globals().items(): - if isinstance(value, type) and issubclass(value, Col): - all.append(key) -__all__ =3D all |
From: <sub...@co...> - 2004-06-14 12:49:34
|
Author: ahmedmo Date: 2004-06-14 04:47:01 -0400 (Mon, 14 Jun 2004) New Revision: 144 Modified: trunk/SQLObject/sqlobject/converters.py Log: Modified: trunk/SQLObject/sqlobject/converters.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/converters.py 2004-06-14 08:46:52 UTC (rev = 143) +++ trunk/SQLObject/sqlobject/converters.py 2004-06-14 08:47:01 UTC (rev = 144) @@ -92,7 +92,7 @@ if db in ('mysql', 'postgres', 'sybase'): for orig, repl in sqlStringReplace: value =3D value.replace(orig, repl) - elif db in ('sqlite', 'firebird'): + elif db in ('sqlite', 'firebird','maxdb'): value =3D value.replace("'", "''") else: assert 0, "Database %s unknown" % db |
From: <sub...@co...> - 2004-06-14 12:49:28
|
Author: ahmedmo Date: 2004-06-14 04:46:52 -0400 (Mon, 14 Jun 2004) New Revision: 143 Modified: trunk/SQLObject/sqlobject/__init__.py Log: Modified: trunk/SQLObject/sqlobject/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/__init__.py 2004-06-14 08:46:43 UTC (rev 14= 2) +++ trunk/SQLObject/sqlobject/__init__.py 2004-06-14 08:46:52 UTC (rev 14= 3) @@ -56,3 +56,9 @@ _sybase.builder()(*args, **kw) =20 =20 +import maxdb +_maxdb =3D maxdb +del maxdb +def MaxdbConnection(*args, **kw): + _warn('MaxdbConnection is deprecated; use connectionForURI("maxdb://= ...") or "from sqlobject.maxdb import builder; MaxdbConnection =3D builde= r()"') + _maxdb.builder()(*args, **kw) \ No newline at end of file |
From: <sub...@co...> - 2004-06-14 12:49:16
|
Author: ahmedmo Date: 2004-06-14 04:46:43 -0400 (Mon, 14 Jun 2004) New Revision: 142 Modified: trunk/SQLObject/sqlobject/col.py Log: Modified: trunk/SQLObject/sqlobject/col.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/col.py 2004-06-14 08:35:02 UTC (rev 141) +++ trunk/SQLObject/sqlobject/col.py 2004-06-14 08:46:43 UTC (rev 142) @@ -202,6 +202,9 @@ =20 def _firebirdType(self): return self._sqlType() + =20 + def _maxdbType(self): + return self._sqlType() =20 def mysqlCreateSQL(self): return ' '.join([self.dbName, self._mysqlType()] + self._extraSQ= L()) @@ -221,8 +224,11 @@ # them differently for Enum columns. if not isinstance(self, SOEnumCol): return ' '.join([self.dbName, self._firebirdType()] + self._= extraSQL()) - else: - return ' '.join([self.dbName] + [self._firebirdType()[0]] + = self._extraSQL() + [self._firebirdType()[1]]) + else: + return ' '.join([self.dbName] + [self._firebirdType()[0]] + = self._extraSQL() + [self._firebirdType()[1]]) +=09 + def maxdbCreateSQL(self): + return ' '.join([self.dbName, self._maxdbType()] + self._extraSQL= ()) =20 def __get__(self, obj, type=3DNone): if obj is None: @@ -303,6 +309,12 @@ return 'BLOB SUB_TYPE TEXT' else: return self._sqlType() + =20 + def _maxdbType(self): + if not self.length: + return 'LONG ASCII' + else: + return self._sqlType() =20 class StringCol(Col): baseClass =3D SOStringCol @@ -354,6 +366,9 @@ =20 def _firebirdType(self): return 'INT' + =20 + def _maxdbType(self): + return "BOOLEAN" =20 class BoolCol(Col): baseClass =3D SOBoolCol @@ -390,6 +405,9 @@ =20 def _firebirdType(self): return 'INT' + =20 + def _maxdbType(self): + return 'INT' =20 class KeyCol(Col): =20 @@ -437,6 +455,18 @@ 'idName':idName}) sql =3D ' '.join([sql, reference]) return sql + =20 + def maxdbCreateSQL(self): + from main import findClass + other =3D findClass(self.foreignKey) + fidName =3D self.dbName + #I assume that foreign key name is identical to the id of the referen= ce table =09 + sql =3D ' '.join([fidName, self._maxdbType()]) + tName =3D other._table + idName =3D other._idName + sql=3Dsql + ',' + '\n'=20 + sql=3Dsql + 'FOREIGN KEY (%s) REFERENCES %s(%s)'%(fidName,tName,idNam= e) + return sql =20 class ForeignKey(KeyCol): =20 @@ -475,8 +505,11 @@ length =3D max(map(len, self.enumValues)) enumValues =3D ', '.join([sqlbuilder.sqlrepr(v, 'firebird') for = v in self.enumValues]) checkConstraint =3D "CHECK (%s in (%s))" % (self.dbName, enumVal= ues) - #NB. Return a tuple, not a string here - return "VARCHAR(%i)" % (length), checkConstraint + #NB. Return a tuple, not a string here + return "VARCHAR(%i)" % (length), checkConstraint +=20 + def _maxdbType(self): + raise "Enum type is not supported" =20 class EnumCol(Col): baseClass =3D SOEnumCol @@ -497,10 +530,13 @@ =20 def _sqliteType(self): return 'TIMESTAMP' - + def _firebirdType(self): - return 'TIMESTAMP' - + return 'TIMESTAMP' + =20 + def _maxdbType(self): + return 'TIMESTAMP' + class DateTimeCol(Col): baseClass =3D SODateTimeCol =20 @@ -517,9 +553,12 @@ =20 def _sybaseType(self): return self._postgresType() - + def _firebirdType(self): - return 'DATE' + return 'DATE' + =20 + def _maxdbType(self): + return 'DATE' =20 class DateCol(Col): baseClass =3D SODateCol |
From: <sub...@co...> - 2004-06-14 12:37:37
|
Author: ahmedmo Date: 2004-06-14 04:35:02 -0400 (Mon, 14 Jun 2004) New Revision: 141 Modified: trunk/SQLObject/converters.py Log: Modified: trunk/SQLObject/converters.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/converters.py 2004-06-14 08:34:16 UTC (rev 140) +++ trunk/SQLObject/converters.py 2004-06-14 08:35:02 UTC (rev 141) @@ -83,7 +83,7 @@ # lookup on klasses dict return self.klass.get(value.__class__, default) return self.basic.get(type(value), default) - + =20 converters =3D ConverterRegistry() registerConverter =3D converters.registerConverter lookupConverter =3D converters.lookupConverter |