Ok. I think I've figured this out. This works:
<code>
dt = DesignType.select()[0]
assert(dt is not None)
d = Design()
d.type = dt
assert(d in dt.designs)
</code>
Notice that d.type was set explicitly. Here's the fix:
Index: lib/sqlalchemy/mapping/__init__.py
===================================================================
--- lib/sqlalchemy/mapping/__init__.py (revision 879)
+++ lib/sqlalchemy/mapping/__init__.py (working copy)
@@ -137,7 +137,7 @@
if not isinstance(getattr(class_, '__init__'), types.MethodType):
def __init__(self, **kwargs):
for key, value in kwargs.items():
- self.__dict__[key] = value
+ setattr(self, key, value)
class_.__init__ = __init__
m = mapper(class_, *args, **params)
class_.mapper = m
~ Daniel
On Feb 1, 2006, at 8:27 AM, dmiller wrote:
On Jan 31, 2006, at 4:57 PM, Michael Bayer wrote:
Ok youve got this:
dt = DesignType.select()[0]
is there a row, and dt non-None ?
d = Design(type=dt)
The auto-constructor thing *should* be working, do you get
something back
for d.type ? does dt.designs have something in it ?
>>> len(dt.designs)
167
>>> d.type is dt
True
>>> d.id is None
True
>>> [d2 for d2 in dt.designs if d2.id is None]
[]
Does that answer your questions?
Thanks,
~ Daniel
-------------------------------------------------------
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