sqlobject-cvs Mailing List for SQLObject (Page 134)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
| 2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
| 2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
| 2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
| 2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
| 2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
| 2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
| 2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
| 2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
| 2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
| 2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
| 2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
| 2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
| 2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
| 2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
| 2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: <sub...@co...> - 2006-03-14 15:52:10
|
Author: phd
Date: 2006-03-14 08:51:59 -0700 (Tue, 14 Mar 2006)
New Revision: 1651
Modified:
home/phd/SQLObject/paramstyles/sqlobject/manager/command.py
Log:
Merged patches from the revisions 1644:1650 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/manager/command.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/manager/command.py 2006-03-14 07:01:12 UTC (rev 1650)
+++ home/phd/SQLObject/paramstyles/sqlobject/manager/command.py 2006-03-14 15:51:59 UTC (rev 1651)
@@ -567,7 +567,8 @@
else:
print 'Creating %s' % soClass.__name__
if v >= 2:
- print soClass.createTableSQL()
+ sql, extra = soClass.createTableSQL()
+ print sql
if (not self.options.simulate
and not exists):
if self.options.interactive:
@@ -584,6 +585,8 @@
if tableConstraints:
constraints[soClass._connection].append(tableConstraints)
for connection in constraints.keys():
+ if v >= 2:
+ print 'Creating constraints'
for constraintList in constraints[connection]:
for constraint in constraintList:
if constraint:
@@ -921,25 +924,25 @@
f = open(os.path.join(output_dir, fn), 'w')
f.write(content)
f.close()
- all_diffs = []
- for cls in self.classes():
- for conn in conns:
- diffs = db_differences(cls, conn)
- for diff in diffs:
- if len(conns) > 1:
- diff = ' (%s).%s: %s' % (
- conn.uri(), cls.sqlmeta.table, diff)
- else:
- diff = ' %s: %s' % (cls.sqlmeta.table, diff)
- all_diffs.append(diff)
- if all_diffs:
- print 'Database does not match schema:'
- print '\n'.join(all_diffs)
- if self.options.db_record:
- print '(Not updating database version)'
- elif self.options.db_record:
- for conn in conns:
- self.update_db(version, conn)
+ if self.options.db_record:
+ all_diffs = []
+ for cls in self.classes():
+ for conn in conns:
+ diffs = db_differences(cls, conn)
+ for diff in diffs:
+ if len(conns) > 1:
+ diff = ' (%s).%s: %s' % (
+ conn.uri(), cls.sqlmeta.table, diff)
+ else:
+ diff = ' %s: %s' % (cls.sqlmeta.table, diff)
+ all_diffs.append(diff)
+ if all_diffs:
+ print 'Database does not match schema:'
+ print '\n'.join(all_diffs)
+ for conn in conns:
+ self.update_db(version, conn)
+ else:
+ all_diffs = []
if self.options.open_editor:
if not last_version_dir:
print ("Cannot edit upgrader because there is no "
|
|
From: <sub...@co...> - 2006-03-14 00:37:45
|
Author: ianb
Date: 2006-03-13 17:37:41 -0700 (Mon, 13 Mar 2006)
New Revision: 1649
Modified:
SQLObject/trunk/sqlobject/manager/command.py
Log:
Improve output from create command
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2006-03-11 11:12:43 UTC (rev 1648)
+++ SQLObject/trunk/sqlobject/manager/command.py 2006-03-14 00:37:41 UTC (rev 1649)
@@ -567,7 +567,8 @@
else:
print 'Creating %s' % soClass.__name__
if v >= 2:
- print soClass.createTableSQL()
+ sql, extra = soClass.createTableSQL()
+ print sql
if (not self.options.simulate
and not exists):
if self.options.interactive:
@@ -584,6 +585,8 @@
if tableConstraints:
constraints[soClass._connection].append(tableConstraints)
for connection in constraints.keys():
+ if v >= 2:
+ print 'Creating constraints'
for constraintList in constraints[connection]:
for constraint in constraintList:
if constraint:
|
|
From: SourceForge.net <no...@so...> - 2006-03-11 01:16:27
|
Bugs item #1334786, was opened at 2005-10-22 02:30 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1334786&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: M. Dietrich (mdt) Assigned to: Nobody/Anonymous (nobody) Summary: infinitiv recursion in Transaction.__del__ Initial Comment: using ThreadConnections i get a Exception exceptions.RuntimeError: 'maximum recursion depth exceeded' in <bound method Transaction.__del__ of <sqlobject.dbconnection.Transaction object at 0xaedb714c>> ignored , commenting __del__() works in the first place. can't figure out what this __del__ is for... ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-03-10 17:16 Message: Logged In: NO In my case, this was caused by an exception happening in the __init__ method of Transaction. The __del__ then tried to use self._obsolete, which had not yet been defined causing __getattr__ to be used which then tried to use more undefined stuff. --- sqlobject/dbconnection.py~ Thu Dec 23 11:52:32 2004 +++ sqlobject/dbconnection.py Fri Mar 10 19:16:24 2006 @@ -473,11 +473,11 @@ class Transaction(object): def __init__(self, dbConnection): + self.cache = CacheSet(cache=dbConnection.doCache) + self._obsolete = False self._dbConnection = dbConnection self._connection = dbConnection.getConnection() self._dbConnection._setAutoCommit(self._connection, 0) - self.cache = CacheSet(cache=dbConnection.doCache) - self._obsolete = False def assertActive(self): assert not self._obsolete, "This transaction has already gone through COMMIT/ROLLBACK; create another transaction" ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-02-06 09:44 Message: Logged In: YES user_id=4799 I cannot reproduce it. When Postgres is not started your program is just reports Traceback (most recent call last): File "./test1.py", line 10, in ? sqlhub.threadConnection = connection.transaction() File "/usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1534-py2.4.egg/sqlobject/dbconnection.py", line 354, in transaction return Transaction(self) File "/usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1534-py2.4.egg/sqlobject/dbconnection.py", line 731, in __init__ self._connection = dbConnection.getConnection() File "/usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1534-py2.4.egg/sqlobject/dbconnection.py", line 226, in getConnection conn = self.makeConnection() File "/usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1534-py2.4.egg/sqlobject/postgres/pgconnection.py", line 108, in makeConnection raise self.module.OperationalError("%s; used connection string %r" % (e, self.dsn)) psycopg.OperationalError: could not connect to server: @â Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? ; used connection string 'dbname=test' Exception exceptions.AttributeError: "PostgresConnection instance has no attribute '_connection'" in <bound method Transaction.__del__ of <sqlobject.dbconnection.Transaction object at 0xb7b6ddec>> ignored ---------------------------------------------------------------------- Comment By: Didrik Pinte (dpinte) Date: 2006-01-24 01:20 Message: Logged In: YES user_id=970259 Same here, I can reproduce it. It happens when the database is not started. Here is a test code : Step 1 : Shut down you postgres server Step 2 : Run the following ------------------------- import sqlobject scheme = "postgres://myusername:mypassword@localhost/mydb" connection = sqlobject.connectionForURI(scheme) sqlobject.sqlhub.processConnection = connection sqlhub.threadConnection = connection.transaction() -------------------------- Didrik ---------------------------------------------------------------------- Comment By: xiao hai tong (haitong) Date: 2005-12-04 09:35 Message: Logged In: YES user_id=146934 I encount it too. once is too many connection crash my pgsql server on windows, then may of such exceptions reported. other time: a multi thread test program. I want to retry my transaction when excecption occured during commit, I commet the threadConnection.rollback(), just set threadConnection = g_conn.transaction(), and redo the transaction after seconds, such exceptions occurred. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-10-25 09:12 Message: Logged In: YES user_id=4799 Can you make a little test program that demonstrates the problem? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1334786&group_id=74338 |
|
From: <sub...@co...> - 2006-03-10 18:42:12
|
Author: ianb
Date: 2006-03-10 11:42:09 -0700 (Fri, 10 Mar 2006)
New Revision: 1647
Modified:
SQLObject/trunk/sqlobject/manager/command.py
Log:
Bug from last commit (really all_diffs should be generated from the last recorded version, not from the database, but for now just punting on that)
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2006-03-10 18:35:49 UTC (rev 1646)
+++ SQLObject/trunk/sqlobject/manager/command.py 2006-03-10 18:42:09 UTC (rev 1647)
@@ -938,6 +938,8 @@
print '\n'.join(all_diffs)
for conn in conns:
self.update_db(version, conn)
+ else:
+ all_diffs = []
if self.options.open_editor:
if not last_version_dir:
print ("Cannot edit upgrader because there is no "
|
|
From: <sub...@co...> - 2006-03-10 18:35:55
|
Author: ianb
Date: 2006-03-10 11:35:49 -0700 (Fri, 10 Mar 2006)
New Revision: 1646
Modified:
SQLObject/trunk/sqlobject/manager/command.py
Log:
When using --no-db-record, don't look at the database at all
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2006-03-09 19:40:55 UTC (rev 1645)
+++ SQLObject/trunk/sqlobject/manager/command.py 2006-03-10 18:35:49 UTC (rev 1646)
@@ -921,25 +921,23 @@
f = open(os.path.join(output_dir, fn), 'w')
f.write(content)
f.close()
- all_diffs = []
- for cls in self.classes():
- for conn in conns:
- diffs = db_differences(cls, conn)
- for diff in diffs:
- if len(conns) > 1:
- diff = ' (%s).%s: %s' % (
- conn.uri(), cls.sqlmeta.table, diff)
- else:
- diff = ' %s: %s' % (cls.sqlmeta.table, diff)
- all_diffs.append(diff)
- if all_diffs:
- print 'Database does not match schema:'
- print '\n'.join(all_diffs)
- if self.options.db_record:
- print '(Not updating database version)'
- elif self.options.db_record:
- for conn in conns:
- self.update_db(version, conn)
+ if self.options.db_record:
+ all_diffs = []
+ for cls in self.classes():
+ for conn in conns:
+ diffs = db_differences(cls, conn)
+ for diff in diffs:
+ if len(conns) > 1:
+ diff = ' (%s).%s: %s' % (
+ conn.uri(), cls.sqlmeta.table, diff)
+ else:
+ diff = ' %s: %s' % (cls.sqlmeta.table, diff)
+ all_diffs.append(diff)
+ if all_diffs:
+ print 'Database does not match schema:'
+ print '\n'.join(all_diffs)
+ for conn in conns:
+ self.update_db(version, conn)
if self.options.open_editor:
if not last_version_dir:
print ("Cannot edit upgrader because there is no "
|
|
From: <sub...@co...> - 2006-03-09 15:58:35
|
Author: phd
Date: 2006-03-09 08:58:30 -0700 (Thu, 09 Mar 2006)
New Revision: 1644
Modified:
home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py
Log:
Merged patches from the revisions 1640:1643 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py 2006-03-09 15:57:40 UTC (rev 1643)
+++ home/phd/SQLObject/paramstyles/sqlobject/postgres/pgconnection.py 2006-03-09 15:58:30 UTC (rev 1644)
@@ -90,6 +90,10 @@
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
path = path.strip('/')
+ if (host is None) and path.count('/'): # Non-default unix socket
+ path_parts = path.split('/')
+ host = '/' + '/'.join(path_parts[:-1])
+ path = path_parts[-1]
return cls(host=host, port=port, db=path, user=user, password=password, **args)
connectionFromURI = classmethod(connectionFromURI)
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py 2006-03-09 15:57:40 UTC (rev 1643)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_parse.py 2006-03-09 15:58:30 UTC (rev 1644)
@@ -8,21 +8,21 @@
def test_parse():
_parseURI = DBConnection._parseURI
- user, password, host, port, path, args = _parseURI("mysql://user:password@host/database")
- assert user == "user"
- assert password == "password"
+ user, password, host, port, path, args = _parseURI("mysql://host/database")
+ assert user is None
+ assert password is None
assert host == "host"
assert port is None
assert path == "/database"
assert args == {}
- user, password, host, port, path, args = _parseURI("mysql://host/database")
- assert user is None
- assert password is None
+ user, password, host, port, path, args = _parseURI("mysql://user:pass%20word@host/database?unix_socket=/var/mysql/socket")
+ assert user == "user"
+ assert password == "pass%20word"
assert host == "host"
assert port is None
assert path == "/database"
- assert args == {}
+ assert args == {"unix_socket": "/var/mysql/socket"}
user, password, host, port, path, args = _parseURI("postgres://user@host/database")
assert user == "user"
@@ -40,6 +40,14 @@
assert path == "/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres:///full/path/to/socket/database")
+ assert user == None
+ assert password is None
+ assert host == None
+ assert port is None
+ assert path == "/full/path/to/socket/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: <sub...@co...> - 2006-03-09 15:57:46
|
Author: phd
Date: 2006-03-09 08:57:40 -0700 (Thu, 09 Mar 2006)
New Revision: 1643
Modified:
SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
Log:
Merged patches from revisions 1641, 1642 from the trunk:
postgres DB URIs with a non-default path to unix socket.
Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-09 15:57:40 UTC (rev 1643)
@@ -137,7 +137,7 @@
scheme://[user[:password]@]host[:port]/database[?parameters]
Scheme is one of ``sqlite``, ``mysql``, ``postgres``, ``firebird``,
-``interbase``, ``maxdb``, ``sapdb``, ``sybase``.
+``interbase``, ``maxdb``, ``sapdb``, ``mssql``, ``sybase``.
Examples::
Modified: SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-03-09 15:57:40 UTC (rev 1643)
@@ -90,6 +90,10 @@
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
path = path.strip('/')
+ if (host is None) and path.count('/'): # Non-default unix socket
+ path_parts = path.split('/')
+ host = '/' + '/'.join(path_parts[:-1])
+ path = path_parts[-1]
return cls(host=host, port=port, db=path, user=user, passwd=password, **args)
connectionFromURI = classmethod(connectionFromURI)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-03-09 15:57:40 UTC (rev 1643)
@@ -8,21 +8,21 @@
def test_parse():
_parseURI = DBConnection._parseURI
- user, password, host, port, path, args = _parseURI("mysql://user:passwd@host/database")
- assert user == "user"
- assert password == "passwd"
+ user, password, host, port, path, args = _parseURI("mysql://host/database")
+ assert user is None
+ assert password is None
assert host == "host"
assert port is None
assert path == "/database"
assert args == {}
- user, password, host, port, path, args = _parseURI("mysql://host/database")
- assert user is None
- assert password is None
+ user, password, host, port, path, args = _parseURI("mysql://user:pass%20word@host/database?unix_socket=/var/mysql/socket")
+ assert user == "user"
+ assert password == "pass%20word"
assert host == "host"
assert port is None
assert path == "/database"
- assert args == {}
+ assert args == {"unix_socket": "/var/mysql/socket"}
user, password, host, port, path, args = _parseURI("postgres://user@host/database")
assert user == "user"
@@ -40,6 +40,14 @@
assert path == "/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres:///full/path/to/socket/database")
+ assert user == None
+ assert password is None
+ assert host == None
+ assert port is None
+ assert path == "/full/path/to/socket/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: <sub...@co...> - 2006-03-09 15:56:37
|
Author: phd
Date: 2006-03-09 08:56:32 -0700 (Thu, 09 Mar 2006)
New Revision: 1642
Modified:
SQLObject/docs/SQLObject.txt
Log:
Minor update: an example of postgres DB URI with a non-default path to unix socket; mssql scheme.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-03-09 15:54:54 UTC (rev 1641)
+++ SQLObject/docs/SQLObject.txt 2006-03-09 15:56:32 UTC (rev 1642)
@@ -142,13 +142,14 @@
scheme://[user[:password]@]host[:port]/database[?parameters]
Scheme is one of ``sqlite``, ``mysql``, ``postgres``, ``firebird``,
-``interbase``, ``maxdb``, ``sapdb``, ``sybase``, ``mssql``.
+``interbase``, ``maxdb``, ``sapdb``, ``mssql``, ``sybase``.
Examples::
mysql://user:password@host/database
mysql://host/database?debug=1
postgres://user@host/database?debug=&cache=
+ postgres:///full/path/to/socket/database
postgres://host:5432/database
sqlite:///full/path/to/database
sqlite:/C|/full/path/to/database
|
|
From: <sub...@co...> - 2006-03-09 15:55:09
|
Author: phd
Date: 2006-03-09 08:54:54 -0700 (Thu, 09 Mar 2006)
New Revision: 1641
Modified:
SQLObject/trunk/sqlobject/postgres/pgconnection.py
SQLObject/trunk/sqlobject/tests/test_parse.py
Log:
Allow non-default path to unix-socket in postgres DB URIs.
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2006-03-09 07:43:05 UTC (rev 1640)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2006-03-09 15:54:54 UTC (rev 1641)
@@ -90,6 +90,10 @@
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
path = path.strip('/')
+ if (host is None) and path.count('/'): # Non-default unix socket
+ path_parts = path.split('/')
+ host = '/' + '/'.join(path_parts[:-1])
+ path = path_parts[-1]
return cls(host=host, port=port, db=path, user=user, password=password, **args)
connectionFromURI = classmethod(connectionFromURI)
Modified: SQLObject/trunk/sqlobject/tests/test_parse.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_parse.py 2006-03-09 07:43:05 UTC (rev 1640)
+++ SQLObject/trunk/sqlobject/tests/test_parse.py 2006-03-09 15:54:54 UTC (rev 1641)
@@ -8,21 +8,21 @@
def test_parse():
_parseURI = DBConnection._parseURI
- user, password, host, port, path, args = _parseURI("mysql://user:password@host/database")
- assert user == "user"
- assert password == "password"
+ user, password, host, port, path, args = _parseURI("mysql://host/database")
+ assert user is None
+ assert password is None
assert host == "host"
assert port is None
assert path == "/database"
assert args == {}
- user, password, host, port, path, args = _parseURI("mysql://host/database")
- assert user is None
- assert password is None
+ user, password, host, port, path, args = _parseURI("mysql://user:pass%20word@host/database?unix_socket=/var/mysql/socket")
+ assert user == "user"
+ assert password == "pass%20word"
assert host == "host"
assert port is None
assert path == "/database"
- assert args == {}
+ assert args == {"unix_socket": "/var/mysql/socket"}
user, password, host, port, path, args = _parseURI("postgres://user@host/database")
assert user == "user"
@@ -40,6 +40,14 @@
assert path == "/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres:///full/path/to/socket/database")
+ assert user == None
+ assert password is None
+ assert host == None
+ assert port is None
+ assert path == "/full/path/to/socket/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|
|
From: SourceForge.net <no...@so...> - 2006-03-08 15:58:42
|
Bugs item #1445743, was opened at 2006-03-08 16:58 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1445743&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Submitted By: Dennis Brakhane (dennis) Assigned to: Nobody/Anonymous (nobody) Summary: SQLObject uses assert for parameter checks Initial Comment: SQLObject uses some assert statements to make sure the classes were given correct parameters or called correctly. For example, in dbconnection.py def uri(self): auth = getattr(self, 'user', None) or '' if auth: if self.password: auth = auth + '@' + self.password auth = auth + ':' else: >>> assert not getattr(self, 'password', None), ( >>> 'URIs cannot express passwords without usernames') or assert not self._obsolete, "This transaction has already gone through ROLLBACK; begin another transaction" The problem with these constructs is that if SQLObject is compiled with -O (which, for example Debian does), asserts are removed! So I can import sqlobject and happily pass incorrect values, it will not be noticed. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1445743&group_id=74338 |
|
From: <sub...@co...> - 2006-03-08 14:36:37
|
Author: phd
Date: 2006-03-08 07:36:33 -0700 (Wed, 08 Mar 2006)
New Revision: 1636
Modified:
SQLObject/docs/SQLObject.txt
Log:
Fixed doc - %s interpolation hasn't been committed.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-03-08 14:36:09 UTC (rev 1635)
+++ SQLObject/docs/SQLObject.txt 2006-03-08 14:36:33 UTC (rev 1636)
@@ -739,7 +739,6 @@
single SQL command, a list of SQL commands, or a dictionary with keys that
are dbNames and values that are either single SQL command string or a list
of SQL commands. This is usually for ALTER TABLE commands.
- ``%s``, if present, is substituted with the name of the table.
There is also one instance attribute:
|
|
From: <sub...@co...> - 2006-03-08 14:36:17
|
Author: phd
Date: 2006-03-08 07:36:09 -0700 (Wed, 08 Mar 2006)
New Revision: 1635
Modified:
SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
Log:
Fixed doc - %s interpolation hasn't been committed.
Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-08 02:10:55 UTC (rev 1634)
+++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-08 14:36:09 UTC (rev 1635)
@@ -734,7 +734,6 @@
single SQL command, a list of SQL commands, or a dictionary with keys that
are dbNames and values that are either single SQL command string or a list
of SQL commands. This is usually for ALTER TABLE commands.
- ``%s``, if present, is substituted with the name of the table.
There is also one instance attribute:
|
|
From: <sub...@co...> - 2006-03-01 15:22:42
|
Author: phd
Date: 2006-03-01 08:22:37 -0700 (Wed, 01 Mar 2006)
New Revision: 1633
Modified:
home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
Log:
Merged patches from the revisions 1630:1632 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-03-01 15:21:33 UTC (rev 1632)
+++ home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-03-01 15:22:37 UTC (rev 1633)
@@ -23,7 +23,7 @@
else:
self.client_encoding = None
self.kw = {}
- for key in ("unix_socket", "named_pipe", "init_command",
+ for key in ("unix_socket", "init_command",
"read_default_file", "read_default_group"):
if key in kw:
self.kw[key] = col.popKey(kw, key)
|
|
From: <sub...@co...> - 2006-03-01 15:21:39
|
Author: phd
Date: 2006-03-01 08:21:33 -0700 (Wed, 01 Mar 2006)
New Revision: 1632
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
Log:
Fixed a minor bug.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-03-01 15:19:49 UTC (rev 1631)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-03-01 15:21:33 UTC (rev 1632)
@@ -19,7 +19,7 @@
self.user = user
self.password = passwd
self.kw = {}
- for key in ("unix_socket", "named_pipe", "init_command",
+ for key in ("unix_socket", "init_command",
"read_default_file", "read_default_group"):
if key in kw:
self.kw[key] = col.popKey(kw, key)
|
|
From: <sub...@co...> - 2006-03-01 15:19:55
|
Author: phd
Date: 2006-03-01 08:19:49 -0700 (Wed, 01 Mar 2006)
New Revision: 1631
Modified:
SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
Log:
Fixed a minor bug.
Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-02-26 16:54:02 UTC (rev 1630)
+++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-03-01 15:19:49 UTC (rev 1631)
@@ -23,7 +23,7 @@
else:
self.client_encoding = None
self.kw = {}
- for key in ("unix_socket", "named_pipe", "init_command",
+ for key in ("unix_socket", "init_command",
"read_default_file", "read_default_group"):
if key in kw:
self.kw[key] = col.popKey(kw, key)
|
|
From: SourceForge.net <no...@so...> - 2006-02-28 12:48:52
|
Bugs item #1440300, was opened at 2006-02-28 04:48 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1440300&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Any EnumCol creation throws AssertionError Initial Comment: The simplest example using EnumCol fails with an AssertionError when attempting to create a SQLObject subclass: >>> class Page (SQLObject): ... name=EnumCol(['val1', 'val2']) results in: AssertionError: You cannot change a name after it has already been set (from ['val1', 'val2'] to name) This is in SQLObject v0.7.0. I'm a noob, so maybe this is somehow my fault, but the example seems so simple that I'd like to doubt that for now. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1440300&group_id=74338 |
|
From: <sub...@co...> - 2006-02-26 16:54:10
|
Author: phd
Date: 2006-02-26 09:54:02 -0700 (Sun, 26 Feb 2006)
New Revision: 1630
Modified:
home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
Log:
Merged patches from the revisions 1627:1629 from the trunk: fixed a bug with :memory: database.
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-02-26 16:52:19 UTC (rev 1629)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-02-26 16:54:02 UTC (rev 1630)
@@ -95,7 +95,10 @@
# pool connections. Since we are isolating threads here, we
# don't have to worry about locking as much.
if self._memory:
- return self.makeConnection()
+ conn = self.makeConnection()
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ return conn
threadid = thread.get_ident()
if (self._pool is not None
and self._threadPool.has_key(threadid)):
|
|
From: <sub...@co...> - 2006-02-26 16:52:28
|
Author: phd
Date: 2006-02-26 09:52:19 -0700 (Sun, 26 Feb 2006)
New Revision: 1629
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed a bug with :memory: database.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-02-26 16:52:00 UTC (rev 1628)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-02-26 16:52:19 UTC (rev 1629)
@@ -95,7 +95,10 @@
# pool connections. Since we are isolating threads here, we
# don't have to worry about locking as much.
if self._memory:
- return self.makeConnection()
+ conn = self.makeConnection()
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ return conn
threadid = thread.get_ident()
if (self._pool is not None
and self._threadPool.has_key(threadid)):
|
|
From: <sub...@co...> - 2006-02-26 16:52:23
|
Author: phd
Date: 2006-02-26 09:52:00 -0700 (Sun, 26 Feb 2006)
New Revision: 1628
Modified:
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed a bug with :memory: database.
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-02-26 15:45:42 UTC (rev 1627)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-02-26 16:52:00 UTC (rev 1628)
@@ -95,7 +95,10 @@
# pool connections. Since we are isolating threads here, we
# don't have to worry about locking as much.
if self._memory:
- return self.makeConnection()
+ conn = self.makeConnection()
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ return conn
threadid = thread.get_ident()
if (self._pool is not None
and self._threadPool.has_key(threadid)):
|
|
From: <sub...@co...> - 2006-02-26 15:45:51
|
Author: phd
Date: 2006-02-26 08:45:42 -0700 (Sun, 26 Feb 2006)
New Revision: 1627
Modified:
SQLObject/docs/SQLObject.txt
Log:
A description for createSQL by David Faure.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-02-26 15:45:13 UTC (rev 1626)
+++ SQLObject/docs/SQLObject.txt 2006-02-26 15:45:42 UTC (rev 1627)
@@ -734,7 +734,14 @@
`indexes`:
A list of all the indexes for this class.
+`createSQL`:
+ SQL queries run after table creation. createSQL can be a string with a
+ single SQL command, a list of SQL commands, or a dictionary with keys that
+ are dbNames and values that are either single SQL command string or a list
+ of SQL commands. This is usually for ALTER TABLE commands.
+ ``%s``, if present, is substituted with the name of the table.
+
There is also one instance attribute:
`expired`:
|
|
From: <sub...@co...> - 2006-02-26 15:45:28
|
Author: phd
Date: 2006-02-26 08:45:13 -0700 (Sun, 26 Feb 2006)
New Revision: 1626
Modified:
SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
Log:
A description for createSQL by David Faure.
Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-02-23 04:28:38 UTC (rev 1625)
+++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-02-26 15:45:13 UTC (rev 1626)
@@ -729,7 +729,14 @@
`indexes`:
A list of all the indexes for this class.
+`createSQL`:
+ SQL queries run after table creation. createSQL can be a string with a
+ single SQL command, a list of SQL commands, or a dictionary with keys that
+ are dbNames and values that are either single SQL command string or a list
+ of SQL commands. This is usually for ALTER TABLE commands.
+ ``%s``, if present, is substituted with the name of the table.
+
There is also one instance attribute:
`expired`:
|
|
From: <sub...@co...> - 2006-02-23 04:08:33
|
Author: ianb Date: 2006-02-22 21:08:30 -0700 (Wed, 22 Feb 2006) New Revision: 1622 Removed: MetaSQLObject/ Log: Finishing rename |
|
From: <sub...@co...> - 2006-02-23 04:08:14
|
Author: ianb Date: 2006-02-22 21:08:11 -0700 (Wed, 22 Feb 2006) New Revision: 1621 Added: SQLObject2/trunk/ Removed: MetaSQLObject/trunk/ Log: Renaming Copied: SQLObject2/trunk (from rev 1620, MetaSQLObject/trunk) |
|
From: <sub...@co...> - 2006-02-23 04:07:16
|
Author: ianb
Date: 2006-02-22 21:07:09 -0700 (Wed, 22 Feb 2006)
New Revision: 1619
Added:
MetaSQLObject/trunk/docs/index.txt
Removed:
MetaSQLObject/trunk/metasqlobject/classregistry.py
Log:
Removed old module, added new doc
Added: MetaSQLObject/trunk/docs/index.txt
===================================================================
--- MetaSQLObject/trunk/docs/index.txt 2006-02-21 06:33:37 UTC (rev 1618)
+++ MetaSQLObject/trunk/docs/index.txt 2006-02-23 04:07:09 UTC (rev 1619)
@@ -0,0 +1,136 @@
+SQLObject 2
+===========
+
+So, what is this?
+
+This is a project to factor out pieces of SQLObject, and make it more
+comfortable to use SQLObject in combination with ad hoc queries, to
+build on SQLObject, and generally to do interesting things.
+
+Package Decomposition
+---------------------
+
+SQLObject 2 breaks SQLObject into three parts (roughly):
+
+* Database infrastructure that is logic-free. This is stuff that
+ could be used anywhere, and can be used in whole or in part. This
+ is what makes up SQL-API.
+
+* Metaprogramming tricks. These are things that aren't specific to
+ SQLObject, but are just general bits of code. Things like events,
+ threadlocal configuration, metaclasses. This is in the
+ ``metasqlobject`` package. Things will float in and out of this
+ package to start.
+
+* SQLObject itself, in the ``sqlobject`` package. This is the
+ object-relational mapper you've come to know and love. You love it,
+ right? Sure you do.
+
+Compatibility
+-------------
+
+Right now (Feb 2006) SQLObject 2 is pre-alpha, and is very not
+compatible with SQLObject 0.X. The test-driven development of
+SQLObject 2 will be to use as many of SQLObject's existing tests as
+possible.
+
+The goal is that if you use SQLObject 2, much of what you do will work
+right away. You'll get a bunch of warnings about things that are
+deprecated, and you'll get some (helpful) messages about things that
+are just plain gone.
+
+If you are digging inside SQLObject, it is very possible that your
+stuff will just be broken. But if you are using fairly public APIs,
+then you should do okay.
+
+``InheritableSQLObject`` is not part of SQLObject 2 at all at this
+point. I definitely want to change that, hopefully sooner rather than
+later. It might be possible to make that same functionality a part of
+the core of SQLObject using some of the new extension techniques,
+without a separate subclass.
+
+Architecture Differences
+------------------------
+
+The package separation is a big part of the difference.
+
+In general SQLObject also tries to move more of the data and logic out
+of the core classes -- ``SQLObject`` itself is quite small (especially
+when you consider that several of the functions are mostly made up of
+argument checks). ``sqlmeta`` really does the bulk of the work, but
+tries to stay small as well. Descriptors are used to greater effect.
+
+The event system is not fully developed yet, but is going to be a core
+part of the system. SQLObject (not-2's) trunk also has an event
+system. In SQLObject 2 the event system is ad hoc, because that was
+just a lot easier to handle in terms of subclassing (previously
+SQLObject used PyDispatcher). The event system will be a core part of
+the way all joins will work, among other more advanced features.
+
+Compound keys are not yet (fully) implemented, but are a core part of
+the design.
+
+Bound parameters are the only kind of queries really supported (fully
+rendered SQL is supported for logging and debugging only).
+
+SQLObject 2 tries to make up as few names as possible -- preferably no
+names. In some cases this means moving functionality elsewhere, in
+some cases being a bit more explicit. For instance ``ForeignKey``
+will be deprecated, and this::
+
+ class Foo(SQLObject):
+ other = ForeignKey('Other')
+
+Is now better done this way::
+
+ class Foo(SQLObject):
+ other_id = IntCol()
+ other = Reference('Other', 'other_id')
+
+Maybe at some future point ``other_id`` can be determined
+automatically, but the basic idea of the column as a separate entity
+from the reference will remain. I'm already very happy with how this
+is working. ``ForeignKey`` now implies exactly those two columns you
+see there.
+
+Names will be moving to underscore-style (PEP 8 compliant), instead of
+mixed case. There's not that many anyway -- ``selectBy``,
+``orderBy``, ``objectID``.
+
+SQLObject will work with DB-API-like connections (actually using a
+thin wrapper from SQL-API, but that wrapper goes right over DB-API
+connections). Logging happens below SQLObject now.
+
+Caching will be carefully considered. I want SQLObject 2 to be much
+more multiprocess-friendly, and much more predictable in terms of
+performance. Right now there is no caching, which introduces some
+problems (for instance, changes to an instance may not effect another
+instance that represents the same row). Probably the result will be
+caching not wholely unlike SQLObject's current caching, except with
+stricter thread affinity -- objects will not be cached or shared
+between threads. But we'll start from zero and work up, with firmer
+promises about how caching works.
+
+Compound queries will be possible -- i.e., fetching objects from more
+than one class at a time, including left joins. Some of the code is
+already in place for this. Features like lazy fetching of columns
+should be much easier. Lazy updates and inserts should be possible
+(i.e., explicit saves).
+
+Column objects are more powerful and more in control of their own
+existance. Column overrides are more explicit. So what was::
+
+ class User(SQLObject):
+ password = StringCol()
+ def _set_password(self, value):
+ self._SO_set_password(value.encode('rot13'))
+
+Will now be::
+
+ class User(SQLObject):
+ class password(StringCol):
+ def set(self, obj, value, raw_set):
+ raw_set(obj, value.encode('rot13')
+
+Well, that's just a few things. More to come!
+
Property changes on: MetaSQLObject/trunk/docs/index.txt
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision
Name: svn:eol-style
+ native
Deleted: MetaSQLObject/trunk/metasqlobject/classregistry.py
===================================================================
--- MetaSQLObject/trunk/metasqlobject/classregistry.py 2006-02-21 06:33:37 UTC (rev 1618)
+++ MetaSQLObject/trunk/metasqlobject/classregistry.py 2006-02-23 04:07:09 UTC (rev 1619)
@@ -1,135 +0,0 @@
-"""
-classresolver.py
- 2 February 2004, Ian Bicking <ia...@co...>
-
-Resolves strings to classes, and runs callbacks when referenced
-classes are created.
-
-Classes are referred to only by name, not by module. So that
-identically-named classes can coexist, classes are put into individual
-registries, which are keyed on strings (names). These registries are
-created on demand.
-
-Use like::
-
- >>> import classregistry
- >>> registry = classregistry.registry('MyModules')
- >>> def afterMyClassExists(cls):
- ... print 'Class finally exists:', cls
- >>> registry.addClassCallback('MyClass', afterMyClassExists)
- >>> class MyClass:
- ... pass
- >>> registry.addClass(MyClass)
- Class finally exists: MyClass
-
-"""
-
-class ClassRegistry(object):
- """
- We'll be dealing with classes that reference each other, so
- class C1 may reference C2 (in a join), while C2 references
- C1 right back. Since classes are created in an order, there
- will be a point when C1 exists but C2 doesn't. So we deal
- with classes by name, and after each class is created we
- try to fix up any references by replacing the names with
- actual classes.
-
- Here we keep a dictionaries of class names to classes -- note
- that the classes might be spread among different modules, so
- since we pile them together names need to be globally unique,
- to just module unique.
- Like needSet below, the container dictionary is keyed by the
- class registry.
- """
-
- def __init__(self, name):
- self.name = name
- self.classes = {}
- self.callbacks = {}
- self.genericCallbacks = []
-
- def addClassCallback(self, className, callback, *args, **kw):
- """
- Whenever a name is substituted for the class, you can register
- a callback that will be called when the needed class is
- created. If it's already been created, the callback will be
- called immediately.
- """
- if self.classes.has_key(className):
- callback(self.classes[className], *args, **kw)
- else:
- self.callbacks.setdefault(className, []).append((callback, args, kw))
-
- def addCallback(self, callback, *args, **kw):
- """
- This callback is called for all classes, not just specific
- ones (like addClassCallback).
- """
- self.genericCallbacks.append((callback, args, kw))
- for cls in self.classes.values():
- callback(cls, *args, **kw)
-
- def addClass(self, cls):
- """
- Everytime a class is created, we add it to the registry, so
- that other classes can find it by name. We also call any
- callbacks that are waiting for the class.
- """
- if cls.__name__ in self.classes:
- import sys
- other = self.classes[cls.__name__]
- raise ValueError(
- "class %s is already in the registry (other class is "
- "%r, from the module %s in %s; attempted new class is "
- "%r, from the module %s in %s)"
- % (cls.__name__,
- other, other.__module__,
- getattr(sys.modules.get(other.__module__),
- '__file__', '(unknown)'),
- cls, cls.__module__,
- getattr(sys.modules.get(cls.__module__),
- '__file__', '(unknown)')))
- self.classes[cls.__name__] = cls
- if self.callbacks.has_key(cls.__name__):
- for callback, args, kw in self.callbacks[cls.__name__]:
- callback(cls, *args, **kw)
- del self.callbacks[cls.__name__]
- for callback, args, kw in self.genericCallbacks:
- callback(cls, *args, **kw)
-
- def getClass(self, className):
- try:
- return self.classes[className]
- except KeyError:
- all = self.classes.keys()
- all.sort()
- raise KeyError(
- "No class %s found in the registry %s (these classes "
- "exist: %s)"
- % (className, self.name or '[default]', ', '.join(all)))
-
- def allClasses(self):
- return self.classes.values()
-
-class _MasterRegistry(object):
- """
- This singleton holds all the class registries. There can be
- multiple registries to hold different unrelated sets of classes
- that reside in the same process. These registries are named with
- strings, and are created on demand. The MasterRegistry module
- global holds the singleton.
- """
-
- def __init__(self):
- self.registries = {}
-
- def registry(self, item):
- if not self.registries.has_key(item):
- self.registries[item] = ClassRegistry(item)
- return self.registries[item]
-
-MasterRegistry = _MasterRegistry()
-registry = MasterRegistry.registry
-
-def findClass(name, class_registry=None):
- return registry(class_registry).getClass(name)
|
|
From: <sub...@co...> - 2006-02-20 15:33:09
|
Author: phd
Date: 2006-02-20 08:33:00 -0700 (Mon, 20 Feb 2006)
New Revision: 1616
Modified:
home/phd/SQLObject/paramstyles/sqlobject/col.py
home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
Log:
Merged patches from the revisions 1614:1615 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-02-20 15:30:54 UTC (rev 1615)
+++ home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-02-20 15:33:00 UTC (rev 1616)
@@ -781,37 +781,9 @@
'sTName': sTName})
return constraint
- def mysqlCreateReferenceConstraint(self):
- sTName = self.soClass.sqlmeta.table
- other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
- tName = other.sqlmeta.table
- idName = other.sqlmeta.idName
- if self.cascade is not None:
- if self.cascade == 'null':
- action = 'ON DELETE SET NULL'
- elif self.cascade:
- action = 'ON DELETE CASCADE'
- else:
- action = 'ON DELETE RESTRICT'
- else:
- action = ''
- constraint = ('ALTER TABLE %(sTName)s ADD CONSTRAINT %(sTName)s_%(colName)s_to_%(tName)s '
- 'FOREIGN KEY (%(colName)s) '
- 'REFERENCES %(tName)s (%(idName)s) '
- '%(action)s' %
- {'tName': tName,
- 'colName': self.dbName,
- 'idName': idName,
- 'action': action,
- 'sTName': sTName})
- return constraint
-
def mysqlCreateSQL(self):
return SOKeyCol.mysqlCreateSQL(self)
- def mysqlCreateReferenceConstraint(self):
- return None
-
def sybaseCreateSQL(self):
sql = SOKeyCol.sybaseCreateSQL(self)
other = findClass(self.foreignKey)
Modified: home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-02-20 15:30:54 UTC (rev 1615)
+++ home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-02-20 15:33:00 UTC (rev 1616)
@@ -104,15 +104,9 @@
def createColumn(self, soClass, col):
return col.mysqlCreateSQL()
- def createReferenceConstraint(self, soClass, col):
- return col.mysqlCreateReferenceConstraint()
-
def createIndexSQL(self, soClass, index):
return index.mysqlCreateIndexSQL(soClass)
- def createReferenceConstraint(self, soClass, col):
- return col.mysqlCreateReferenceConstraint()
-
def createIDColumn(self, soClass):
if soClass.sqlmeta.idType == str:
return '%s TEXT PRIMARY KEY' % soClass.sqlmeta.idName
|