On Jul 19, 2007, at 1:45 PM, Ian Wilson wrote:

>
> Can anyone explain why this http://paste.turbogears.org/paste/1510
> fails at the last assert but this
> http://paste.turbogears.org/paste/1511 works ?
>

I cant actually guess what that might be, unless your Resouce or  
CifsResource class evaluates to True when tested with "not".

Its likely that your Resource mapper is not set up to load  
polymorphically, or something is otherwise glitchy with how the  
tables are set up.  After the flush(), your CifsResource is present  
in the session; it has an instance key of (CifsResource, (id, )).    
The get() method, being that its called on a Resource query, looks  
for the instance key (Resource, (id, )), finds nothing, then issues a  
query.  Depending  on how things are set up , it will either find a  
row or it wont.  Lets say it finds a row, doesnt know its supposed to  
load polymorphically, and creates a Resource object.   Being that  
this is undefined behavior, its conceivable that things get tripped  
up internally at that point where it simultaneously locates the  
CifsResoucre in the session and also links it to the (Resource,  
(id,)) key, causing the second access to complete.  but this all  
relies upon "if not resource" evaluating to True for a non-None  
value; otherwise i dont yet see how this could happen quite that way.

the actual answer will be in turning on echo='debug' and seeing what  
its actually doing, doing a repr() on the returned value, and  
checking your polymorphic setup.

in version 0.4 we will be looking into identifiying all joined- and  
single- table inheritance objects against the root class so get()- 
lookups like these will be much less error-prone.  it will also be  
easier to set up polymorphic loading for mappers since the  
"polymorphic join/union" scenario becomes an optional optimization.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to