sqlobject-cvs Mailing List for SQLObject (Page 65)
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
|
Dec
|
From: <sub...@co...> - 2008-07-24 16:04:34
|
Author: phd Date: 2008-07-24 10:04:25 -0600 (Thu, 24 Jul 2008) New Revision: 3525 Modified: SQLObject/branches/0.9/sqlobject/sqlite/sqliteconnection.py Log: Fixed the bug 2009801: sqlobject-admin fails to process sqlite database with enums. Modified: SQLObject/branches/0.9/sqlobject/sqlite/sqliteconnection.py =================================================================== --- SQLObject/branches/0.9/sqlobject/sqlite/sqliteconnection.py 2008-07-23 15:41:06 UTC (rev 3524) +++ SQLObject/branches/0.9/sqlobject/sqlite/sqliteconnection.py 2008-07-24 16:04:25 UTC (rev 3525) @@ -308,9 +308,9 @@ raise ValueError('The table %s ws not found in the database. Load failed.' % tableName) colData = colData[0].split('(', 1)[1].strip()[:-2] while colData.find('(') > -1: - st = colData.find('(') - en = colData.find(')') - colData = colData[:st] + colData[en+1:] + start = colData.find('(') + end = colData.find(')', start) + colData = colData[:start] + colData[end+1:] results = [] for colDesc in colData.split(','): parts = colDesc.strip().split(' ', 2) |
From: SourceForge.net <no...@so...> - 2008-07-24 15:56:13
|
Bugs item #2026909, was opened at 2008-07-24 19:43 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2026909&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: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: name column should be available Initial Comment: Hello, I want to migrate from sqlalchemy to sqlobject but it doesn't allow to me to use "name" columns. My application makes widely use of this naming, how can I bypass this restriction? ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2008-07-24 19:56 Message: Logged In: YES user_id=4799 Originator: NO Welcome and good luck! (-: ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2008-07-24 19:45 Message: Logged In: NO I'm sorry, it was my mistake, you can close the bug as worksforme. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2026909&group_id=74338 |
From: SourceForge.net <no...@so...> - 2008-07-24 15:45:55
|
Bugs item #2026909, was opened at 2008-07-24 15:43 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2026909&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 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: name column should be available Initial Comment: Hello, I want to migrate from sqlalchemy to sqlobject but it doesn't allow to me to use "name" columns. My application makes widely use of this naming, how can I bypass this restriction? ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2008-07-24 15:45 Message: Logged In: NO I'm sorry, it was my mistake, you can close the bug as worksforme. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2026909&group_id=74338 |
From: SourceForge.net <no...@so...> - 2008-07-24 15:43:46
|
Bugs item #2026909, was opened at 2008-07-24 15:43 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=2026909&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 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: name column should be available Initial Comment: Hello, I want to migrate from sqlalchemy to sqlobject but it doesn't allow to me to use "name" columns. My application makes widely use of this naming, how can I bypass this restriction? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2026909&group_id=74338 |
From: <sub...@co...> - 2008-07-23 15:42:37
|
Author: phd Date: 2008-07-23 09:41:06 -0600 (Wed, 23 Jul 2008) New Revision: 3524 Modified: SQLObject/trunk/sqlobject/tests/test_schema.py Log: Allow the test to be run without 'schema=' parameter in the DB URI. Modified: SQLObject/trunk/sqlobject/tests/test_schema.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_schema.py 2008-07-23 14:22:44 UTC (rev 3523) +++ SQLObject/trunk/sqlobject/tests/test_schema.py 2008-07-23 15:41:06 UTC (rev 3524) @@ -11,12 +11,11 @@ def test_connection_schema(): if not supports('schema'): return - conn = getConnection(schema=None) + conn = getConnection() conn.schema = None conn.query('CREATE SCHEMA test') + conn.schema = 'test' + conn.query('SET search_path TO test') setupClass(Test) Test(foo='bar') - conn = Test._connection - assert conn.schema, \ - """To test a schema you need to give a connection uri that contains a schema.""" - assert conn.queryAll("select * from %s.test" % conn.schema) + assert conn.queryAll("SELECT * FROM test.test") |
From: <sub...@co...> - 2008-07-23 14:22:46
|
Author: phd Date: 2008-07-23 08:22:44 -0600 (Wed, 23 Jul 2008) New Revision: 3523 Modified: SQLObject/trunk/docs/News.txt Log: Added some support for schemas in PostgreSQL. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2008-07-23 14:20:47 UTC (rev 3522) +++ SQLObject/trunk/docs/News.txt 2008-07-23 14:22:44 UTC (rev 3523) @@ -25,6 +25,8 @@ * SQLObject can now create and drop a database in MySQL, PostgreSQL, SQLite and Firebird/Interbase. +* Added some support for schemas in PostgreSQL. + Minor features -------------- |
From: <sub...@co...> - 2008-07-23 14:20:49
|
Author: phd Date: 2008-07-23 08:20:47 -0600 (Wed, 23 Jul 2008) New Revision: 3522 Added: SQLObject/trunk/sqlobject/tests/test_schema.py Modified: SQLObject/trunk/docs/SQLObject.txt SQLObject/trunk/sqlobject/postgres/pgconnection.py SQLObject/trunk/sqlobject/tests/dbtest.py Log: A patch by Diez B. Roggisch: added support for schemas in PostgreSQL. Modified: SQLObject/trunk/docs/SQLObject.txt =================================================================== --- SQLObject/trunk/docs/SQLObject.txt 2008-07-23 13:58:11 UTC (rev 3521) +++ SQLObject/trunk/docs/SQLObject.txt 2008-07-23 14:20:47 UTC (rev 3522) @@ -162,7 +162,8 @@ Parameters are: ``debug`` (default: False), ``debugOutput`` (default: False), ``cache`` (default: True), ``autoCommit`` (default: True), ``debugThreading`` (default: False), -``logger`` (default: None), ``loglevel`` (default: None). +``logger`` (default: None), ``loglevel`` (default: None), +``schema`` (default: None). If you want to pass True value in a connection URI - pass any non-empty string; an empty string for False. Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py =================================================================== --- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2008-07-23 13:58:11 UTC (rev 3521) +++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2008-07-23 14:20:47 UTC (rev 3522) @@ -85,6 +85,7 @@ dsn = ' '.join(dsn) self.dsn = dsn self.unicodeCols = unicodeCols + self.schema = kw.pop('schema', None) DBAPI.__init__(self, **kw) def connectionFromURI(cls, uri): @@ -114,6 +115,9 @@ # psycopg2 does not have an autocommit method. if hasattr(conn, 'autocommit'): conn.autocommit(1) + if self.schema: + c = conn.cursor() + c.execute("SET search_path TO " + self.schema) return conn def _queryInsertID(self, conn, soInstance, id, names, values): Modified: SQLObject/trunk/sqlobject/tests/dbtest.py =================================================================== --- SQLObject/trunk/sqlobject/tests/dbtest.py 2008-07-23 13:58:11 UTC (rev 3521) +++ SQLObject/trunk/sqlobject/tests/dbtest.py 2008-07-23 14:20:47 UTC (rev 3522) @@ -45,7 +45,8 @@ '-blobData': 'mssql', '-decimalColumn': 'mssql', '-emptyTable': 'mssql', - '-limitSelect' : 'mssql' + '-limitSelect' : 'mssql', + '+schema' : 'postgres', } Added: SQLObject/trunk/sqlobject/tests/test_schema.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_schema.py (rev 0) +++ SQLObject/trunk/sqlobject/tests/test_schema.py 2008-07-23 14:20:47 UTC (rev 3522) @@ -0,0 +1,22 @@ +from sqlobject import * +from sqlobject.tests.dbtest import * + +######################################## +## Schema per connection +######################################## + +class Test(SQLObject): + foo = UnicodeCol(length=200) + +def test_connection_schema(): + if not supports('schema'): + return + conn = getConnection(schema=None) + conn.schema = None + conn.query('CREATE SCHEMA test') + setupClass(Test) + Test(foo='bar') + conn = Test._connection + assert conn.schema, \ + """To test a schema you need to give a connection uri that contains a schema.""" + assert conn.queryAll("select * from %s.test" % conn.schema) |
From: <sub...@co...> - 2008-07-23 13:58:14
|
Author: phd Date: 2008-07-23 07:58:11 -0600 (Wed, 23 Jul 2008) New Revision: 3521 Modified: SQLObject/trunk/docs/DeveloperGuide.txt Log: Minor documentation update - fixed devguide on how to pass DB URI to tests. Modified: SQLObject/trunk/docs/DeveloperGuide.txt =================================================================== --- SQLObject/trunk/docs/DeveloperGuide.txt 2008-07-23 13:57:48 UTC (rev 3520) +++ SQLObject/trunk/docs/DeveloperGuide.txt 2008-07-23 13:58:11 UTC (rev 3521) @@ -152,11 +152,9 @@ .. _getting started: http://codespeak.net/py/dist/test.html#starting-point-py-test-command-line-tool To actually run the test, you have to give it a database to connect -to. You do this with the ``TESTDB`` environmental variable (right now -py.test doesn't have a better way to add custom options). You can -give the complete URI to access your test database, or you can give it -a shortcut like ``mysql`` (these shortcuts are defined in the top of -``tests/dbtest.py``. +to. You do so with the option "-D". You can either give a complete URI or one of several +shortcuts like ``mysql`` (these shortcuts are defined in the top of +``tests/dbtest.py``). All the tests are modules in ``sqlobject/tests``. Each module tests one kind of feature, more or less. If you are testing a module, call |
From: <sub...@co...> - 2008-07-23 13:57:49
|
Author: phd Date: 2008-07-23 07:57:48 -0600 (Wed, 23 Jul 2008) New Revision: 3520 Modified: SQLObject/branches/0.10/docs/DeveloperGuide.txt Log: Minor documentation update - fixed devguide on how to pass DB URI to tests. Modified: SQLObject/branches/0.10/docs/DeveloperGuide.txt =================================================================== --- SQLObject/branches/0.10/docs/DeveloperGuide.txt 2008-07-23 13:57:17 UTC (rev 3519) +++ SQLObject/branches/0.10/docs/DeveloperGuide.txt 2008-07-23 13:57:48 UTC (rev 3520) @@ -152,11 +152,9 @@ .. _getting started: http://codespeak.net/py/dist/test.html#starting-point-py-test-command-line-tool To actually run the test, you have to give it a database to connect -to. You do this with the ``TESTDB`` environmental variable (right now -py.test doesn't have a better way to add custom options). You can -give the complete URI to access your test database, or you can give it -a shortcut like ``mysql`` (these shortcuts are defined in the top of -``tests/dbtest.py``. +to. You do so with the option "-D". You can either give a complete URI or one of several +shortcuts like ``mysql`` (these shortcuts are defined in the top of +``tests/dbtest.py``). All the tests are modules in ``sqlobject/tests``. Each module tests one kind of feature, more or less. If you are testing a module, call |
From: <sub...@co...> - 2008-07-23 13:57:23
|
Author: phd Date: 2008-07-23 07:57:17 -0600 (Wed, 23 Jul 2008) New Revision: 3519 Modified: SQLObject/branches/0.9/docs/DeveloperGuide.txt Log: Minor documentation update - fixed devguide on how to pass DB URI to tests. Modified: SQLObject/branches/0.9/docs/DeveloperGuide.txt =================================================================== --- SQLObject/branches/0.9/docs/DeveloperGuide.txt 2008-07-19 23:30:05 UTC (rev 3518) +++ SQLObject/branches/0.9/docs/DeveloperGuide.txt 2008-07-23 13:57:17 UTC (rev 3519) @@ -152,11 +152,9 @@ .. _getting started: http://codespeak.net/py/dist/test.html#starting-point-py-test-command-line-tool To actually run the test, you have to give it a database to connect -to. You do this with the ``TESTDB`` environmental variable (right now -py.test doesn't have a better way to add custom options). You can -give the complete URI to access your test database, or you can give it -a shortcut like ``mysql`` (these shortcuts are defined in the top of -``tests/dbtest.py``. +to. You do so with the option "-D". You can either give a complete URI or one of several +shortcuts like ``mysql`` (these shortcuts are defined in the top of +``tests/dbtest.py``). All the tests are modules in ``sqlobject/tests``. Each module tests one kind of feature, more or less. If you are testing a module, call |
From: SourceForge.net <no...@so...> - 2008-07-22 15:33:19
|
Bugs item #2024794, was opened at 2008-07-22 08:33 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=2024794&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 Private: No Submitted By: Ray Van dolson (rayvd) Assigned to: Nobody/Anonymous (nobody) Summary: Using idName with fromDatabase; id col issues Initial Comment: See this post: http://thread.gmane.org/gmane.comp.python.sqlobject/9360 When using fromDatabase = True with idName: class SystemsInfo(SQLObject): class sqlmeta: fromDatabase = True table = 'SystemsInfo' idType = str idName = 'SystemName' lazyUpdate = True .. an attempt to insert a new row with all other columns but the index (SystemName) defined results in a duplicate column error: item = SystemsInfo(id='uniquename') SystemName is used both as the id column and is in place in the normal column listing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2024794&group_id=74338 |
From: <sub...@co...> - 2008-07-17 13:27:55
|
Author: phd Date: 2008-07-17 07:13:08 -0600 (Thu, 17 Jul 2008) New Revision: 3510 Added: SQLObject/branches/0.10/sqlobject/tests/test_default_style.py Modified: SQLObject/branches/0.10/docs/News.txt Log: Merged r3509 from the 0.9 branch: added test_default_style.py from the SF patch 2007233. Modified: SQLObject/branches/0.10/docs/News.txt =================================================================== --- SQLObject/branches/0.10/docs/News.txt 2008-07-17 13:10:35 UTC (rev 3509) +++ SQLObject/branches/0.10/docs/News.txt 2008-07-17 13:13:08 UTC (rev 3510) @@ -104,6 +104,8 @@ * Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html +* Added test_default_style.py. + SQLObject 0.9.7 =============== Copied: SQLObject/branches/0.10/sqlobject/tests/test_default_style.py (from rev 3509, SQLObject/branches/0.9/sqlobject/tests/test_default_style.py) =================================================================== --- SQLObject/branches/0.10/sqlobject/tests/test_default_style.py (rev 0) +++ SQLObject/branches/0.10/sqlobject/tests/test_default_style.py 2008-07-17 13:13:08 UTC (rev 3510) @@ -0,0 +1,58 @@ +""" +Test the default styles, to guarantee consistency. +""" + +from sqlobject import * +from sqlobject.tests.dbtest import * +from sqlobject.styles import Style, MixedCaseUnderscoreStyle, MixedCaseStyle + +#hash of styles versus the database names resulting from 'columns' below +columns = ["ABCUpper", "abc_lower", "ABCamelCaseColumn"] +styles = {Style:columns, + MixedCaseUnderscoreStyle:["abc_upper", "abc_lower", "ab_camel_case_column"], + MixedCaseStyle:["ABCUpper", "Abc_lower", "ABCamelCaseColumn"], + } + +#hash of styles versus the database names resulting from a foreign key named 'FKey' +fkey = ForeignKey("DefaultStyleTest", name="FKey") +fkeys = {Style:"FKeyID", + MixedCaseUnderscoreStyle:"f_key_id", + MixedCaseStyle:"FKeyID", + } + + +def make_columns(): + global columns + columns = [] + for col_name in columns: + columns.append(StringCol(name=col_name, length=10)) + + +def do_col_test(DefaultStyleTest, style, dbnames): + DefaultStyleTest.sqlmeta.style = style() + for col, old_dbname in zip(columns, dbnames): + DefaultStyleTest.sqlmeta.addColumn(col) + try: + new_dbname = DefaultStyleTest.sqlmeta.columns[col.name].dbName + assert new_dbname == old_dbname + finally: + if col.name in DefaultStyleTest.sqlmeta.columns: + DefaultStyleTest.sqlmeta.delColumn(col) + +def do_fkey_test(DefaultStyleTest, style, dbname): + DefaultStyleTest.sqlmeta.style = style() + DefaultStyleTest.sqlmeta.addColumn(fkey) + try: + assert DefaultStyleTest.sqlmeta.columns.keys()[0] == "FKeyID" + assert DefaultStyleTest.sqlmeta.columns.values()[0].dbName == dbname + finally: + DefaultStyleTest.sqlmeta.delColumn(fkey) + +class DefaultStyleTest(SQLObject): + pass + +def test_default_styles(): + make_columns() + for style in styles: + yield do_col_test, DefaultStyleTest, style, styles[style] + yield do_fkey_test, DefaultStyleTest, style, fkeys[style] |
From: <sub...@co...> - 2008-07-17 13:23:04
|
Author: phd Date: 2008-07-17 07:14:02 -0600 (Thu, 17 Jul 2008) New Revision: 3511 Added: SQLObject/trunk/sqlobject/tests/test_default_style.py Modified: SQLObject/trunk/docs/News.txt Log: Merged r3509 from the 0.9 branch: added test_default_style.py from the SF patch 2007233. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2008-07-17 13:13:08 UTC (rev 3510) +++ SQLObject/trunk/docs/News.txt 2008-07-17 13:14:02 UTC (rev 3511) @@ -130,6 +130,8 @@ * Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html +* Added test_default_style.py. + SQLObject 0.9.7 =============== Copied: SQLObject/trunk/sqlobject/tests/test_default_style.py (from rev 3510, SQLObject/branches/0.10/sqlobject/tests/test_default_style.py) =================================================================== --- SQLObject/trunk/sqlobject/tests/test_default_style.py (rev 0) +++ SQLObject/trunk/sqlobject/tests/test_default_style.py 2008-07-17 13:14:02 UTC (rev 3511) @@ -0,0 +1,58 @@ +""" +Test the default styles, to guarantee consistency. +""" + +from sqlobject import * +from sqlobject.tests.dbtest import * +from sqlobject.styles import Style, MixedCaseUnderscoreStyle, MixedCaseStyle + +#hash of styles versus the database names resulting from 'columns' below +columns = ["ABCUpper", "abc_lower", "ABCamelCaseColumn"] +styles = {Style:columns, + MixedCaseUnderscoreStyle:["abc_upper", "abc_lower", "ab_camel_case_column"], + MixedCaseStyle:["ABCUpper", "Abc_lower", "ABCamelCaseColumn"], + } + +#hash of styles versus the database names resulting from a foreign key named 'FKey' +fkey = ForeignKey("DefaultStyleTest", name="FKey") +fkeys = {Style:"FKeyID", + MixedCaseUnderscoreStyle:"f_key_id", + MixedCaseStyle:"FKeyID", + } + + +def make_columns(): + global columns + columns = [] + for col_name in columns: + columns.append(StringCol(name=col_name, length=10)) + + +def do_col_test(DefaultStyleTest, style, dbnames): + DefaultStyleTest.sqlmeta.style = style() + for col, old_dbname in zip(columns, dbnames): + DefaultStyleTest.sqlmeta.addColumn(col) + try: + new_dbname = DefaultStyleTest.sqlmeta.columns[col.name].dbName + assert new_dbname == old_dbname + finally: + if col.name in DefaultStyleTest.sqlmeta.columns: + DefaultStyleTest.sqlmeta.delColumn(col) + +def do_fkey_test(DefaultStyleTest, style, dbname): + DefaultStyleTest.sqlmeta.style = style() + DefaultStyleTest.sqlmeta.addColumn(fkey) + try: + assert DefaultStyleTest.sqlmeta.columns.keys()[0] == "FKeyID" + assert DefaultStyleTest.sqlmeta.columns.values()[0].dbName == dbname + finally: + DefaultStyleTest.sqlmeta.delColumn(fkey) + +class DefaultStyleTest(SQLObject): + pass + +def test_default_styles(): + make_columns() + for style in styles: + yield do_col_test, DefaultStyleTest, style, styles[style] + yield do_fkey_test, DefaultStyleTest, style, fkeys[style] |
From: <sub...@co...> - 2008-07-17 13:19:39
|
Author: phd Date: 2008-07-17 07:19:36 -0600 (Thu, 17 Jul 2008) New Revision: 3512 Added: SQLObject/trunk/sqlobject/include/hashcol.py Modified: SQLObject/trunk/docs/News.txt Log: Added sqlobject.include.hascol.HashCol from SF patch 2013132. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2008-07-17 13:14:02 UTC (rev 3511) +++ SQLObject/trunk/docs/News.txt 2008-07-17 13:19:36 UTC (rev 3512) @@ -30,9 +30,17 @@ * Use reversed() in manager/command.py instead of .__reversed__(). -* DecimalStringCol - similar to DecimalCol but stores data as strings to - work around problems in some drivers and type affinity problem in SQLite. +* Added DecimalStringCol - similar to DecimalCol but stores data as strings + to work around problems in some drivers and type affinity problem in + SQLite. +* Added sqlobject.include.hascol.HashCol - a column type that automatically + hashes anything going into it, and returns out an object that hashes + anything being compared to itself. Basically, it's good for really simple + one-way password fields, and it even supports the assignment of None to + indicate no password set. By default, it uses the md5 library for + hashing, but this can be changed in a HashCol definition. + SQLObject 0.10.3 ================ Added: SQLObject/trunk/sqlobject/include/hashcol.py =================================================================== --- SQLObject/trunk/sqlobject/include/hashcol.py (rev 0) +++ SQLObject/trunk/sqlobject/include/hashcol.py 2008-07-17 13:19:36 UTC (rev 3512) @@ -0,0 +1,62 @@ +__all__ = ['HashCol'] + +import sqlobject.col + +class DbHash: + """ Presents a comparison object for hashes, allowing plain text to be + automagically compared with the base content. """ + + def __init__( self, hash, hashMethod ): + self.hash = hash + self.hashMethod = hashMethod + + def __cmp__( self, other ): + if other is None: + if self.hash is None: + return 0 + return True + if not isinstance( other, basestring ): + raise TypeError( "A hash may only be compared with a string, or None." ) + return cmp( self.hashMethod( other ), self.hash ) + + def __repr__( self ): + return "<DbHash>" + +class HashValidator( sqlobject.col.StringValidator ): + """ Provides formal SQLObject validation services for the HashCol. """ + + def to_python( self, value, state ): + """ Passes out a hash object. """ + if value is None: + return None + return DbHash( hash = value, hashMethod = self.hashMethod ) + + def from_python( self, value, state ): + """ Store the given value as a MD5 hash, or None if specified. """ + if value is None: + return None + return self.hashMethod( value ) + +class SOHashCol( sqlobject.col.SOStringCol ): + """ The internal HashCol definition. By default, enforces a md5 digest. """ + + def __init__( self, **kw ): + if 'hashMethod' not in kw: + from md5 import md5 + self.hashMethod = lambda v: md5( v ).hexdigest() + if 'length' not in kw: + kw['length'] = 32 + else: + self.hashMethod = kw['hashMethod'] + del kw['hashMethod'] + super( sqlobject.col.SOStringCol, self ).__init__( **kw ) + + def createValidators( self ): + return [HashValidator( name=self.name, hashMethod=self.hashMethod )] + \ + super( SOHashCol, self ).createValidators() + +class HashCol( sqlobject.col.StringCol ): + """ End-user HashCol class. May be instantiated with 'hashMethod', a function + which returns the string hash of any other string (i.e. basestring). """ + + baseClass = SOHashCol |
From: SourceForge.net <no...@so...> - 2008-07-17 13:19:30
|
Patches item #2013132, was opened at 2008-07-08 09:08 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2013132&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: Closed >Resolution: Accepted Priority: 5 Private: Yes Submitted By: Nobody/Anonymous (nobody) >Assigned to: Oleg Broytmann (phd) Summary: HashCol type for passwords and the like Initial Comment: This is some fairly simple code for a HashCol, a column type that automatically hashes anything going into it, and returns out an object that hashes anything being compared to itself. Basically, it's great for really simple one-way password fields, and it even supports the assignment of None to indicate no password set. By default, it uses the md5 library for hashing, but this can be changed in a HashCol definition. The attached code could pretty neatly be slotted right into col.py within the source. sam...@gm... ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2008-07-17 17:19 Message: Logged In: YES user_id=4799 Originator: NO Added as sqlobject.include.hascol.HashCol to the trunk. Thank you. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2013132&group_id=74338 |
From: SourceForge.net <no...@so...> - 2008-07-17 13:14:30
|
Patches item #2007233, was opened at 2008-07-01 04:13 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2007233&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: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) >Assigned to: Oleg Broytmann (phd) Summary: More testing for styles Initial Comment: I've written some more tests for the built-in styles, in anticipation of adding customizable ForeignKey naming. In any case, these tests will help guarantee that the naming stays consistent. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2008-07-17 17:14 Message: Logged In: YES user_id=4799 Originator: NO Added to the repository at the revisions 3509-3511 (branches 0.9, 0.10 and the trunk). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2007233&group_id=74338 |
From: <sub...@co...> - 2008-07-17 13:10:42
|
Author: phd Date: 2008-07-17 07:10:35 -0600 (Thu, 17 Jul 2008) New Revision: 3509 Added: SQLObject/branches/0.9/sqlobject/tests/test_default_style.py Modified: SQLObject/branches/0.9/docs/News.txt Log: Added test_default_style.py from the SF patch 2007233. Modified: SQLObject/branches/0.9/docs/News.txt =================================================================== --- SQLObject/branches/0.9/docs/News.txt 2008-07-15 13:22:04 UTC (rev 3508) +++ SQLObject/branches/0.9/docs/News.txt 2008-07-17 13:10:35 UTC (rev 3509) @@ -13,6 +13,8 @@ * Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html +* Added test_default_style.py. + SQLObject 0.9.7 =============== Added: SQLObject/branches/0.9/sqlobject/tests/test_default_style.py =================================================================== --- SQLObject/branches/0.9/sqlobject/tests/test_default_style.py (rev 0) +++ SQLObject/branches/0.9/sqlobject/tests/test_default_style.py 2008-07-17 13:10:35 UTC (rev 3509) @@ -0,0 +1,58 @@ +""" +Test the default styles, to guarantee consistency. +""" + +from sqlobject import * +from sqlobject.tests.dbtest import * +from sqlobject.styles import Style, MixedCaseUnderscoreStyle, MixedCaseStyle + +#hash of styles versus the database names resulting from 'columns' below +columns = ["ABCUpper", "abc_lower", "ABCamelCaseColumn"] +styles = {Style:columns, + MixedCaseUnderscoreStyle:["abc_upper", "abc_lower", "ab_camel_case_column"], + MixedCaseStyle:["ABCUpper", "Abc_lower", "ABCamelCaseColumn"], + } + +#hash of styles versus the database names resulting from a foreign key named 'FKey' +fkey = ForeignKey("DefaultStyleTest", name="FKey") +fkeys = {Style:"FKeyID", + MixedCaseUnderscoreStyle:"f_key_id", + MixedCaseStyle:"FKeyID", + } + + +def make_columns(): + global columns + columns = [] + for col_name in columns: + columns.append(StringCol(name=col_name, length=10)) + + +def do_col_test(DefaultStyleTest, style, dbnames): + DefaultStyleTest.sqlmeta.style = style() + for col, old_dbname in zip(columns, dbnames): + DefaultStyleTest.sqlmeta.addColumn(col) + try: + new_dbname = DefaultStyleTest.sqlmeta.columns[col.name].dbName + assert new_dbname == old_dbname + finally: + if col.name in DefaultStyleTest.sqlmeta.columns: + DefaultStyleTest.sqlmeta.delColumn(col) + +def do_fkey_test(DefaultStyleTest, style, dbname): + DefaultStyleTest.sqlmeta.style = style() + DefaultStyleTest.sqlmeta.addColumn(fkey) + try: + assert DefaultStyleTest.sqlmeta.columns.keys()[0] == "FKeyID" + assert DefaultStyleTest.sqlmeta.columns.values()[0].dbName == dbname + finally: + DefaultStyleTest.sqlmeta.delColumn(fkey) + +class DefaultStyleTest(SQLObject): + pass + +def test_default_styles(): + make_columns() + for style in styles: + yield do_col_test, DefaultStyleTest, style, styles[style] + yield do_fkey_test, DefaultStyleTest, style, fkeys[style] |
From: <sub...@co...> - 2008-07-15 13:22:07
|
Author: dan Date: 2008-07-15 07:22:04 -0600 (Tue, 15 Jul 2008) New Revision: 3508 Modified: SQLObject/branches/0.9/sqlobject/mysql/mysqlconnection.py Log: Fixed inconsistency with error message type when converting from mysql OperationalError to sqlobject OperationalError (backported from trunk) Modified: SQLObject/branches/0.9/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/branches/0.9/sqlobject/mysql/mysqlconnection.py 2008-07-15 13:21:53 UTC (rev 3507) +++ SQLObject/branches/0.9/sqlobject/mysql/mysqlconnection.py 2008-07-15 13:22:04 UTC (rev 3508) @@ -5,8 +5,8 @@ MySQLdb = None class ErrorMessage(str): - def __new__(cls, e): - obj = str.__new__(cls, e[1]) + def __new__(cls, e, append_msg=''): + obj = str.__new__(cls, e[1] + append_msg) obj.code = int(e[0]) obj.module = e.__module__ obj.exception = e.__class__.__name__ @@ -67,10 +67,8 @@ if MySQLdb.version_info[:3] >= (1, 2, 2): conn.ping(True) # Attempt to reconnect. This setting is persistent. except self.module.OperationalError, e: - raise OperationalError( - "%s; used connection string: host=%s, port=%s, db=%s, user=%s, pwd=%s" % ( - e, self.host, self.port, self.db, self.user, self.password) - ) + conninfo = "; used connection string: host=%(host)s, port=%(port)s, db=%(db)s, user=%(user)s" % self.__dict__ + raise OperationalError(ErrorMessage(e, conninfo)) if hasattr(conn, 'autocommit'): conn.autocommit(bool(self.autoCommit)) |
From: <sub...@co...> - 2008-07-15 13:21:54
|
Author: dan Date: 2008-07-15 07:21:53 -0600 (Tue, 15 Jul 2008) New Revision: 3507 Modified: SQLObject/branches/0.10/sqlobject/mysql/mysqlconnection.py Log: Fixed inconsistency with error message type when converting from mysql OperationalError to sqlobject OperationalError (backported from trunk) Modified: SQLObject/branches/0.10/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/branches/0.10/sqlobject/mysql/mysqlconnection.py 2008-07-15 13:21:27 UTC (rev 3506) +++ SQLObject/branches/0.10/sqlobject/mysql/mysqlconnection.py 2008-07-15 13:21:53 UTC (rev 3507) @@ -5,8 +5,8 @@ MySQLdb = None class ErrorMessage(str): - def __new__(cls, e): - obj = str.__new__(cls, e[1]) + def __new__(cls, e, append_msg=''): + obj = str.__new__(cls, e[1] + append_msg) obj.code = int(e[0]) obj.module = e.__module__ obj.exception = e.__class__.__name__ @@ -72,10 +72,8 @@ if MySQLdb.version_info[:3] >= (1, 2, 2): conn.ping(True) # Attempt to reconnect. This setting is persistent. except self.module.OperationalError, e: - raise OperationalError( - "%s; used connection string: host=%s, port=%s, db=%s, user=%s, pwd=%s" % ( - e, self.host, self.port, self.db, self.user, self.password) - ) + conninfo = "; used connection string: host=%(host)s, port=%(port)s, db=%(db)s, user=%(user)s" % self.__dict__ + raise OperationalError(ErrorMessage(e, conninfo)) if hasattr(conn, 'autocommit'): conn.autocommit(bool(self.autoCommit)) |
From: <sub...@co...> - 2008-07-15 13:21:32
|
Author: dan Date: 2008-07-15 07:21:27 -0600 (Tue, 15 Jul 2008) New Revision: 3506 Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py Log: Fixed inconsistency with error message type when converting from mysql OperationalError to sqlobject OperationalError Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2008-07-14 11:59:41 UTC (rev 3505) +++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2008-07-15 13:21:27 UTC (rev 3506) @@ -5,8 +5,8 @@ MySQLdb = None class ErrorMessage(str): - def __new__(cls, e): - obj = str.__new__(cls, e[1]) + def __new__(cls, e, append_msg=''): + obj = str.__new__(cls, e[1] + append_msg) obj.code = int(e[0]) obj.module = e.__module__ obj.exception = e.__class__.__name__ @@ -72,10 +72,8 @@ if MySQLdb.version_info[:3] >= (1, 2, 2): conn.ping(True) # Attempt to reconnect. This setting is persistent. except self.module.OperationalError, e: - raise OperationalError( - "%s; used connection string: host=%s, port=%s, db=%s, user=%s, pwd=%s" % ( - e, self.host, self.port, self.db, self.user, self.password) - ) + conninfo = "; used connection string: host=%(host)s, port=%(port)s, db=%(db)s, user=%(user)s" % self.__dict__ + raise OperationalError(ErrorMessage(e, conninfo)) if hasattr(conn, 'autocommit'): conn.autocommit(bool(self.autoCommit)) |
From: <sub...@co...> - 2008-07-14 11:59:45
|
Author: phd Date: 2008-07-14 05:59:41 -0600 (Mon, 14 Jul 2008) New Revision: 3505 Modified: SQLObject/trunk/docs/SQLObject.txt Log: DecimalStringColumn cannot be used in expressions and ordering. Modified: SQLObject/trunk/docs/SQLObject.txt =================================================================== --- SQLObject/trunk/docs/SQLObject.txt 2008-07-11 16:37:56 UTC (rev 3504) +++ SQLObject/trunk/docs/SQLObject.txt 2008-07-14 11:59:41 UTC (rev 3505) @@ -1137,7 +1137,9 @@ `DecimalStringCol`: Similar to `DecimalCol` but stores data as strings to work around - problems in some drivers and type affinity problem in SQLite. + problems in some drivers and type affinity problem in SQLite. As it + stores data as strings the column cannot be used in SQL expressions + (column1 + column2) and probably will has problems with ORDER BY. `EnumCol`: One of several string values -- give the possible strings as a |
From: <sub...@co...> - 2008-07-11 16:37:59
|
Author: phd Date: 2008-07-11 10:37:56 -0600 (Fri, 11 Jul 2008) New Revision: 3504 Modified: SQLObject/trunk/docs/Authors.txt SQLObject/trunk/sqlobject/col.py SQLObject/trunk/sqlobject/tests/test_decimal.py Log: DecimalStringValidator now supports quantization, thanks to Christopher Singley <csingley at gmail.com>. Modified: SQLObject/trunk/docs/Authors.txt =================================================================== --- SQLObject/trunk/docs/Authors.txt 2008-07-11 15:29:51 UTC (rev 3503) +++ SQLObject/trunk/docs/Authors.txt 2008-07-11 16:37:56 UTC (rev 3504) @@ -21,6 +21,7 @@ * David Turner, The Open Planning Project * Dan Pascu <dan at ag-projects.com> * Diez B. Roggisch <deets at web.de> +* Christopher Singley <csingley at gmail.com> * Oleg Broytmann <ph...@ph...> .. image:: http://sourceforge.net/sflogo.php?group_id=74338&type=4 Modified: SQLObject/trunk/sqlobject/col.py =================================================================== --- SQLObject/trunk/sqlobject/col.py 2008-07-11 15:29:51 UTC (rev 3503) +++ SQLObject/trunk/sqlobject/col.py 2008-07-11 16:37:56 UTC (rev 3504) @@ -1347,38 +1347,48 @@ class DecimalStringValidator(DecimalValidator): + def to_python(self, value, state): + value = super(DecimalStringValidator, self).to_python(value, state) + if self.precision and isinstance(value, Decimal): + assert value < self.max, \ + "Value must be less than %s" % int(self.max) + value = value.quantize(self.precision) + return value + def from_python(self, value, state): - if value is None: - return None - if isinstance(value, sqlbuilder.SQLExpression): - return value - if not isinstance(value, basestring): + value = super(DecimalStringValidator, self).from_python(value, state) + if isinstance(value, Decimal): + if self.precision: + assert value < self.max, \ + "Value must be less than %s" % int(self.max) + value = value.quantize(self.precision) + value = value.to_eng_string() + elif isinstance(value, (int, long)): value = str(value) - connection = state.soObject._connection - if hasattr(connection, "decimalSeparator"): - value = value.replace(connection.decimalSeparator, ".") - try: - Decimal(value) # Test if the value is valid - except: - raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol from '%s'" % - (value, getattr(state, 'soObject', '(unknown)')), value, state) - else: - return value + return value class SODecimalStringCol(SOStringCol): def __init__(self, **kw): - size = kw.pop('size', NoDefault) - assert size is not NoDefault, \ - "You must give a size argument" - precision = kw.pop('precision', NoDefault) - assert precision is not NoDefault, \ - "You must give a precision argument" - kw['length'] = size + precision + self.size = kw.pop('size', NoDefault) + assert (self.size is not NoDefault) and (self.size >= 0), \ + "You must give a size argument as a positive integer" + self.precision = kw.pop('precision', NoDefault) + assert (self.precision is not NoDefault) and (self.precision >= 0), \ + "You must give a precision argument as a positive integer" + kw['length'] = int(self.size) + int(self.precision) + self.quantize = kw.pop('quantize', False) + assert isinstance(self.quantize, bool), \ + "quantize argument must be Boolean True/False" super(SODecimalStringCol, self).__init__(**kw) def createValidators(self): - return [DecimalStringValidator()] + \ - super(SODecimalStringCol, self).createValidators() + if self.quantize: + v = DecimalStringValidator( + precision=Decimal(10) ** (-1 * int(self.precision)), + max=Decimal(10) ** (int(self.size) - int(self.precision))) + else: + v = DecimalStringValidator(precision=0) + return [v] + super(SODecimalStringCol, self).createValidators() class DecimalStringCol(StringCol): baseClass = SODecimalStringCol Modified: SQLObject/trunk/sqlobject/tests/test_decimal.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 15:29:51 UTC (rev 3503) +++ SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 16:37:56 UTC (rev 3504) @@ -11,27 +11,52 @@ class DecimalTable(SQLObject): name = UnicodeCol(length=255) col1 = DecimalCol(size=6, precision=4) + col2 = DecimalStringCol(size=6, precision=4) + col3 = DecimalStringCol(size=6, precision=4, quantize=True) if supports('decimalColumn'): def test_1_decimal(): setupClass(DecimalTable) - d = DecimalTable(name='test', col1=21.12) + d = DecimalTable(name='test', col1=21.12, col2='10.01', col3='10.01') # psycopg2 returns float as Decimal if isinstance(d.col1, Decimal): assert d.col1 == Decimal("21.12") else: assert d.col1 == 21.12 + assert d.col2 == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col2'].to_python('10.01', + d._SO_validatorState) == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col2'].from_python('10.01', + d._SO_validatorState) == "10.01" + assert d.col3 == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col3'].to_python('10.01', + d._SO_validatorState) == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col3'].from_python('10.01', + d._SO_validatorState) == "10.0100" def test_2_decimal(): setupClass(DecimalTable) - d = DecimalTable(name='test', col1=Decimal("21.12")) + d = DecimalTable(name='test', col1=Decimal("21.12"), + col2=Decimal('10.01'), col3=Decimal('10.01')) assert d.col1 == Decimal("21.12") + assert d.col2 == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col2'].to_python(Decimal('10.01'), + d._SO_validatorState) == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col2'].from_python(Decimal('10.01'), + d._SO_validatorState) == "10.01" + assert d.col3 == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col3'].to_python(Decimal('10.01'), + d._SO_validatorState) == Decimal("10.01") + assert DecimalTable.sqlmeta.columns['col3'].from_python(Decimal('10.01'), + d._SO_validatorState) == "10.0100" # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html if isinstance(Decimal(u'123').to_eng_string(), unicode): # a bug in Python 2.5.2 def test_3_unicode(): setupClass(DecimalTable) - d = DecimalTable(name='test', col1=Decimal(u"21.12")) + d = DecimalTable(name='test', col1=Decimal(u"21.12"), + col2='10.01', col3='10.01') assert d.col1 == Decimal("21.12") - d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12")) + d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12"), + col2='10.01', col3='10.01') assert d.col1 == Decimal("21.12") |
From: <sub...@co...> - 2008-07-11 15:29:55
|
Author: phd Date: 2008-07-11 09:29:51 -0600 (Fri, 11 Jul 2008) New Revision: 3503 Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/converters.py SQLObject/trunk/sqlobject/tests/test_decimal.py Log: Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2008-07-11 15:15:54 UTC (rev 3502) +++ SQLObject/trunk/docs/News.txt 2008-07-11 15:29:51 UTC (rev 3503) @@ -33,6 +33,11 @@ * DecimalStringCol - similar to DecimalCol but stores data as strings to work around problems in some drivers and type affinity problem in SQLite. +SQLObject 0.10.3 +================ + +* A number of changes ported from `SQLObject 0.9.8`_. + SQLObject 0.10.2 ================ @@ -119,6 +124,12 @@ * Under MySQL, PickleCol no longer used TEXT column types; the smallest column is now BLOB - it is not possible to create TINYBLOB column. +SQLObject 0.9.8 +=============== + +* Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; + see http://mail.python.org/pipermail/python-dev/2008-March/078189.html + SQLObject 0.9.7 =============== Modified: SQLObject/trunk/sqlobject/converters.py =================================================================== --- SQLObject/trunk/sqlobject/converters.py 2008-07-11 15:15:54 UTC (rev 3502) +++ SQLObject/trunk/sqlobject/converters.py 2008-07-11 15:29:51 UTC (rev 3503) @@ -180,7 +180,8 @@ registerConverter(datetime.time, TimeConverter) def DecimalConverter(value, db): - return value.to_eng_string() + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + return str(value.to_eng_string()) # Convert to str to work around a bug in Python 2.5.2 registerConverter(Decimal, DecimalConverter) Modified: SQLObject/trunk/sqlobject/tests/test_decimal.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 15:15:54 UTC (rev 3502) +++ SQLObject/trunk/sqlobject/tests/test_decimal.py 2008-07-11 15:29:51 UTC (rev 3503) @@ -1,3 +1,5 @@ +# -*- coding: koi8-r -*- + from decimal import Decimal from sqlobject import * from sqlobject.tests.dbtest import * @@ -7,25 +9,29 @@ ######################################## class DecimalTable(SQLObject): + name = UnicodeCol(length=255) col1 = DecimalCol(size=6, precision=4) - col2 = DecimalStringCol(size=6, precision=4) if supports('decimalColumn'): def test_1_decimal(): setupClass(DecimalTable) - d = DecimalTable(col1=21.12, col2='10.01') + d = DecimalTable(name='test', col1=21.12) # psycopg2 returns float as Decimal if isinstance(d.col1, Decimal): assert d.col1 == Decimal("21.12") else: assert d.col1 == 21.12 - assert d.col2 == Decimal("10.01") def test_2_decimal(): setupClass(DecimalTable) - d = DecimalTable(col1=Decimal("21.12"), col2=Decimal('10.01')) - if isinstance(d.col1, Decimal): + d = DecimalTable(name='test', col1=Decimal("21.12")) + assert d.col1 == Decimal("21.12") + + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + if isinstance(Decimal(u'123').to_eng_string(), unicode): # a bug in Python 2.5.2 + def test_3_unicode(): + setupClass(DecimalTable) + d = DecimalTable(name='test', col1=Decimal(u"21.12")) assert d.col1 == Decimal("21.12") - else: - assert d.col1 == 21.12 - assert d.col2 == Decimal("10.01") + d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12")) + assert d.col1 == Decimal("21.12") |
From: <sub...@co...> - 2008-07-11 15:15:58
|
Author: phd Date: 2008-07-11 09:15:54 -0600 (Fri, 11 Jul 2008) New Revision: 3502 Modified: SQLObject/branches/0.10/docs/News.txt SQLObject/branches/0.10/sqlobject/converters.py SQLObject/branches/0.10/sqlobject/tests/test_decimal.py Log: Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html Modified: SQLObject/branches/0.10/docs/News.txt =================================================================== --- SQLObject/branches/0.10/docs/News.txt 2008-07-11 15:11:29 UTC (rev 3501) +++ SQLObject/branches/0.10/docs/News.txt 2008-07-11 15:15:54 UTC (rev 3502) @@ -7,6 +7,11 @@ .. _start: +SQLObject 0.10.3 +================ + +* A number of changes ported from `SQLObject 0.9.8`_. + SQLObject 0.10.2 ================ @@ -93,6 +98,12 @@ * Under MySQL, PickleCol no longer uses TEXT column types; the smallest column is now BLOB - it is not possible to create TINYBLOB column. +SQLObject 0.9.8 +=============== + +* Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; + see http://mail.python.org/pipermail/python-dev/2008-March/078189.html + SQLObject 0.9.7 =============== Modified: SQLObject/branches/0.10/sqlobject/converters.py =================================================================== --- SQLObject/branches/0.10/sqlobject/converters.py 2008-07-11 15:11:29 UTC (rev 3501) +++ SQLObject/branches/0.10/sqlobject/converters.py 2008-07-11 15:15:54 UTC (rev 3502) @@ -194,7 +194,8 @@ if Decimal: def DecimalConverter(value, db): - return value.to_eng_string() + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + return str(value.to_eng_string()) # Convert to str to work around a bug in Python 2.5.2 registerConverter(Decimal, DecimalConverter) Modified: SQLObject/branches/0.10/sqlobject/tests/test_decimal.py =================================================================== --- SQLObject/branches/0.10/sqlobject/tests/test_decimal.py 2008-07-11 15:11:29 UTC (rev 3501) +++ SQLObject/branches/0.10/sqlobject/tests/test_decimal.py 2008-07-11 15:15:54 UTC (rev 3502) @@ -1,3 +1,5 @@ +# -*- coding: koi8-r -*- + from sqlobject import * from sqlobject.tests.dbtest import * @@ -11,13 +13,14 @@ ######################################## class DecimalTable(SQLObject): + name = UnicodeCol(length=255) col1 = DecimalCol(size=6, precision=4) if supports('decimalColumn'): def test_1_decimal(): """Tests new instance with a float in col1.""" setupClass(DecimalTable) - d = DecimalTable(col1=21.12) + d = DecimalTable(name='test', col1=21.12) if Decimal: assert d.col1 == Decimal("21.12") else: @@ -27,5 +30,14 @@ def test_2_decimal(): """Tests new instance with a Decimal in col1.""" setupClass(DecimalTable) - d = DecimalTable(col1=Decimal("21.12")) + d = DecimalTable(name='test', col1=Decimal("21.12")) assert d.col1 == Decimal("21.12") + + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + if isinstance(Decimal(u'123').to_eng_string(), unicode): # a bug in Python 2.5.2 + def test_3_unicode(): + setupClass(DecimalTable) + d = DecimalTable(name='test', col1=Decimal(u"21.12")) + assert d.col1 == Decimal("21.12") + d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12")) + assert d.col1 == Decimal("21.12") |
From: <sub...@co...> - 2008-07-11 15:11:33
|
Author: phd Date: 2008-07-11 09:11:29 -0600 (Fri, 11 Jul 2008) New Revision: 3501 Modified: SQLObject/branches/0.9/docs/News.txt SQLObject/branches/0.9/sqlobject/converters.py SQLObject/branches/0.9/sqlobject/tests/test_decimal.py Log: Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html Modified: SQLObject/branches/0.9/docs/News.txt =================================================================== --- SQLObject/branches/0.9/docs/News.txt 2008-07-04 04:47:17 UTC (rev 3500) +++ SQLObject/branches/0.9/docs/News.txt 2008-07-11 15:11:29 UTC (rev 3501) @@ -7,6 +7,12 @@ .. _start: +SQLObject 0.9.8 +=============== + +* Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; + see http://mail.python.org/pipermail/python-dev/2008-March/078189.html + SQLObject 0.9.7 =============== Modified: SQLObject/branches/0.9/sqlobject/converters.py =================================================================== --- SQLObject/branches/0.9/sqlobject/converters.py 2008-07-04 04:47:17 UTC (rev 3500) +++ SQLObject/branches/0.9/sqlobject/converters.py 2008-07-11 15:11:29 UTC (rev 3501) @@ -222,7 +222,8 @@ if Decimal: def DecimalConverter(value, db): - return value.to_eng_string() + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + return str(value.to_eng_string()) # Convert to str to work around a bug in Python 2.5.2 registerConverter(Decimal, DecimalConverter) Modified: SQLObject/branches/0.9/sqlobject/tests/test_decimal.py =================================================================== --- SQLObject/branches/0.9/sqlobject/tests/test_decimal.py 2008-07-04 04:47:17 UTC (rev 3500) +++ SQLObject/branches/0.9/sqlobject/tests/test_decimal.py 2008-07-11 15:11:29 UTC (rev 3501) @@ -1,3 +1,5 @@ +# -*- coding: koi8-r -*- + from sqlobject import * from sqlobject.tests.dbtest import * @@ -11,13 +13,14 @@ ######################################## class DecimalTable(SQLObject): + name = UnicodeCol(length=255) col1 = DecimalCol(size=6, precision=4) if supports('decimalColumn'): def test_1_decimal(): """Tests new instance with a float in col1.""" setupClass(DecimalTable) - d = DecimalTable(col1=21.12) + d = DecimalTable(name='test', col1=21.12) if Decimal: assert d.col1 == Decimal("21.12") else: @@ -27,5 +30,14 @@ def test_2_decimal(): """Tests new instance with a Decimal in col1.""" setupClass(DecimalTable) - d = DecimalTable(col1=Decimal("21.12")) + d = DecimalTable(name='test', col1=Decimal("21.12")) assert d.col1 == Decimal("21.12") + + # See http://mail.python.org/pipermail/python-dev/2008-March/078189.html + if isinstance(Decimal(u'123').to_eng_string(), unicode): # a bug in Python 2.5.2 + def test_3_unicode(): + setupClass(DecimalTable) + d = DecimalTable(name='test', col1=Decimal(u"21.12")) + assert d.col1 == Decimal("21.12") + d = DecimalTable(name=unicode('', 'koi8-r'), col1=Decimal(u"21.12")) + assert d.col1 == Decimal("21.12") |