sqlobject-cvs Mailing List for SQLObject (Page 143)
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-01-16 17:32:30
|
Author: phd
Date: 2006-01-16 10:32:21 -0700 (Mon, 16 Jan 2006)
New Revision: 1517
Modified:
home/phd/SQLObject/paramstyles/sqlobject/joins.py
Log:
Merged patches from the revisions 1513:1516 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/joins.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/joins.py 2006-01-16 17:31:06 UTC (rev 1516)
+++ home/phd/SQLObject/paramstyles/sqlobject/joins.py 2006-01-16 17:32:21 UTC (rev 1517)
@@ -99,11 +99,22 @@
# @@: but we don't handle more complex expressions for orderings
if orderBy.startswith('-'):
orderBy = orderBy[1:]
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(b, attr), getattr(a, attr))
+ reverse = True
else:
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(a, attr), getattr(b, attr))
+ reverse = False
+
+ def cmper(a, b, attr=orderBy, rev=reverse):
+ a = getattr(a, attr)
+ b = getattr(b, attr)
+ if rev:
+ a, b = b, a
+ if a is None:
+ if b is None:
+ return 0
+ return -1
+ if b is None:
+ return 1
+ return cmp(a, b)
return cmper
# This is a one-to-many
|
|
From: <sub...@co...> - 2006-01-16 17:31:19
|
Author: phd
Date: 2006-01-16 10:31:06 -0700 (Mon, 16 Jan 2006)
New Revision: 1516
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/joins.py
Log:
Merged a patch by Jan-Wijbrand Kolman <jw...@in...> for ordering joins with NULLs.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/joins.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2006-01-16 17:29:59 UTC (rev 1515)
+++ SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2006-01-16 17:31:06 UTC (rev 1516)
@@ -97,11 +97,22 @@
# @@: but we don't handle more complex expressions for orderings
if orderBy.startswith('-'):
orderBy = orderBy[1:]
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(b, attr), getattr(a, attr))
+ reverse = True
else:
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(a, attr), getattr(b, attr))
+ reverse = False
+
+ def cmper(a, b, attr=orderBy, rev=reverse):
+ a = getattr(a, attr)
+ b = getattr(b, attr)
+ if rev:
+ a, b = b, a
+ if a is None:
+ if b is None:
+ return 0
+ return -1
+ if b is None:
+ return 1
+ return cmp(a, b)
return cmper
# This is a one-to-many
|
|
From: <sub...@co...> - 2006-01-16 17:30:30
|
Author: phd
Date: 2006-01-16 10:29:59 -0700 (Mon, 16 Jan 2006)
New Revision: 1515
Modified:
SQLObject/trunk/sqlobject/joins.py
Log:
A patch by Jan-Wijbrand Kolman <jw...@in...> for ordering joins with NULLs.
Modified: SQLObject/trunk/sqlobject/joins.py
===================================================================
--- SQLObject/trunk/sqlobject/joins.py 2006-01-16 16:58:58 UTC (rev 1514)
+++ SQLObject/trunk/sqlobject/joins.py 2006-01-16 17:29:59 UTC (rev 1515)
@@ -99,11 +99,22 @@
# @@: but we don't handle more complex expressions for orderings
if orderBy.startswith('-'):
orderBy = orderBy[1:]
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(b, attr), getattr(a, attr))
+ reverse = True
else:
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(a, attr), getattr(b, attr))
+ reverse = False
+
+ def cmper(a, b, attr=orderBy, rev=reverse):
+ a = getattr(a, attr)
+ b = getattr(b, attr)
+ if rev:
+ a, b = b, a
+ if a is None:
+ if b is None:
+ return 0
+ return -1
+ if b is None:
+ return 1
+ return cmp(a, b)
return cmper
# This is a one-to-many
|
|
From: <sub...@co...> - 2006-01-16 07:54:59
|
Author: ianb Date: 2006-01-16 00:54:49 -0700 (Mon, 16 Jan 2006) New Revision: 1513 Modified: SQLObject/docs/index.comments.txt Log: Web updates Modified: SQLObject/docs/index.comments.txt =================================================================== --- SQLObject/docs/index.comments.txt 2006-01-16 06:06:06 UTC (rev 1512) +++ SQLObject/docs/index.comments.txt 2006-01-16 07:54:49 UTC (rev 1513) @@ -1,7 +0,0 @@ -==== $(example) c ----------------------------------------- -date: 2006-01-08T06:10:41 -id: 1 -ip: 221.221.32.12 - -Hmm does not work?? |
|
From: <sub...@co...> - 2006-01-14 01:41:02
|
Author: ianb Date: 2006-01-13 18:40:51 -0700 (Fri, 13 Jan 2006) New Revision: 1506 Modified: SQLObject/docs/index.comments.txt Log: Web updates Modified: SQLObject/docs/index.comments.txt =================================================================== --- SQLObject/docs/index.comments.txt 2006-01-13 09:29:03 UTC (rev 1505) +++ SQLObject/docs/index.comments.txt 2006-01-14 01:40:51 UTC (rev 1506) @@ -4,4 +4,4 @@ id: 1 ip: 221.221.32.12 -cool! +Hmm does not work?? |
|
From: <sub...@co...> - 2006-01-13 09:38:39
|
Author: phd Date: 2006-01-13 02:28:39 -0700 (Fri, 13 Jan 2006) New Revision: 1504 Modified: SQLObject/docs/FAQ.txt Log: Added FAQ about __len__; copied Andrew Bennetts' answer verbatim from http://sourceforge.net/mailarchive/forum.php?thread_id=9455066&forum_id=30269. Modified: SQLObject/docs/FAQ.txt =================================================================== --- SQLObject/docs/FAQ.txt 2006-01-13 09:19:24 UTC (rev 1503) +++ SQLObject/docs/FAQ.txt 2006-01-13 09:28:39 UTC (rev 1504) @@ -4,6 +4,25 @@ .. contents:: +Why there is no __len__? +------------------------ + +There are reasons why there is no __len__ method, though many people think +having those make them feel more integrated into Python. + +One is that len(foo) is expected to be fast, but issuing a COUNT query can +be slow. Worse, often this causes the database to do essentially redundant +work when the actual query is performed (generally taking the len of a +sequence is followed by accessing items from that sequence). + +Another is that list(foo) implicitly tries to do a len first, as an +optimization (because len is expected to be cheap -- see previous point). +Worse, it swallows *all* exceptions that occur during that call to __len__, +so if it fails (e.g. there's a typo somewhere in the query), the original +cause is silently discarded, and instead you're left with mysterious errors +like "current transaction is aborted, commands ignored until end of +transaction block" for no apparent reason. + How can I do a LEFT JOIN? ------------------------- |
|
From: <sub...@co...> - 2006-01-13 09:38:26
|
Author: phd
Date: 2006-01-13 02:19:24 -0700 (Fri, 13 Jan 2006)
New Revision: 1503
Added:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py
home/phd/SQLObject/paramstyles/sqlobject/wsgi_middleware.py
Modified:
home/phd/SQLObject/paramstyles/setup.py
home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py
Log:
Merged patches from the revisions 1500:1502 from the trunk
Modified: home/phd/SQLObject/paramstyles/setup.py
===================================================================
--- home/phd/SQLObject/paramstyles/setup.py 2006-01-13 09:18:48 UTC (rev 1502)
+++ home/phd/SQLObject/paramstyles/setup.py 2006-01-13 09:19:24 UTC (rev 1503)
@@ -4,8 +4,10 @@
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup
+ is_setuptools = True
except ImportError:
from distutils.core import setup
+ is_setuptools = False
subpackages = ['firebird', 'include', 'include.pydispatch', 'inheritance',
'manager', 'maxdb', 'mssql', 'mysql', 'postgres', 'sqlite',
@@ -18,6 +20,13 @@
DistributionMetadata.classifiers = None
DistributionMetadata.download_url = None
+kw = {}
+if is_setuptools:
+ kw['entry_points'] = """
+ [paste.filter_app_factory]
+ main = sqlobject.wsgi_middleware:make_middleware
+ """
+
setup(name="SQLObject",
version="0.8",
description="Object-Relational Manager, aka database wrapper",
@@ -58,6 +67,7 @@
'sqlite': ['pysqlite'],
# Others?
},
+ **kw
)
# Send announce to:
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py 2006-01-13 09:18:48 UTC (rev 1502)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py 2006-01-13 09:19:24 UTC (rev 1503)
@@ -84,9 +84,7 @@
'sqlite:///' + installedDBFilename)
def getConnection(**kw):
- name = conftest.option.Database
- if conftest.connectionShortcuts.has_key(name):
- name = conftest.connectionShortcuts[name]
+ name = getConnectionURI()
conn = sqlobject.connectionForURI(name, **kw)
if conftest.option.show_sql:
conn.debug = True
@@ -94,6 +92,12 @@
conn.debugOutput = True
return conn
+def getConnectionURI():
+ name = conftest.option.Database
+ if conftest.connectionShortcuts.has_key(name):
+ name = conftest.connectionShortcuts[name]
+ return name
+
try:
connection = getConnection()
except Exception, e:
@@ -291,6 +295,6 @@
sqlobject.main.warnings_level = None
sqlobject.main.exception_level = 0
-__all__ = ['getConnection', 'setupClass', 'Dummy', 'raises',
+__all__ = ['getConnection', 'getConnectionURI', 'setupClass', 'Dummy', 'raises',
'd', 'inserts', 'supports', 'deprecated_module',
'setup_module', 'teardown_module']
Copied: home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py (from rev 1501, SQLObject/trunk/sqlobject/tests/test_paste.py)
Property changes on: home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: home/phd/SQLObject/paramstyles/sqlobject/wsgi_middleware.py (from rev 1501, SQLObject/trunk/sqlobject/wsgi_middleware.py)
Property changes on: home/phd/SQLObject/paramstyles/sqlobject/wsgi_middleware.py
___________________________________________________________________
Name: svn:eol-style
+ native
|
|
From: <sub...@co...> - 2006-01-13 09:38:05
|
Author: phd Date: 2006-01-13 02:18:48 -0700 (Fri, 13 Jan 2006) New Revision: 1502 Modified: SQLObject/trunk/setup.py Log: Removed trailing spaces. Modified: SQLObject/trunk/setup.py =================================================================== --- SQLObject/trunk/setup.py 2006-01-13 07:20:19 UTC (rev 1501) +++ SQLObject/trunk/setup.py 2006-01-13 09:18:48 UTC (rev 1502) @@ -117,4 +117,3 @@ -- Ian Bicking / ia...@co... / http://blog.ianbicking.org """ - |
|
From: <sub...@co...> - 2006-01-13 09:38:03
|
Author: phd
Date: 2006-01-13 02:29:03 -0700 (Fri, 13 Jan 2006)
New Revision: 1505
Modified:
SQLObject/docs/SQLObject.txt
Log:
Fixed reST formatting.
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-01-13 09:28:39 UTC (rev 1504)
+++ SQLObject/docs/SQLObject.txt 2006-01-13 09:29:03 UTC (rev 1505)
@@ -412,7 +412,7 @@
<Address 1 ...>
>>> p.addresses
[<Address 1 ...>]
-
+
.. note::
MultipleJoin, as well as RelatedJoin, returns a list of results.
Would you prefer to get a SelectResults objects, you should use
@@ -483,7 +483,7 @@
methods add/removesomething may not work as expected. Assuming that
you are providing the join with the correct joinColumn and otherColumn
arguments, be aware it's not possibile to insert extra data via such
-methodos, nor will they set any default value.
+methodos, nor will they set any default value.
Let's have an example: in the previous User/Role system,
you're creating a UserRole intermediate table, with the two columns
@@ -661,8 +661,8 @@
`table`:
The name of the table in the database. This is derived from
- ``style`` and the class name if no explicit name is given. If you
- don't give a name and haven't defined an alternative ``style``, then
+ ``style`` and the class name if no explicit name is given. If you
+ don't give a name and haven't defined an alternative ``style``, then
the standard `MixedCase` to `mixed_case` translation is performed.
`idName`:
@@ -675,10 +675,10 @@
is ``int`` by default (all IDs are normalized to integers).
`style`:
- A style object -- this object allows you to use other algorithms
+ A style object -- this object allows you to use other algorithms
for translating between Python attribute and class names, and the
database's column and table names. See `Changing the Naming
- Style`_ for more. It is an instance of the `IStyle` interface.
+ Style`_ for more. It is an instance of the `IStyle` interface.
`lazyUpdate`:
A boolean (default false). If true, then setting attributes on
@@ -700,9 +700,9 @@
If set to `False` then values for attributes from the database
won't be cached. So every time you access an attribute in the
object the database will be queried for a value, i.e., a ``SELECT``
- will be issued. If you want to handle concurrent access to the
- database from multiple processes then this is probably the way to
- do so. You should also use it with transactions_ (it is not
+ will be issued. If you want to handle concurrent access to the
+ database from multiple processes then this is probably the way to
+ do so. You should also use it with transactions_ (it is not
implied).
`registry`:
@@ -742,10 +742,10 @@
attributes are accessed a query will be run.
-While in previous versions of SQLObject those attributes were defined
+While in previous versions of SQLObject those attributes were defined
directly at the class that will map your database data to Python and
all of them were prefixed with an underscore, now it is suggested that
-you change your code to this new style. The old way will be removed
+you change your code to this new style. The old way will be removed
when SQLObject 0.8 is out and you'll receive lots of warning messages
saying that if you're not using the ``sqlmeta`` class you're doing things
in a deprecated way.
@@ -788,11 +788,11 @@
SQLObject Class
---------------
-Besides sqlmeta and columns specifications, there are a number of other
+Besides sqlmeta and columns specifications, there are a number of other
special attributes you can set in your class. Those are listed below but,
except for the ``_connection`` attribute, all other are superseded by the
implementation shown before with sqlmeta. If you use them with SQLObject
-0.7 you'll get warnings about their deprecation and you'll probably have
+0.7 you'll get warnings about their deprecation and you'll probably have
to convert your code in future releases, when these are dropped.
`_connection`:
@@ -816,7 +816,7 @@
from sqlmeta class.
`_cacheValues`:
- This is old style and works the same way as the `cacheValues`
+ This is old style and works the same way as the `cacheValues`
attribute from sqlmeta class.
.. _idName:
@@ -978,7 +978,7 @@
Undefined attributes
~~~~~~~~~~~~~~~~~~~~
-There's one more thing worth telling, because you may something get
+There's one more thing worth telling, because you may something get
strange results when making a typo. SQLObject won't ever complain or
raise any error when setting a previously undefined attribute; it will
simply set it, without making any change to the database, i.e: it will
@@ -1080,12 +1080,12 @@
Base-10, precise number. Uses the keyword arguments `size` for
number of digits stored, and `precision` for the number of digits
after the decimal point.
- WARNING: it may happen that DecimalCol values, although correctly
- stored in the DB, are returned as floats instead of decimals.
- You should test with your database adapter, and you should try
- importing the Decimal type and your DB adapter before importing
- SQLObject.
-
+ WARNING: it may happen that DecimalCol values, although correctly
+ stored in the DB, are returned as floats instead of decimals.
+ You should test with your database adapter, and you should try
+ importing the Decimal type and your DB adapter before importing
+ SQLObject.
+
`EnumCol`:
One of several string values -- give the possible strings as a
list, with the `enumValues` keyword argument. MySQL has a native
@@ -1158,7 +1158,7 @@
into 'product_no_id' in the DB ( product_no is the normal uppercase-
to-lowercase + underscores SQLO Translation, the added _id is just
because the column referring to the table is probably a ForeignKey,
- and SQLO translates foreign keys that way).
+ and SQLO translates foreign keys that way).
You should pass that parameter.
`orderBy`:
Like the `orderBy`_ argument to `select()`, you can specify
@@ -1195,20 +1195,20 @@
`removeRole(role)` are created. The ``Role`` portion of these
method names can be changed by giving a string value here.
`createRelatedTable`:
- default: ``True``. If ``False``, then the related table won't be
- automatically created; instead you must manually create it (e.g.,
- with explicit SQLObject classes for the joins). New in 0.7.1.
+ default: ``True``. If ``False``, then the related table won't be
+ automatically created; instead you must manually create it (e.g.,
+ with explicit SQLObject classes for the joins). New in 0.7.1.
.. note::
- Let's suppose you have SQLObject-inherited classes Alpha and Beta,
- and an AlphasAndBetas used for the many-to-many relationship.
+ Let's suppose you have SQLObject-inherited classes Alpha and Beta,
+ and an AlphasAndBetas used for the many-to-many relationship.
AlphasAndBetas contains the alphaIndex Foreign Key column referring
to Alpha, and the betaIndex FK column referring to Beta.
if you want a 'betas' RelatedJoin in Alpha, you should add it to
Alpha passing 'Beta' (class name!) as the first parameter, then
- passing 'alpha_index_id' as joinColumn, 'beta_index_id' as
+ passing 'alpha_index_id' as joinColumn, 'beta_index_id' as
otherColumn, and 'alphas_and_betas' as intermediateTable.
-
+
__ `Many-to-Many Relationships`_
An example schema that requires the use of `joinColumn`, `otherColumn`,
|
|
From: <sub...@co...> - 2006-01-13 07:20:31
|
Author: ianb
Date: 2006-01-13 00:20:19 -0700 (Fri, 13 Jan 2006)
New Revision: 1501
Added:
SQLObject/trunk/sqlobject/tests/test_paste.py
SQLObject/trunk/sqlobject/wsgi_middleware.py
Modified:
SQLObject/docs/News.txt
SQLObject/trunk/setup.py
SQLObject/trunk/sqlobject/tests/dbtest.py
Log:
Added WSGI middleware for configuring connections and running request in transaction
Modified: SQLObject/docs/News.txt
===================================================================
--- SQLObject/docs/News.txt 2006-01-12 16:50:35 UTC (rev 1500)
+++ SQLObject/docs/News.txt 2006-01-13 07:20:19 UTC (rev 1501)
@@ -50,6 +50,11 @@
results are found (more than one result is always an error). If no
default is given, it is an error if no such object exists.
+* Added a WSGI middleware (in ``sqlobject.wsgi_middleware``) for
+ configuring the database for the request. Also handles
+ transactions. Available as ``egg:SQLObject`` in Paste Deploy
+ configuration files.
+
SQLObject 0.7.1
===============
Modified: SQLObject/trunk/setup.py
===================================================================
--- SQLObject/trunk/setup.py 2006-01-12 16:50:35 UTC (rev 1500)
+++ SQLObject/trunk/setup.py 2006-01-13 07:20:19 UTC (rev 1501)
@@ -4,8 +4,10 @@
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup
+ is_setuptools = True
except ImportError:
from distutils.core import setup
+ is_setuptools = False
subpackages = ['firebird', 'include', 'include.pydispatch', 'inheritance',
'manager', 'maxdb', 'mysql', 'mssql', 'postgres', 'sqlite',
@@ -18,6 +20,13 @@
DistributionMetadata.classifiers = None
DistributionMetadata.download_url = None
+kw = {}
+if is_setuptools:
+ kw['entry_points'] = """
+ [paste.filter_app_factory]
+ main = sqlobject.wsgi_middleware:make_middleware
+ """
+
setup(name="SQLObject",
version="0.8",
description="Object-Relational Manager, aka database wrapper",
@@ -58,6 +67,7 @@
'sqlite': ['pysqlite'],
# Others?
},
+ **kw
)
# Send announce to:
@@ -107,4 +117,4 @@
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
"""
-
\ No newline at end of file
+
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py 2006-01-12 16:50:35 UTC (rev 1500)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py 2006-01-13 07:20:19 UTC (rev 1501)
@@ -84,9 +84,7 @@
'sqlite:///' + installedDBFilename)
def getConnection(**kw):
- name = conftest.option.Database
- if conftest.connectionShortcuts.has_key(name):
- name = conftest.connectionShortcuts[name]
+ name = getConnectionURI()
conn = sqlobject.connectionForURI(name, **kw)
if conftest.option.show_sql:
conn.debug = True
@@ -94,6 +92,12 @@
conn.debugOutput = True
return conn
+def getConnectionURI():
+ name = conftest.option.Database
+ if conftest.connectionShortcuts.has_key(name):
+ name = conftest.connectionShortcuts[name]
+ return name
+
try:
connection = getConnection()
except Exception, e:
@@ -291,6 +295,6 @@
sqlobject.main.warnings_level = None
sqlobject.main.exception_level = 0
-__all__ = ['getConnection', 'setupClass', 'Dummy', 'raises',
+__all__ = ['getConnection', 'getConnectionURI', 'setupClass', 'Dummy', 'raises',
'd', 'inserts', 'supports', 'deprecated_module',
'setup_module', 'teardown_module']
Added: SQLObject/trunk/sqlobject/tests/test_paste.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_paste.py 2006-01-12 16:50:35 UTC (rev 1500)
+++ SQLObject/trunk/sqlobject/tests/test_paste.py 2006-01-13 07:20:19 UTC (rev 1501)
@@ -0,0 +1,74 @@
+from dbtest import *
+from sqlobject import sqlhub, SQLObject, StringCol
+try:
+ from sqlobject.wsgi_middleware import make_middleware
+except ImportError:
+ disable = True
+
+class NameOnly(SQLObject):
+ name = StringCol()
+
+def makeapp(abort=False, begin=False, fail=False):
+ def app(environ, start_response):
+ NameOnly(name='app1')
+ if fail == 'early':
+ assert 0
+ start_response('200 OK', [('content-type', 'text/plain')])
+ if begin:
+ environ['sqlobject.begin']()
+ NameOnly(name='app2')
+ if abort:
+ environ['sqlobject.abort']()
+ if fail:
+ assert 0
+ return ['ok']
+ return app
+
+def makestack(abort=False, begin=False, fail=False, **kw):
+ app = makeapp(abort=abort, begin=begin, fail=fail)
+ app = make_middleware(app, {}, database=getConnectionURI(), **kw)
+ return app
+
+def runapp(**kw):
+ print '-'*8
+ app = makestack(**kw)
+ env = {}
+ def start_response(*args):
+ pass
+ try:
+ list(app(env, start_response))
+ return True
+ except AssertionError:
+ return False
+
+def setup():
+ setupClass(NameOnly)
+ NameOnly._connection = sqlhub
+
+def names():
+ names = [n.name for n in NameOnly.select(connection=getConnection())]
+ names.sort()
+ return names
+
+def test_fail():
+ setup()
+ assert not runapp(fail=True, use_transaction=True)
+ assert names() == []
+ setup()
+ assert not runapp(fail=True, use_transaction=False)
+ assert names() == ['app1', 'app2']
+ setup()
+ assert not runapp(fail=True, begin=True, use_transaction=True)
+ assert names() == ['app1']
+
+def test_other():
+ setup()
+ assert runapp(fail=False, begin=True, use_transaction=True)
+ assert names() == ['app1', 'app2']
+ setup()
+ assert runapp(fail=False, begin=True, abort=True, use_transaction=True)
+ assert names() == ['app1']
+ setup()
+ assert runapp(use_transaction=True)
+ assert names() == ['app1', 'app2']
+
Property changes on: SQLObject/trunk/sqlobject/tests/test_paste.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: SQLObject/trunk/sqlobject/wsgi_middleware.py
===================================================================
--- SQLObject/trunk/sqlobject/wsgi_middleware.py 2006-01-12 16:50:35 UTC (rev 1500)
+++ SQLObject/trunk/sqlobject/wsgi_middleware.py 2006-01-13 07:20:19 UTC (rev 1501)
@@ -0,0 +1,97 @@
+from paste.deploy.converters import asbool
+from paste.wsgilib import catch_errors
+from paste.util import import_string
+import sqlobject
+import threading
+
+def make_middleware(app, global_conf, database=None, use_transaction=False,
+ hub=None):
+ """
+ WSGI middleware that sets the connection for the request (using
+ the database URI or connection object) and the given hub (or
+ ``sqlobject.sqlhub`` if not given).
+
+ If ``use_transaction`` is true, then the request will be run in a
+ transaction.
+
+ Applications can use the keys (which are all no-argument functions):
+
+ ``sqlobject.get_connection()``:
+ Returns the connection object
+
+ ``sqlobject.abort()``:
+ Aborts the transaction. Does not raise an error, but at the *end*
+ of the request there will be a rollback.
+
+ ``sqlobject.begin()``:
+ Starts a transaction. First commits (or rolls back if aborted) if
+ this is run in a transaction.
+
+ ``sqlobject.in_transaction()``:
+ Returns true or false, depending if we are currently in a
+ transaction.
+ """
+ use_transaction = asbool(use_transaction)
+ if database is None:
+ database = global_conf.get('database')
+ if not database:
+ raise ValueError(
+ "You must provide a 'database' configuration value")
+ if isinstance(hub, basestring):
+ hub = import_string.eval_import(hub)
+ if not hub:
+ hub = sqlobject.sqlhub
+ if isinstance(database, basestring):
+ database = sqlobject.connectionForURI(database)
+ return SQLObjectMiddleware(app, database, use_transaction, hub)
+
+class SQLObjectMiddleware(object):
+
+ def __init__(self, app, conn, use_transaction, hub):
+ self.app = app
+ self.conn = conn
+ self.use_transaction = use_transaction
+ self.hub = hub
+
+ def __call__(self, environ, start_response):
+ conn = [self.conn]
+ if self.use_transaction:
+ conn[0] = conn[0].transaction()
+ any_errors = []
+ use_transaction = [self.use_transaction]
+ self.hub.threadConnection = conn[0]
+ def abort():
+ assert use_transaction[0], (
+ "You cannot abort, because a transaction is not being used")
+ any_errors.append(None)
+ def begin():
+ if use_transaction[0]:
+ if any_errors:
+ conn[0].rollback()
+ else:
+ conn[0].commit()
+ any_errors[:] = []
+ use_transaction[0] = True
+ conn[0] = self.conn.transaction()
+ self.hub.threadConnection = conn[0]
+ def error(exc_info=None):
+ any_errors.append(None)
+ ok()
+ def ok():
+ if use_transaction[0]:
+ if any_errors:
+ conn[0].rollback()
+ else:
+ conn[0].commit()
+ self.hub.threadConnection = None
+ def in_transaction():
+ return use_transaction[0]
+ def get_connection():
+ return conn[0]
+ environ['sqlobject.get_connection'] = get_connection
+ environ['sqlobject.abort'] = abort
+ environ['sqlobject.begin'] = begin
+ environ['sqlobject.in_transaction'] = in_transaction
+ return catch_errors(self.app, environ, start_response,
+ error_callback=error, ok_callback=ok)
+
Property changes on: SQLObject/trunk/sqlobject/wsgi_middleware.py
___________________________________________________________________
Name: svn:eol-style
+ native
|
|
From: SourceForge.net <no...@so...> - 2006-01-12 16:51:49
|
Bugs item #1389410, was opened at 2005-12-24 10:28 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1389410&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: Closed >Resolution: Fixed Priority: 5 Submitted By: Alvin (alvinwang) >Assigned to: Oleg Broytmann (phd) Summary: child_name is text Initial Comment: There are performance issues in a number of databases with text fields. I do not think that class names should be an unlimited length. Say 40 characters max and make it a varchar(40). Even 100 characters is okay but there should be a limit. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-01-12 19:51 Message: Logged In: YES user_id=4799 Fixed at the revision 1500 in the 0.7-branch. It has been fixed already in the trunk. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1389410&group_id=74338 |
|
From: <sub...@co...> - 2006-01-12 16:50:43
|
Author: phd
Date: 2006-01-12 09:50:35 -0700 (Thu, 12 Jan 2006)
New Revision: 1500
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/main.py
Log:
Fixed bug N 1389410: restricted the length of childName column to 255 characters.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-01-12 16:27:36 UTC (rev 1499)
+++ SQLObject/branches/0.7-bugfix/sqlobject/main.py 2006-01-12 16:50:35 UTC (rev 1500)
@@ -740,7 +740,7 @@
if hasattr(cls, '_inheritable') and cls._inheritable and \
cls.__name__ <> "InheritableSQLObject":
cls.sqlmeta.columnDefinitions['childName'] = col.StringCol(
- name='childName', default=None)
+ name='childName', length=255, default=None)
######################################################
# Set some attributes to their defaults, if necessary.
|
|
From: SourceForge.net <no...@so...> - 2006-01-12 16:28:30
|
Bugs item #1344338, was opened at 2005-11-01 01:28 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1344338&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: MySQL Group: SQLObject release (specify) Status: Open >Resolution: Fixed Priority: 5 Submitted By: Andy Dustman (adustman) >Assigned to: Oleg Broytmann (phd) Summary: 0.7.0: autoCommit from URI wrong type Initial Comment: In dbconnection.py, when the URI is parsed, there is no special treatment or type conversion of the autoCommit parameter, so it is always stored as a string. In the MySQL case (mysql.mysqlconnection), this causes the call to conn.autocommit() to always, since that API function requires an integer (booleans work too). A workaround for this is to change conn.autocommit(self.autoCommit) to conn.autocommit(int(self.autoCommit)), though only works if an integer is used as a parameter; it fails if True or False is used. Note that sybase support has this sequence in SybaseConnection.__init__(): autoCommit = kw.get('autoCommit') if autoCommit: autoCommmit = int(autoCommit) else: autoCommit = None kw['autoCommit'] = autoCommit DBAPI.__init__(self, **kw) A similar block of code would also work for MySQLdb. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-01-12 19:28 Message: Logged In: YES user_id=4799 Fixed at the revision 1499. Please try and report if it works for you. ---------------------------------------------------------------------- Comment By: Andy Dustman (adustman) Date: 2006-01-03 16:38 Message: Logged In: YES user_id=71372 Either will work. The Python C API turns bool into int. Actual boolean values would be more readable. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-03 15:32 Message: Logged In: YES user_id=4799 Documentation for MySQLdb says "Set the autocommit mode. True values enable; False value disable." What are those True and False - bools or ints? Should I write conn.autocommit(int(self.autoCommit)) or conn.autocommit(bool(self.autoCommit)) ? ---------------------------------------------------------------------- Comment By: Mike Kent (mrmakent) Date: 2005-12-09 20:11 Message: Logged In: YES user_id=1401261 I just ran into this same problem using SQLObject with TurboGears. Passing autoCommit as an empty string: mysql://server:port/db?autoCommit=&debug= as the previous commenter suggested did NOT work; I got the same TypeError exception. ---------------------------------------------------------------------- Comment By: Andy Dustman (adustman) Date: 2005-11-03 00:05 Message: Logged In: YES user_id=71372 That doesn't work; I tried it previously. It results in SQLObject trying to do conn.autocommit(''), which still results in a TypeError. Even though '' == False, it is not an integer, and thismethod requires an integer (or boolean). ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-11-02 23:42 Message: Logged In: YES user_id=4799 Pass autoCommit as an empty string: mysql://server:port/db?autoCommit=&debug= ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1344338&group_id=74338 |
|
From: <sub...@co...> - 2006-01-12 16:27:48
|
Author: phd
Date: 2006-01-12 09:27:36 -0700 (Thu, 12 Jan 2006)
New Revision: 1499
Modified:
home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py
home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed the bug N 1344338: convert self.autoCommit from string to bool/int.
Modified: home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
+++ home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2006-01-12 16:27:36 UTC (rev 1499)
@@ -47,7 +47,7 @@
self.usingUnicodeStrings = False
self.make_conn_str = lambda keys: \
["", keys.user, keys.password, keys.host, keys.db]
- self.autoCommit=autoCommit
+ self.autoCommit=int(autoCommit)
self.host = host
self.db = db
self.user = user
Modified: home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
+++ home/phd/SQLObject/paramstyles/sqlobject/mysql/mysqlconnection.py 2006-01-12 16:27:36 UTC (rev 1499)
@@ -46,7 +46,7 @@
)
if hasattr(conn, 'autocommit'):
- conn.autocommit(self.autoCommit)
+ conn.autocommit(bool(self.autoCommit))
return conn
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-12 16:27:36 UTC (rev 1499)
@@ -49,7 +49,7 @@
sqlite2_Binary = sqlite.Binary
sqlite.Binary = lambda s: sqlite2_Binary(sqlite.encode(s))
else:
- opts['autocommit'] = autoCommit
+ opts['autocommit'] = bool(autoCommit)
if 'encoding' in kw:
opts['encoding'] = popKey(kw, 'encoding')
if 'mode' in kw:
|
|
From: <sub...@co...> - 2006-01-12 16:27:35
|
Author: phd
Date: 2006-01-12 09:27:23 -0700 (Thu, 12 Jan 2006)
New Revision: 1498
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed the bug N 1344338: convert self.autoCommit from string to bool/int.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
@@ -47,7 +47,7 @@
self.usingUnicodeStrings = False
self.make_conn_str = lambda keys: \
["", keys.user, keys.password, keys.host, keys.db]
- self.autoCommit=autoCommit
+ self.autoCommit=int(autoCommit)
self.host = host
self.db = db
self.user = user
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mysql/mysqlconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
@@ -46,7 +46,7 @@
)
if hasattr(conn, 'autocommit'):
- conn.autocommit(self.autoCommit)
+ conn.autocommit(bool(self.autoCommit))
return conn
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-12 16:27:23 UTC (rev 1498)
@@ -49,7 +49,7 @@
sqlite2_Binary = sqlite.Binary
sqlite.Binary = lambda s: sqlite2_Binary(sqlite.encode(s))
else:
- opts['autocommit'] = autoCommit
+ opts['autocommit'] = bool(autoCommit)
if 'encoding' in kw:
opts['encoding'] = popKey(kw, 'encoding')
if 'mode' in kw:
|
|
From: <sub...@co...> - 2006-01-12 16:27:18
|
Author: phd
Date: 2006-01-12 09:27:04 -0700 (Thu, 12 Jan 2006)
New Revision: 1497
Modified:
SQLObject/trunk/sqlobject/mssql/mssqlconnection.py
SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed the bug N 1344338: convert self.autoCommit from string to bool/int.
Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2006-01-12 08:02:28 UTC (rev 1496)
+++ SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
@@ -47,7 +47,7 @@
self.usingUnicodeStrings = False
self.make_conn_str = lambda keys: \
["", keys.user, keys.password, keys.host, keys.db]
- self.autoCommit=autoCommit
+ self.autoCommit=int(autoCommit)
self.host = host
self.db = db
self.user = user
Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-01-12 08:02:28 UTC (rev 1496)
+++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
@@ -46,7 +46,7 @@
)
if hasattr(conn, 'autocommit'):
- conn.autocommit(self.autoCommit)
+ conn.autocommit(bool(self.autoCommit))
return conn
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-12 08:02:28 UTC (rev 1496)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-12 16:27:04 UTC (rev 1497)
@@ -49,7 +49,7 @@
sqlite2_Binary = sqlite.Binary
sqlite.Binary = lambda s: sqlite2_Binary(sqlite.encode(s))
else:
- opts['autocommit'] = autoCommit
+ opts['autocommit'] = bool(autoCommit)
if 'encoding' in kw:
opts['encoding'] = popKey(kw, 'encoding')
if 'mode' in kw:
|
|
From: SourceForge.net <no...@so...> - 2006-01-12 16:18:08
|
Bugs item #1387369, was opened at 2005-12-21 21:03 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1387369&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: Postgres Group: SQLObject release (specify) >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: tables not created in correct order Initial Comment: When I have this code: class ClassB(SQLObject): ... var1=StringCol() ... class ClassA(SQLObject): ... var2=ForeignKey('ClassB') ... I get an error that relation 'classb' does not exist. So when I execute tg-admin sql create it tries to create the ClassA table first, not checking for the dependencies and create ClassB first. When I created the ClassB table manually (via tg-admin shell), it went all ok. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-01-04 00:15 Message: Logged In: NO The problem is resolved in SQLObject SVN, but not in 0.7, so I thiink we can resolve this bug. The bug was in sqlobject.manager. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-03 16:51 Message: Logged In: YES user_id=4799 In any case, is the problem a problem of SQLObject or tg-admin? I think the latter. ---------------------------------------------------------------------- Comment By: Stephen Thorne (jerub) Date: 2005-12-22 04:51 Message: Logged In: YES user_id=100823 I have experenced a similar problem in the past with SQLObject based projects. The general solution seems to be, with databases like postgrsql, to create the foreignkeys after all the tables have been created. This is a code snippet that I have used in the past for creating a bunch of tables correctly (used with SQLObject 0.6.0, so don't be surprised if it doesn't work with the latest SQLObject): fkeys = [] tablename = [] pgCSQL = sqlobject.ForeignKey.baseClass.postgresCreateSQL def newfk(c): fkeys.append((tablename[-1], pgCSQL(c).split(',')[1])) return pgCSQL(c).split(',')[0] sqlobject.ForeignKey.baseClass.postgresCreateSQL = newfk import database import views c = database.__connection__ c.autoCommit = True for x in database.__all__: o = getattr(database, x) tablename.append(o._table) o.createTable() for table, key in fkeys: c.query("ALTER TABLE %s ADD %s" % (table, key)) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1387369&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-12 12:58:00
|
Bugs item #1094171, was opened at 2005-01-01 22:59 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&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: Wichert Akkerman (wichert) >Assigned to: Oleg Broytmann (phd) Summary: unicode queries break Initial Comment: When trying to store unicode data in a database I get an exception with the backtrace below. Tested using current SVN trunk. File "./parse", line 10, in StoreChannels nc[xid]=tvguide.database.Channel.byXid(xid) File "<string>", line 1, in <lambda> File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 961, in _SO_fetchAlternateID value) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 400, in _SO_selectOneAlt return self.queryOne("SELECT %s FROM %s WHERE %s = %s" % File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 230, in queryOne return self._runWithConnection(self._queryOne, s) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 125, in _runWithConnection val = meth(conn, *args) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 223, in _queryOne self._executeRetry(conn, c, s) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 196, in _executeRetry return cursor.execute(query) TypeError: argument 1 must be str, not unicode ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-01-12 15:57 Message: Logged In: YES user_id=4799 Call me stupid, but I see xid = sqlobject.StringCol(length=32, varchar=True, alternateID=True) xid *IS* StringCol in my eyes! Are my eyes lying? Well, it is a known problem in SQLObject: if you do .select(), .selectBy() or .by*() you have to convert unicode to string yourself: Channel.byXid(xid.encode(dbEncoding)) even for UnicodeColumns. ---------------------------------------------------------------------- Comment By: Wichert Akkerman (wichert) Date: 2006-01-12 15:24 Message: Logged In: YES user_id=15420 This code did use a UnicodeCol. The class definition used is: class Channel(sqlobject.SQLObject): xid = sqlobject.StringCol(length=32, varchar=True, alternateID=True) name = sqlobject.UnicodeCol(length=64, varchar=True, notNone=True) programs = sqlobject.MultipleJoin("Program") xid is not StringCol here, which is correct it is only allowed to store ASCII data. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-06-17 15:18 Message: Logged In: YES user_id=4799 Use UnicodeCol to convert unicode to DB strings. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-03-01 18:12 Message: Logged In: YES user_id=4799 What type is xid column? Can you provide a test program? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-12 12:24:31
|
Bugs item #1094171, was opened at 2005-01-01 20:59 Message generated for change (Comment added) made by wichert You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&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: Fixed Priority: 5 Submitted By: Wichert Akkerman (wichert) Assigned to: Nobody/Anonymous (nobody) Summary: unicode queries break Initial Comment: When trying to store unicode data in a database I get an exception with the backtrace below. Tested using current SVN trunk. File "./parse", line 10, in StoreChannels nc[xid]=tvguide.database.Channel.byXid(xid) File "<string>", line 1, in <lambda> File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 961, in _SO_fetchAlternateID value) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 400, in _SO_selectOneAlt return self.queryOne("SELECT %s FROM %s WHERE %s = %s" % File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 230, in queryOne return self._runWithConnection(self._queryOne, s) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 125, in _runWithConnection val = meth(conn, *args) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 223, in _queryOne self._executeRetry(conn, c, s) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 196, in _executeRetry return cursor.execute(query) TypeError: argument 1 must be str, not unicode ---------------------------------------------------------------------- >Comment By: Wichert Akkerman (wichert) Date: 2006-01-12 13:24 Message: Logged In: YES user_id=15420 This code did use a UnicodeCol. The class definition used is: class Channel(sqlobject.SQLObject): xid = sqlobject.StringCol(length=32, varchar=True, alternateID=True) name = sqlobject.UnicodeCol(length=64, varchar=True, notNone=True) programs = sqlobject.MultipleJoin("Program") xid is not StringCol here, which is correct it is only allowed to store ASCII data. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-06-17 13:18 Message: Logged In: YES user_id=4799 Use UnicodeCol to convert unicode to DB strings. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-03-01 16:12 Message: Logged In: YES user_id=4799 What type is xid column? Can you provide a test program? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-11 21:05:52
|
Patches item #1386249, was opened at 2005-12-20 18:09 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1386249&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 Submitted By: Jan-Wijbrand Kolman (j-w) Assigned to: Oleg Broytmann (phd) Summary: Date(time) converters cannot handle dates before 1900 Initial Comment: The Date(time) converters rely on Python's datetime.strftime method. This method cannot handle dates with years < 1900. The attached patch uses 'normal' string interpolation to overcome this limitiation. A test for this fix is included in the patch. I hope this patch proofs to be useful and can be applied to the SQLObject codebase. Thx for the great library! ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-01-12 00:05 Message: Logged In: YES user_id=4799 Oops! I have forgotten to switch to the new URL of the repository and committed to the old one. Now I've recommitted the patch. Rev. 1492. Sorry for the confusion! ---------------------------------------------------------------------- Comment By: Jan-Wijbrand Kolman (j-w) Date: 2006-01-11 23:17 Message: Logged In: YES user_id=80745 I'm confused; I did a check out of both trunk and 0.7-bugfix branch (from http://svn.colorstudy.com/SQLObject/) but I didn't see any changes related to the date(time) converters. Do I look at the wrong repository? ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-11 19:57 Message: Logged In: YES user_id=4799 Applied at the revision 1482 to the 0.7-branch and 1483 to the trunk. Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1386249&group_id=74338 |
|
From: <sub...@co...> - 2006-01-11 20:57:45
|
Author: phd
Date: 2006-01-11 13:57:41 -0700 (Wed, 11 Jan 2006)
New Revision: 1492
Modified:
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/tests/test_converters.py
Log:
Recommitted patches that I have erroneously committed to to the old repository.
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2006-01-11 20:57:23 UTC (rev 1491)
+++ SQLObject/trunk/sqlobject/converters.py 2006-01-11 20:57:41 UTC (rev 1492)
@@ -189,20 +189,22 @@
if datetime:
def DateTimeConverter(value, db):
- return value.strftime("'%Y-%m-%d %H:%M:%S'")
+ return "'%4d-%02d-%02d %02d:%02d:%02d'" % (
+ value.year, value.month, value.day,
+ value.hour, value.minute, value.second)
registerConverter(datetime.datetime, DateTimeConverter)
+ def DateConverter(value, db):
+ return "'%4d-%02d-%02d'" % (value.year, value.month, value.day)
+
+ registerConverter(datetime.date, DateConverter)
+
def TimeConverter(value, db):
- return value.strftime("'%H:%M:%S'")
+ return "'%02d:%02d:%02d'" % (value.hour, value.minute, value.second)
registerConverter(datetime.time, TimeConverter)
- def DateConverter(value, db):
- return value.strftime("'%Y-%m-%d'")
-
- registerConverter(datetime.date, DateConverter)
-
if Decimal:
def DecimalConverter(value, db):
return value.to_eng_string()
Modified: SQLObject/trunk/sqlobject/tests/test_converters.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_converters.py 2006-01-11 20:57:23 UTC (rev 1491)
+++ SQLObject/trunk/sqlobject/tests/test_converters.py 2006-01-11 20:57:41 UTC (rev 1492)
@@ -82,6 +82,15 @@
assert sqlrepr(TRUE, 'mysql') == "1"
assert sqlrepr(FALSE, 'mysql') == "0"
+def test_datetime():
+ from datetime import datetime, date, time
+ assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == "'2005-07-14 13:31:02'"
+ assert sqlrepr(date(2005, 7, 14)) == "'2005-07-14'"
+ assert sqlrepr(time(13, 31, 2)) == "'13:31:02'"
+ # now dates before 1900
+ assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == "'1428-07-14 13:31:02'"
+ assert sqlrepr(date(1428, 7, 14)) == "'1428-07-14'"
+
def test_instance():
instance = TestClass()
assert sqlrepr(instance) == repr(instance)
|
|
From: <sub...@co...> - 2006-01-11 20:57:28
|
Author: phd
Date: 2006-01-11 13:57:23 -0700 (Wed, 11 Jan 2006)
New Revision: 1491
Modified:
home/phd/SQLObject/paramstyles/sqlobject/converters.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_converters.py
Log:
Recommitted patches that I have erroneously committed to to the old repository.
Modified: home/phd/SQLObject/paramstyles/sqlobject/converters.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/converters.py 2006-01-11 20:56:17 UTC (rev 1490)
+++ home/phd/SQLObject/paramstyles/sqlobject/converters.py 2006-01-11 20:57:23 UTC (rev 1491)
@@ -189,20 +189,22 @@
if datetime:
def DateTimeConverter(value, db):
- return value.strftime("'%Y-%m-%d %H:%M:%S'")
+ return "'%4d-%02d-%02d %02d:%02d:%02d'" % (
+ value.year, value.month, value.day,
+ value.hour, value.minute, value.second)
registerConverter(datetime.datetime, DateTimeConverter)
+ def DateConverter(value, db):
+ return "'%4d-%02d-%02d'" % (value.year, value.month, value.day)
+
+ registerConverter(datetime.date, DateConverter)
+
def TimeConverter(value, db):
- return value.strftime("'%H:%M:%S'")
+ return "'%02d:%02d:%02d'" % (value.hour, value.minute, value.second)
registerConverter(datetime.time, TimeConverter)
- def DateConverter(value, db):
- return value.strftime("'%Y-%m-%d'")
-
- registerConverter(datetime.date, DateConverter)
-
if Decimal:
def DecimalConverter(value, db):
return value.to_eng_string()
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_converters.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_converters.py 2006-01-11 20:56:17 UTC (rev 1490)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_converters.py 2006-01-11 20:57:23 UTC (rev 1491)
@@ -82,6 +82,15 @@
assert sqlrepr(TRUE, 'mysql') == "1"
assert sqlrepr(FALSE, 'mysql') == "0"
+def test_datetime():
+ from datetime import datetime, date, time
+ assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == "'2005-07-14 13:31:02'"
+ assert sqlrepr(date(2005, 7, 14)) == "'2005-07-14'"
+ assert sqlrepr(time(13, 31, 2)) == "'13:31:02'"
+ # now dates before 1900
+ assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == "'1428-07-14 13:31:02'"
+ assert sqlrepr(date(1428, 7, 14)) == "'1428-07-14'"
+
def test_instance():
instance = TestClass()
assert sqlrepr(instance) == repr(instance)
|
|
From: <sub...@co...> - 2006-01-11 20:56:27
|
Author: phd
Date: 2006-01-11 13:56:17 -0700 (Wed, 11 Jan 2006)
New Revision: 1490
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/converters.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_converters.py
Log:
Recommited patches that I have erroneously commited to tye old repository.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/converters.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/converters.py 2006-01-11 19:14:53 UTC (rev 1489)
+++ SQLObject/branches/0.7-bugfix/sqlobject/converters.py 2006-01-11 20:56:17 UTC (rev 1490)
@@ -189,20 +189,22 @@
if datetime:
def DateTimeConverter(value, db):
- return value.strftime("'%Y-%m-%d %H:%M:%S'")
+ return "'%4d-%02d-%02d %02d:%02d:%02d'" % (
+ value.year, value.month, value.day,
+ value.hour, value.minute, value.second)
registerConverter(datetime.datetime, DateTimeConverter)
+ def DateConverter(value, db):
+ return "'%4d-%02d-%02d'" % (value.year, value.month, value.day)
+
+ registerConverter(datetime.date, DateConverter)
+
def TimeConverter(value, db):
- return value.strftime("'%H:%M:%S'")
+ return "'%02d:%02d:%02d'" % (value.hour, value.minute, value.second)
registerConverter(datetime.time, TimeConverter)
- def DateConverter(value, db):
- return value.strftime("'%Y-%m-%d'")
-
- registerConverter(datetime.date, DateConverter)
-
if Decimal:
def DecimalConverter(value, db):
return value.to_eng_string()
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_converters.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_converters.py 2006-01-11 19:14:53 UTC (rev 1489)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_converters.py 2006-01-11 20:56:17 UTC (rev 1490)
@@ -82,6 +82,15 @@
assert sqlrepr(TRUE, 'mysql') == "1"
assert sqlrepr(FALSE, 'mysql') == "0"
+def test_datetime():
+ from datetime import datetime, date, time
+ assert sqlrepr(datetime(2005, 7, 14, 13, 31, 2)) == "'2005-07-14 13:31:02'"
+ assert sqlrepr(date(2005, 7, 14)) == "'2005-07-14'"
+ assert sqlrepr(time(13, 31, 2)) == "'13:31:02'"
+ # now dates before 1900
+ assert sqlrepr(datetime(1428, 7, 14, 13, 31, 2)) == "'1428-07-14 13:31:02'"
+ assert sqlrepr(date(1428, 7, 14)) == "'1428-07-14'"
+
def test_instance():
instance = TestClass()
assert sqlrepr(instance) == repr(instance)
|
|
From: SourceForge.net <no...@so...> - 2006-01-11 20:17:23
|
Patches item #1386249, was opened at 2005-12-20 15:09 Message generated for change (Comment added) made by j-w You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1386249&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 Submitted By: Jan-Wijbrand Kolman (j-w) Assigned to: Oleg Broytmann (phd) Summary: Date(time) converters cannot handle dates before 1900 Initial Comment: The Date(time) converters rely on Python's datetime.strftime method. This method cannot handle dates with years < 1900. The attached patch uses 'normal' string interpolation to overcome this limitiation. A test for this fix is included in the patch. I hope this patch proofs to be useful and can be applied to the SQLObject codebase. Thx for the great library! ---------------------------------------------------------------------- >Comment By: Jan-Wijbrand Kolman (j-w) Date: 2006-01-11 20:17 Message: Logged In: YES user_id=80745 I'm confused; I did a check out of both trunk and 0.7-bugfix branch (from http://svn.colorstudy.com/SQLObject/) but I didn't see any changes related to the date(time) converters. Do I look at the wrong repository? ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-11 16:57 Message: Logged In: YES user_id=4799 Applied at the revision 1482 to the 0.7-branch and 1483 to the trunk. Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1386249&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-11 17:04:56
|
Bugs item #1398353, was opened at 2006-01-06 11:48 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1398353&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: SQLite Group: SQLObject release (specify) >Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: full path cannot work? SQLObject 0.7.0 Initial Comment: I tried the following in windows XP using SQLObject 0.7.0, the path for DB is: C:\\Documents and Settings\\guest\\My Documents\\test.db sDBPath = os.path.abspath('test.db') sqlhub.processConnection = connectionForURI('sqlite:%s' % sDBPath) it insists on having "/". -------- exception ----------------- File "c:\program files\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 80, in _parseURI assert rest.startswith('/'), "URIs must start with scheme:/ -- you did not include a / (in %r)" % rest AssertionError: URIs must start with scheme:/ -- you did not include a / (in 'C:\\Documents and Settings\\tambrinc\\My Documents\\test.db') ------------------------------------ sqlhub.processConnection = connectionForURI('sqlite:/%s' % sDBPath) -------- exception ----------------- File "C:\Program Files\Python24\Lib\site-packages\sqlite\main.py", line 445, in __init__ self.db = _sqlite.connect(database, mode) _sqlite.DatabaseError: unable to open database file ------------------------------------ ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-01-11 20:04 Message: Logged In: YES user_id=4799 Yes, this is an URI. It must has forward, not backward slashes. To convert fullpath to URI I use the following code: cwd = os.getcwd() cwd_uri = cwd.replace(os.sep, '/') if os.name == 'nt': cwd_uri = '/' + cwd_uri.replace(':', '|') ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1398353&group_id=74338 |