Sweet.  Thanks for the tip.  If anyone is interested here's how I got
this to work:

At the top of the app's "config/middleware.py" add a listener class
and instance with whatever raw_connection goodies you would like.
Mine looks like this:

-----

from sqlalchemy.interfaces import PoolListener
class MyListener(PoolListener):
    def connect(self, dbapi_con, con_record):
        from project.lib.natsort import natcasecmp
        dbapi_con.create_collation('natsort', natcasecmp)

my_listener = MyListener()

-----

Then add a new entry in your app_conf dictionary (immediately before
the make_base_app line):

-----

app_conf['sqlalchemy.listeners']=[my_listener,]
app = make_base_app(global_conf, full_stack=True, **app_conf)

-----

-Marcus


On Feb 20, 10:31 pm, Christoph Zwerschke <[email protected]> wrote:
> Am 20.02.2011 21:40 schrieb sharkus:
>
> > However, when actually testing a query from the site I get an
> > "OperationalError: (OperationalError) no such collation sequence".  I
> > can SOMETIMES get things to work if I add something like this to my
> > root controller method (perhaps 1 out of 5 times):
>
> That's because SQLAlchemy is using a pool of database connections (5 by
> default) and you ran create_collation only on one of the connections.
>
> A simple solution would be to reduce the number of connections to 1
> (sqlalchemy.pool_size=1 or sqlalchemy.pool_size=NullPool).
>
> If you want to use the pool, you can set sqlalchemy.creator to a
> function that sets up your connection with create_collation. 
> Seehttp://www.sqlalchemy.org/docs/core/pooling.html#using-a-custom-conne...
>
> -- Christoph

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to