inserts and updates, no problem, if you override before_insert to set  
the "dataset" value youll get it for everything inserted.  you can do  
it for before_update as well, but thats only if you think the loaded  
objects might lose their "dataset" attribute for some reason.

for selects, mapperextension also has select_by() and select().  if  
you take a look at how the SelectResultsExt in  
sqlalchemy.ext.selectresults does it, that will give you some clues;  
youll basically have to take the existing WHERE clause and say and_ 
(existingclause, sometable.c.dataset==x) to wrap that around.

if you can get that going, we might need to add some more query  
methods to mapper extension, like selectfirst(), count(), etc.   
actually, it might be more useful to add a mapper extension method  
that is builds into "select_whereclause"  (like "process_select_args"  
or something) so that most of those other select methods call it  
automatically.  if you look at the source for query.py youll see this  
isnt too hard to add in, if you want to try patching something.

On Sep 6, 2006, at 12:40 PM, Arnar Birgisson wrote:

> Hi all,
>
> I have a legacy schema from an accounting system that for licensing
> reasons puts multiple datasets in one ms-sql server database.
>
> All tables (with no exceptions) contain a 3-char column called
> "dataset", which identifies the dataset to which a row belongs. The
> datasets are completely independent of each other and are in fact the
> financial books for otherwise unrelated companies.
>
> Could I write a mapper_extension (or something similar) that would add
> "where table.dataset = X" for all tables in all selects, inserts and
> updates automatically, preferably with X being read from a property on
> the connection?
>
> Arnar
>
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to