From fc753a06475c2fa571d09d73d3169b66c272c8d6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 8 Sep 2007 19:51:35 +0000 Subject: - fixes to ShardedSession to work with deferred columns [ticket:771]. - user-defined shard_chooser() function must accept "clause=None" argument; this is the ClauseElement passed to session.execute(statement) and can be used to determine correct shard id (since execute() doesn't take an instance) --- examples/sharding/attribute_shard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/sharding') diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index 25da98872..0a9e992a3 100644 --- a/examples/sharding/attribute_shard.py +++ b/examples/sharding/attribute_shard.py @@ -22,6 +22,7 @@ from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.orm.shard import ShardedSession from sqlalchemy.sql import operators +from sqlalchemy import sql import datetime # step 2. databases @@ -107,7 +108,7 @@ shard_lookup = { # note that we need to define conditions for # the WeatherLocation class, as well as our secondary Report class which will # point back to its WeatherLocation via its 'location' attribute. -def shard_chooser(mapper, instance): +def shard_chooser(mapper, instance, clause=None): if isinstance(instance, WeatherLocation): return shard_lookup[instance.continent] else: -- cgit v1.2.1