sqlobject-cvs Mailing List for SQLObject (Page 190)
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: <ian...@us...> - 2003-04-19 00:06:06
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv5538/SQLObject Modified Files: Col.py Log Message: Fixed Postgres to use TIMESTAMP instead of DATETIME Index: Col.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Col.py 19 Apr 2003 00:04:07 -0000 1.10 --- Col.py 19 Apr 2003 00:06:04 -0000 1.11 *************** *** 236,241 **** # do any parsing and checking. And DATE and TIME? ! def _sqlType(self): return 'DATETIME' --- 236,244 ---- # do any parsing and checking. And DATE and TIME? ! def _mysqlType(self): return 'DATETIME' + + def _postgresType(self): + return 'TIMESTAMP' |
From: <ian...@us...> - 2003-04-19 00:04:11
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv4903/SQLObject Modified Files: Col.py DBConnection.py Log Message: * Added Postgres support for _fromDatabase * Moved guessClass out of Col, into DBConnection classes * Changed tests so Postgres gets tested too Index: Col.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Col.py 11 Apr 2003 16:23:18 -0000 1.9 --- Col.py 19 Apr 2003 00:04:07 -0000 1.10 *************** *** 248,264 **** return value - def guessClass(t): - if t.startswith('int'): - return IntCol, {} - elif t.startswith('varchar'): - return StringCol, {'length': int(t[8:-1])} - elif t.startswith('char'): - return StringCol, {'length': int(t[5:-1]), - 'varchar': False} - elif t.startswith('datetime'): - return DateTimeCol, {} - else: - return Col, {} - _generatePythonNameRE = re.compile('_.') def generatePythonName(name): --- 248,251 ---- Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** DBConnection.py 17 Apr 2003 07:16:09 -0000 1.20 --- DBConnection.py 19 Apr 2003 00:04:08 -0000 1.21 *************** *** 400,404 **** if field == 'id': continue ! colClass, kw = Col.guessClass(t) kw['name'] = Col.generatePythonName(field) kw['notNull'] = not nullAllowed --- 400,404 ---- if field == 'id': continue ! colClass, kw = self.guessClass(t) kw['name'] = Col.generatePythonName(field) kw['notNull'] = not nullAllowed *************** *** 409,412 **** --- 409,426 ---- return results + def guessClass(self, t): + if t.startswith('int'): + return Col.IntCol, {} + elif t.startswith('varchar'): + return Col.StringCol, {'length': int(t[8:-1])} + elif t.startswith('char'): + return Col.StringCol, {'length': int(t[5:-1]), + 'varchar': False} + elif t.startswith('datetime'): + return Col.DateTimeCol, {} + else: + return Col, {} + + class PostgresConnection(DBAPI): *************** *** 478,481 **** --- 492,551 ---- (tableName, column.dbName)) + + def columnsFromSchema(self, tableName): + + keyQuery = """ + SELECT pg_catalog.pg_get_constraintdef(oid) as condef + FROM pg_catalog.pg_constraint r + WHERE r.conrelid = '%s'::regclass AND r.contype = 'f'""" + + colQuery = """ + SELECT a.attname, + pg_catalog.format_type(a.atttypid, a.atttypmod), a.attnotnull, + (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d + WHERE d.adrelid=a.attrelid AND d.adnum = a.attnum) + FROM pg_catalog.pg_attribute a + WHERE a.attrelid ='%s'::regclass + AND a.attnum > 0 AND NOT a.attisdropped + ORDER BY a.attnum""" + + keyData = self.queryAll(keyQuery % tableName) + keyRE = re.compile("\((.)\) REFERENCES (.)\(") + keymap = {} + for (condef,) in keyData: + match = keyRE.search(condef) + if match: + field, reftable = match.groups() + keymap[field] = reftable.capitalize() + #print "keymap:", keymap + colData = self.queryAll(colQuery % tableName) + results = [] + for field, t, notnull, defaultstr in colData: + if field == 'id': + continue + colClass, kw = self.guessClass(t) + kw['name'] = Col.generatePythonName(field) + kw['notNull'] = notnull + if defaultstr is not None: + kw['default'] = eval(defaultstr) + if keymap.has_key(field): + kw['foreignKey'] = keymap[field] + results.append(colClass(**kw)) + return results + + def guessClass(self, t): + if t.count('int'): + return Col.IntCol, {} + elif t.count('varying'): + return Col.StringCol, {'length': int(t[t.index('(')+1:-1])} + elif t.startswith('character('): + return Col.StringCol, {'length': int(t[t.index('(')+1:-1]), + 'varchar': False} + elif t=='text': + return Col.StringCol, {} + elif t.startswith('datetime'): + return Col.DateTimeCol, {} + else: + return Col.Col, {} |
From: <ian...@us...> - 2003-04-19 00:04:11
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv4903/tests Modified Files: SQLObjectTest.py test.py Log Message: * Added Postgres support for _fromDatabase * Moved guessClass out of Col, into DBConnection classes * Changed tests so Postgres gets tested too Index: SQLObjectTest.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SQLObjectTest.py 8 Apr 2003 03:01:33 -0000 1.6 --- SQLObjectTest.py 19 Apr 2003 00:04:08 -0000 1.7 *************** *** 20,24 **** def postgresConnection(): SQLObjectTest.supportDynamic = True ! SQLObjectTest.supportAuto = False return PostgresConnection(db='test') --- 20,24 ---- def postgresConnection(): SQLObjectTest.supportDynamic = True ! SQLObjectTest.supportAuto = True return PostgresConnection(db='test') *************** *** 28,31 **** --- 28,33 ---- return SQLiteConnection('data/sqlite.data') + databaseName = None + supportedDatabases = ['mysql', 'postgres', 'sqlite', 'dbm'] *************** *** 45,53 **** c._connection = __connection__ for c in self.classes + [self]: ! if hasattr(c, 'drop'): __connection__.query(c.drop) elif hasattr(c, 'dropTable'): c.dropTable(ifExists=True) ! if hasattr(c, 'create'): __connection__.query(c.create) elif hasattr(c, 'createTable'): --- 47,64 ---- c._connection = __connection__ for c in self.classes + [self]: ! if hasattr(c, '%sDrop' % databaseName): ! if __connection__.tableExists(c._table): ! __connection__.query( ! getattr(c, '%sDrop' % databaseName)) ! elif hasattr(c, 'drop'): __connection__.query(c.drop) elif hasattr(c, 'dropTable'): c.dropTable(ifExists=True) ! ! if hasattr(c, '%sCreate' % databaseName): ! if not __connection__.tableExists(c._table): ! __connection__.query( ! getattr(c, '%sCreate' % databaseName)) ! elif hasattr(c, 'create'): __connection__.query(c.create) elif hasattr(c, 'createTable'): *************** *** 69,73 **** --- 80,86 ---- def setDatabaseType(t): global __connection__ + global databaseName conn = globals()[t + "Connection"]() + databaseName = t __connection__ = conn Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test.py 17 Apr 2003 07:15:17 -0000 1.7 --- test.py 19 Apr 2003 00:04:08 -0000 1.8 *************** *** 161,165 **** first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT, created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL --- 161,165 ---- first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT DEFAULT NULL, created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL *************** *** 172,177 **** first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT, ! created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL ) --- 172,177 ---- first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT DEFAULT 0, ! created VARCHAR(40) NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL ) *************** *** 186,192 **** --- 186,198 ---- """ + _table = 'auto_test' + def testClassCreate(self): if not self.supportAuto: return + import sys + reg = sys.modules[SQLObject.__module__].classRegistry + if reg.has_key('AutoTest'): + del reg['AutoTest'] class AutoTest(SQLObject): _fromDatabase = True *************** *** 198,202 **** AutoTest.new(firstName='jane', lastName='doe', ! happy='N') ######################################## --- 204,209 ---- AutoTest.new(firstName='jane', lastName='doe', ! happy='N', ! created=DateTime.now()) ######################################## |
From: <ian...@us...> - 2003-04-19 00:03:04
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv4768 Added Files: Authors.txt Log Message: Created --- NEW FILE: Authors.txt --- Authors ======= SQLObject was originally written and continues to be maintained by Ian Bicking <ia...@co...> Contributions have been made by: Frank Barknecht <fb...@fo...> Bud P. Bruegger <bu...@si...> David M. Cook <da...@da...> |
From: <ian...@us...> - 2003-04-18 08:20:57
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv8744/SQLObject Modified Files: SQLBuilder.py Log Message: * Added ISNULL and ISNOTNULL to SQLBuilder * Made == aware of None/NULL, so that it translates it to a ISNULL or ISNOTNULL Index: SQLBuilder.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLBuilder.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLBuilder.py 7 Apr 2003 01:13:54 -0000 1.3 --- SQLBuilder.py 18 Apr 2003 08:20:53 -0000 1.4 *************** *** 183,189 **** return SQLOp(">=", self, other) def __eq__(self, other): ! return SQLOp("=", self, other) def __ne__(self, other): ! return SQLOp("<>", self, other) def __and__(self, other): --- 183,195 ---- return SQLOp(">=", self, other) def __eq__(self, other): ! if other is None: ! return ISNULL(self) ! else: ! return SQLOp("=", self, other) def __ne__(self, other): ! if other is None: ! return ISNOTNULL(self) ! else: ! return SQLOp("<>", self, other) def __and__(self, other): *************** *** 539,542 **** --- 545,554 ---- def CONTAINSSTRING(expr, string): return SQLOp("LIKE", expr, '%' + _likeQuote(string) + '%') + + def ISNULL(expr): + return SQLOp("IS", expr, None) + + def ISNOTNULL(expr): + return SQLOp("IS NOT", expr, None) def _likeQuote(s): |
From: <ian...@us...> - 2003-04-17 07:22:56
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv32338/SQLObject Modified Files: SQLObject.py Log Message: Better error message when object not found Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SQLObject.py 17 Apr 2003 07:15:14 -0000 1.22 --- SQLObject.py 17 Apr 2003 07:22:51 -0000 1.23 *************** *** 654,657 **** --- 654,659 ---- results = self._connection._SO_selectOne(self, [self._SO_columnDict[name].dbName]) self._SO_writeLock.release() + assert results != None, "%s with id %s is not in the database" \ + % (self.__class__.__name__, self.id) return results[0] |
From: <ian...@us...> - 2003-04-17 07:17:15
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv30561/docs Modified Files: SQLObject.txt Log Message: typo in example Index: SQLObject.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/SQLObject.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SQLObject.txt 17 Apr 2003 03:39:08 -0000 1.10 --- SQLObject.txt 17 Apr 2003 07:17:12 -0000 1.11 *************** *** 684,688 **** if not self._phoneNumberRE.match(value): raise ValueError, 'Phone numbers can contain only digits' ! self._SO_set_phoneNumber(self, value) def _get_phoneNumber(self): --- 684,688 ---- if not self._phoneNumberRE.match(value): raise ValueError, 'Phone numbers can contain only digits' ! self._SO_set_phoneNumber(value) def _get_phoneNumber(self): |
From: <ian...@us...> - 2003-04-17 07:16:13
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv30234/SQLObject Modified Files: DBConnection.py Log Message: Previous Postgres fix was backwards (typo) Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** DBConnection.py 17 Apr 2003 03:42:56 -0000 1.19 --- DBConnection.py 17 Apr 2003 07:16:09 -0000 1.20 *************** *** 437,441 **** def _queryInsertID(self, conn, table, idName, names, values): c = conn.cursor() ! c.execute('SELECT nextval(\'%s_%s_seq\')' % (idName, table)) (id,) = c.fetchone() names.append(idName) --- 437,441 ---- def _queryInsertID(self, conn, table, idName, names, values): c = conn.cursor() ! c.execute('SELECT nextval(\'%s_%s_seq\')' % (table, idName)) (id,) = c.fetchone() names.append(idName) |
From: <ian...@us...> - 2003-04-17 07:15:22
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv29696/tests Modified Files: test.py Log Message: Added basic functionality test Fixed properties bug (where only overriding one of get/set wouldn't cause the other one to be used) Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test.py 7 Apr 2003 19:48:44 -0000 1.6 --- test.py 17 Apr 2003 07:15:17 -0000 1.7 *************** *** 4,7 **** --- 4,35 ---- ######################################## + ## Basic operation + ######################################## + + class TestSO1(SQLObject): + + _columns = [ + StringCol('name', length=10), + StringCol('passwd', length=10), + ] + + def _set_passwd(self, passwd): + self._SO_set_passwd(passwd.encode('rot13')) + + class TestCase1(SQLObjectTest): + + classes = [TestSO1] + + def inserts(self): + for name, passwd in [('bob', 'god'), ('sally', 'sordid'), + ('dave', 'dremel'), ('fred', 'forgo')]: + TestSO1.new(name=name, passwd=passwd) + + def testGet(self): + bob = TestSO1.selectBy(name='bob')[0] + self.assertEqual(bob.name, 'bob') + self.assertEqual(bob.passwd, 'god'.encode('rot13')) + + ######################################## ## Slicing tests ######################################## |
From: <ian...@us...> - 2003-04-17 07:15:21
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv29696/SQLObject Modified Files: SQLObject.py Log Message: Added basic functionality test Fixed properties bug (where only overriding one of get/set wouldn't cause the other one to be used) Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SQLObject.py 17 Apr 2003 02:59:29 -0000 1.21 --- SQLObject.py 17 Apr 2003 07:15:14 -0000 1.22 *************** *** 153,160 **** dict['q'] = SQLBuilder.SmartTable(dict['_table']) - # makeProperties turns all the _get_/_set_ stuff into - # properties. - makeProperties(dict) - # If the connection is named, we turn the name into # a real connection. --- 153,156 ---- *************** *** 170,173 **** --- 166,170 ---- # We actually create the class. newClass = type.__new__(cls, className, bases, dict) + newClass._SO_finishedClassCreation = False for column in newClass._columns[:]: *************** *** 185,189 **** --- 182,189 ---- setNeedSet() + # We don't setup the properties until we're finished with the + # batch adding of all the columns... newClass._SO_finishedClassCreation = True + makeProperties(newClass) # And return the class *************** *** 226,230 **** if len(setters) == 1 and setters.has_key('doc'): continue ! if d.has_key(var): continue setFunc(var, property(setters.get('get'), setters.get('set'), --- 226,231 ---- if len(setters) == 1 and setters.has_key('doc'): continue ! if d.has_key(var): ! continue setFunc(var, property(setters.get('get'), setters.get('set'), |
From: <ian...@us...> - 2003-04-17 03:58:13
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv32081 Modified Files: SQLObject.txt Log Message: Note SERIAL PRIMARY KEY for pg Index: SQLObject.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/SQLObject.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SQLObject.txt 9 Apr 2003 04:34:45 -0000 1.9 --- SQLObject.txt 17 Apr 2003 03:39:08 -0000 1.10 *************** *** 130,134 **** CREATE TABLE person ( ! id SERIAL, first_name VARCHAR(100) NOT NULL, middle_initial CHAR(1), --- 130,134 ---- CREATE TABLE person ( ! id SERIAL PRIMARY KEY, first_name VARCHAR(100) NOT NULL, middle_initial CHAR(1), *************** *** 195,200 **** You'll note that the ``id`` column is not given in the class definition, it is implied. For MySQL databases it should be defined ! as ``INT PRIMARY KEY AUTO_INCREMENT``, in Postgres ``SERIAL``, and in ! SQLite as ``INTEGER PRIMARY KEY``. Using the Class --- 195,200 ---- You'll note that the ``id`` column is not given in the class definition, it is implied. For MySQL databases it should be defined ! as ``INT PRIMARY KEY AUTO_INCREMENT``, in Postgres ``SERIAL PRIMARY KEY``, ! and in SQLite as ``INTEGER PRIMARY KEY``. Using the Class *************** *** 382,387 **** The name of the primary key column (default ``id``). ! Relations Between Classes/Tables ! -------------------------------- You can use the `foreignKey` argument to `Col` to handle simple --- 382,387 ---- The name of the primary key column (default ``id``). ! Relationships Between Classes/Tables ! ------------------------------------ You can use the `foreignKey` argument to `Col` to handle simple *************** *** 389,397 **** many-to-many references you'll use joins. ! Relations: One-to-Many ! ~~~~~~~~~~~~~~~~~~~~~~ ! Now we'll deal with having a relation to another table, a phone number ! table that refers to a person:: CREATE TABLE phone_number ( --- 389,397 ---- many-to-many references you'll use joins. ! Relationships: One-to-Many ! ~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Now we'll deal with having a relationship to another table, a phone ! number table that refers to a person:: CREATE TABLE phone_number ( *************** *** 437,442 **** .. _Many-to-Many: ! Relations: Many-to-Many ! ~~~~~~~~~~~~~~~~~~~~~~~ We'll add roles to the system, where a person can have more than one --- 437,442 ---- .. _Many-to-Many: ! Relationships: Many-to-Many ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~ We'll add roles to the system, where a person can have more than one *************** *** 836,840 **** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! To create a database call `createTable`. It takes two arguments: `ifNotExists`: --- 836,840 ---- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! To create a table call `createTable`. It takes two arguments: `ifNotExists`: *************** *** 842,846 **** False. `createJoinTables`: ! If you used Many-to-Many_ relations, then the intermediate tables will be created (but only for one of the two involved classes). Default True. --- 842,846 ---- False. `createJoinTables`: ! If you used Many-to-Many_ relationships, then the intermediate tables will be created (but only for one of the two involved classes). Default True. |
From: <ian...@us...> - 2003-04-17 03:42:59
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv767 Modified Files: DBConnection.py Log Message: Forgot to use idName for sequence (PG) Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DBConnection.py 11 Apr 2003 16:26:39 -0000 1.18 --- DBConnection.py 17 Apr 2003 03:42:56 -0000 1.19 *************** *** 437,441 **** def _queryInsertID(self, conn, table, idName, names, values): c = conn.cursor() ! c.execute('SELECT nextval(\'%s_id_seq\')' % table) (id,) = c.fetchone() names.append(idName) --- 437,441 ---- def _queryInsertID(self, conn, table, idName, names, values): c = conn.cursor() ! c.execute('SELECT nextval(\'%s_%s_seq\')' % (idName, table)) (id,) = c.fetchone() names.append(idName) |
From: <ian...@us...> - 2003-04-17 03:39:48
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv32306 Modified Files: util.py Log Message: Make fields that start with caps work Index: util.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/util.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** util.py 14 Mar 2003 03:52:01 -0000 1.1 --- util.py 17 Apr 2003 03:39:43 -0000 1.2 *************** *** 3,5 **** _translateRE = re.compile(r'[A-Z]') def splitWords(s): ! return _translateRE.sub(lambda x: '_%s' % x.group(0).lower(), s) --- 3,8 ---- _translateRE = re.compile(r'[A-Z]') def splitWords(s): ! trans = _translateRE.sub(lambda x: '_%s' % x.group(0).lower(), s) ! if trans.startswith('_'): ! trans = trans[1:] ! return trans |
From: <ian...@us...> - 2003-04-17 02:59:32
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv20597 Modified Files: Cache.py SQLObject.py Log Message: * Fixed Cache problem where it would become interminably locked * Fixed destroy semantics a little Index: Cache.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Cache.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Cache.py 10 Apr 2003 21:45:43 -0000 1.4 --- Cache.py 17 Apr 2003 02:59:29 -0000 1.5 *************** *** 105,108 **** --- 105,110 ---- else: self.expiredCache[id] = ref(obj) + + def finishPut(self): self.lock.release() *************** *** 126,133 **** --- 128,137 ---- def purge(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() class CacheSet(object): *************** *** 147,150 **** --- 151,157 ---- def put(self, id, cls, obj): self.caches[cls.__name__].put(id, obj) + + def finishPut(self, cls): + self.caches[cls.__name__].finishPut() def created(self, id, cls, obj): Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SQLObject.py 16 Apr 2003 21:19:03 -0000 1.20 --- SQLObject.py 17 Apr 2003 02:59:29 -0000 1.21 *************** *** 308,314 **** val = cache.get(id, cls) if val is None: ! val = object.__new__(cls, id, connection) ! val._init(id, connection) ! cache.put(id, cls, val) return val --- 308,317 ---- val = cache.get(id, cls) if val is None: ! try: ! val = object.__new__(cls, id, connection) ! val._init(id, connection) ! cache.put(id, cls, val) ! finally: ! cache.finishPut(cls) return val *************** *** 817,829 **** clearTable = classmethod(clearTable) ! def destroy(self): # Kills this object. Kills it dead! self._SO_obsolete = True self._SO_autoInitDone = False - # huh? - #self._SO_delete(self) self._connection._SO_delete(self) self._connection.cache.purge(self.id, self.__class__) def __repr__(self): return '<%s %i %s>' \ --- 820,836 ---- clearTable = classmethod(clearTable) ! def destroySelf(self): # Kills this object. Kills it dead! self._SO_obsolete = True self._SO_autoInitDone = False self._connection._SO_delete(self) self._connection.cache.purge(self.id, self.__class__) + def delete(cls, id): + obj = cls(id) + obj.destroySelf() + + delete = classmethod(delete) + def __repr__(self): return '<%s %i %s>' \ *************** *** 1071,1075 **** def getID(obj): ! if type(obj) is type(1): return obj elif type(obj) is type(1L): --- 1078,1084 ---- def getID(obj): ! if isinstance(obj, SQLObject): ! return obj.id ! elif type(obj) is type(1): return obj elif type(obj) is type(1L): *************** *** 1079,1084 **** elif obj is None: return None - else: - return obj.id def getObject(obj, klass): --- 1088,1091 ---- |
From: <ian...@us...> - 2003-04-17 02:58:42
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv20414/tests Added Files: test_cache.py Log Message: light testing for Cache --- NEW FILE: test_cache.py --- import unittest from SQLObject.Cache import CacheSet class Something(object): pass class CacheTest(unittest.TestCase): def testPurge1(self): x = CacheSet() y = Something() obj = x.get(1, y.__class__) self.assertEqual(obj, None) x.put(1, y.__class__, y) x.finishPut(y.__class__) j = x.get(1, y.__class__) self.assertEqual(j, y) x.purge(1, y.__class__) j = x.get(1, y.__class__) self.assertEqual(j, None) x.finishPut(y.__class__) j = x.get(1, y.__class__) self.assertEqual(j, None) x.finishPut(y.__class__) if __name__ == "__main__": unittest.main() |
From: <ian...@us...> - 2003-04-16 21:19:07
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv3435 Modified Files: SQLObject.py Log Message: Fixed spurious argument (caused error in Python 2.3) Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SQLObject.py 11 Apr 2003 16:30:39 -0000 1.19 --- SQLObject.py 16 Apr 2003 21:19:03 -0000 1.20 *************** *** 290,294 **** if id is None: # Create an actual new object: ! inst = object.__new__(cls, id) inst._SO_creating = True # This is a dictionary of column-names to --- 290,294 ---- if id is None: # Create an actual new object: ! inst = object.__new__(cls) inst._SO_creating = True # This is a dictionary of column-names to |
From: <ian...@us...> - 2003-04-11 16:30:44
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv30290 Modified Files: SQLObject.py Log Message: pychecker typos Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SQLObject.py 8 Apr 2003 17:25:04 -0000 1.18 --- SQLObject.py 11 Apr 2003 16:30:39 -0000 1.19 *************** *** 22,26 **** import threading - import re import SQLBuilder import DBConnection --- 22,25 ---- *************** *** 121,125 **** # since it's abstract we'll ignore it. if className != 'SQLObject': - import sys mod = sys.modules[dict['__module__']] # See if there's a __connection__ global in --- 120,123 ---- *************** *** 431,435 **** cls._columns.remove(column) if isinstance(column, str): ! column = self._SO_columnDict[column] name = column.name del cls._SO_columnDict[name] --- 429,433 ---- cls._columns.remove(column) if isinstance(column, str): ! column = cls._SO_columnDict[column] name = column.name del cls._SO_columnDict[name] *************** *** 520,524 **** meth = join.joinMethodName cls._joins.remove(join) - appendMeth = meth[0].upper() + meth[1:] for i in range(len(cls._SO_joinList)): if cls._SO_joinList[i] is join: --- 518,521 ---- *************** *** 627,632 **** self._SO_writeLock.acquire() - # Python names of the columns: - hereNames = [col.name for col in self._columns] # Database (_-using) names: dbNames = [col.dbName for col in self._columns] --- 624,627 ---- *************** *** 1014,1018 **** def lazyColumns(self, value): ! return self.clone(lazyColumns=lazyColumns) def __getitem__(self, value): --- 1009,1013 ---- def lazyColumns(self, value): ! return self.clone(lazyColumns=value) def __getitem__(self, value): |
From: <ian...@us...> - 2003-04-11 16:26:43
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv27507 Modified Files: DBConnection.py Log Message: pychecker typoes Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** DBConnection.py 10 Apr 2003 21:45:43 -0000 1.17 --- DBConnection.py 11 Apr 2003 16:26:39 -0000 1.18 *************** *** 583,587 **** if match.group(1) and not self.tableExists(match.group(2)): return ! return self.dropTable(match.group(2), match.group(1)) def addColumn(self, tableName, column): --- 583,587 ---- if match.group(1) and not self.tableExists(match.group(2)): return ! return self.dropTable(match.group(2)) def addColumn(self, tableName, column): |
From: <ian...@us...> - 2003-04-11 16:23:22
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv25492/SQLObject Modified Files: Col.py Log Message: Pychecker-caught typos Index: Col.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Col.py 10 Apr 2003 04:46:54 -0000 1.8 --- Col.py 11 Apr 2003 16:23:18 -0000 1.9 *************** *** 17,21 **** # Col is essentially a column definition, it doesn't have # much logic to it. ! class Col: def __init__(self, name, dbName=None, default=NoDefault, --- 17,21 ---- # Col is essentially a column definition, it doesn't have # much logic to it. ! class Col(object): def __init__(self, name, dbName=None, default=NoDefault, *************** *** 91,96 **** def _get_joinName(self): ! assert self._name[-2:] == 'ID' ! return self._name[:-2] joinName = property(_get_joinName, None, None) --- 91,96 ---- def _get_joinName(self): ! assert self.name[-2:] == 'ID' ! return self.name[:-2] joinName = property(_get_joinName, None, None) *************** *** 108,112 **** def createSQL(self): ! return ' '.join([self._sqlType(self) + self._extraSQL()]) def _extraSQL(self): --- 108,112 ---- def createSQL(self): ! return ' '.join([self._sqlType() + self._extraSQL()]) def _extraSQL(self): |
From: <ian...@us...> - 2003-04-10 21:45:50
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv16377/SQLObject Modified Files: Cache.py DBConnection.py Log Message: Assign True and False Index: Cache.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Cache.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Cache.py 8 Apr 2003 17:25:03 -0000 1.3 --- Cache.py 10 Apr 2003 21:45:43 -0000 1.4 *************** *** 3,6 **** --- 3,8 ---- from time import time as now + True, False = 1==1, 0==1 + class CacheFactory(object): Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** DBConnection.py 10 Apr 2003 04:46:15 -0000 1.16 --- DBConnection.py 10 Apr 2003 21:45:43 -0000 1.17 *************** *** 1,4 **** --- 1,6 ---- from __future__ import generators + True, False = 1==1, 0==1 + import threading import SQLBuilder |
From: <ian...@us...> - 2003-04-10 04:46:57
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv2335/SQLObject Modified Files: Col.py Log Message: Add `unique` keyword argument to Col. (need doc) Index: Col.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Col.py 9 Apr 2003 04:35:32 -0000 1.7 --- Col.py 10 Apr 2003 04:46:54 -0000 1.8 *************** *** 22,26 **** foreignKey=None, alternateID=False, alternateMethodName=None, ! constraints=None, notNull=False): # This isn't strictly true, since we *could* use backquotes # around column names, but why would anyone *want* to --- 22,27 ---- foreignKey=None, alternateID=False, alternateMethodName=None, ! constraints=None, notNull=False, ! unique=NoDefault): # This isn't strictly true, since we *could* use backquotes # around column names, but why would anyone *want* to *************** *** 62,65 **** --- 63,70 ---- constraints = [Constraints.notNull] + constraints self.contraints = constraints + if unique is NoDefault: + self.unique = alternateID + else: + self.unique = unique def autoConstraints(self): *************** *** 109,113 **** if self.notNull: result.append('NOT NULL') ! if self.alternateID: result.append('UNIQUE') return result --- 114,118 ---- if self.notNull: result.append('NOT NULL') ! if self.unique: result.append('UNIQUE') return result |
From: <ian...@us...> - 2003-04-10 04:46:26
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv2213/SQLObject Modified Files: DBConnection.py Log Message: Make postgres use SERIAL KEY for id fields Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** DBConnection.py 8 Apr 2003 09:05:19 -0000 1.15 --- DBConnection.py 10 Apr 2003 04:46:15 -0000 1.16 *************** *** 456,460 **** def createIDColumn(self, soClass): ! return '%s SERIAL' % soClass._idName def joinSQLType(self, join): --- 456,460 ---- def createIDColumn(self, soClass): ! return '%s SERIAL PRIMARY KEY' % soClass._idName def joinSQLType(self, join): |
From: <ian...@us...> - 2003-04-09 04:35:35
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv25006/SQLObject Modified Files: Col.py Log Message: Made foreign key column names slightly more permissive (you can use lower case "id") Index: Col.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Col.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Col.py 8 Apr 2003 02:51:49 -0000 1.6 --- Col.py 9 Apr 2003 04:35:32 -0000 1.7 *************** *** 50,54 **** self.foreignKey = foreignKey if foreignKey: ! assert name.endswith('ID'), "All foreign key columns must end with 'ID' (%s)" % repr(name) self.foreignName = name[:-2] else: --- 50,54 ---- self.foreignKey = foreignKey if foreignKey: ! assert name.upper().endswith('ID'), "All foreign key columns must end with 'ID' (%s)" % repr(name) self.foreignName = name[:-2] else: |
From: <ian...@us...> - 2003-04-09 04:34:48
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv24886/docs Modified Files: SQLObject.txt Log Message: typo Index: SQLObject.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/SQLObject.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SQLObject.txt 8 Apr 2003 03:08:02 -0000 1.8 --- SQLObject.txt 9 Apr 2003 04:34:45 -0000 1.9 *************** *** 171,175 **** _table = 'people' ! _id = 'peopleID' _columns = [Col('firstName', dbName='fname'), Col('middleInitial', dbName='MI'), --- 171,175 ---- _table = 'people' ! _idName = 'peopleID' _columns = [Col('firstName', dbName='fname'), Col('middleInitial', dbName='MI'), |
From: <ian...@us...> - 2003-04-08 17:25:11
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv24013/SQLObject Modified Files: Cache.py SQLObject.py Log Message: Fixed purge Index: Cache.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Cache.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Cache.py 30 Mar 2003 01:47:35 -0000 1.2 --- Cache.py 8 Apr 2003 17:25:03 -0000 1.3 *************** *** 152,153 **** --- 152,159 ---- self.caches[cls.__name__] = CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].created(id, obj) + + def purge(self, id, cls): + try: + self.caches[cls.__name__].purge(id) + except KeyError: + pass Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SQLObject.py 8 Apr 2003 03:01:34 -0000 1.17 --- SQLObject.py 8 Apr 2003 17:25:04 -0000 1.18 *************** *** 829,833 **** #self._SO_delete(self) self._connection._SO_delete(self) ! self._connection.cache.purge(self.id) def __repr__(self): --- 829,833 ---- #self._SO_delete(self) self._connection._SO_delete(self) ! self._connection.cache.purge(self.id, self.__class__) def __repr__(self): |