On 6 Feb 2006, at 20:10, Michael Bayer wrote:


I would rather the ability to place a different mapper on a subclass
without it inheriting the base class' table, if an inherit relationship is not defined. That way you can make subclasses that just get stored in a different table, or subclasses that get stored exactly the same way except you're getting them from a different mapper that knows how to create those subclasses. There also might be interesting dependency relationships that
can be set up when playing around with this kind of thing.

I doubt the above patterns work right now though, sounds like a good
ticket to add to trac.

Interestingly it turns out that I actually need to use one of those patterns (I have an object that inherits from another one that has a mapper, but I don't want to use the mapper from the original one because it does something special.) It does seem to work, provided the other part of that patch (the bit that doesn't check for inherits) has been applied; I've separated it out
below.

Kind regards,

Alastair.

Index: lib/sqlalchemy/mapping/mapper.py
===================================================================
--- lib/sqlalchemy/mapping/mapper.py    (revision 926)
+++ lib/sqlalchemy/mapping/mapper.py    (working copy)
@@ -168,7 +168,8 @@
self._get_clause.clauses.append(primary_key == sql.bindparam("pk_"+primary_key.key))
         if (
- (not hasattr(self.class_, '_mapper') or not mapper_registry.has_key(self.class_._mapper))
+                (not self.class_.__dict__.has_key('_mapper')
+                 or not mapper_registry.has_key(self.class_._mapper))
                 or self.is_primary
or (inherits is not None and inherits._is_primary_mapper())
             ):


--
http://www.alastairs-place.net




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to