Hi,

I am playing with the mapping inheritance structures to my database.

I have a the following hierarchy:

class Tag(object):
    pass

class NormalisedNameTag(Tag):
    pass

class NormalisedPlaceTag(Tag):
    pass

The idea is that a pre-processing step will produce a series of tags
and then all of the Tags will be postprocessed to normalise them ( map
them to a specific identifier in a controlled vocabulary).

mapper(Tag, tags_table, polymorphic_on=tags_table.c.type)
mapper(NormalisedNameTag, tag_name_normalised_table,
polymorphic_identity='NAME', inherits=Tag )
mapper(NormalisedPlaceTag, tag_name_normalised_table, inherits=Tag,
polymorphic_identity="PLACE")

however, if I do the following

 for entity in session.query(SDY.Tag).filter(SDY.Tag.type ==
"NAME").filter(SDY.Tag.deleted == 0):
    print entity, type(Entity)
    # look up entity in a dictionary and assign an identifier to it
and store in NormalisedNameTag
    entity.name_id = dictionary[ entity.word ]
    session.commit()

then SQLAlchemy decides that it is actually looking for
NormalisedNameTag instead of just plain old Tag.

    raise exc.ObjectDeletedError("Instance '%s' has been deleted." %
state_str(state))
sqlalchemy.orm.exc.ObjectDeletedError: Instance '<NormalisedNameTag at
0x2004ef0>' has been deleted.

So I am confusing SQLAlchemy into thinking that the object has been
deleted when in fact I have never created it? So is there a way round
for this? Can you defer the loading of the inheritance mapping until
later?

Many thanks in advance, yet again,

Nathan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to