while youre free to make your own InstrumentedAttribute, i think that
is a long uphill battle which also might be incompatible with new
releases.

I think you might want to go with sticking some hidden attributes on
your pickleable object so that your custom PickleType can just use
those to identify the information it needs (a good choice might be the
"id" of the session, so that you can get the session back by saying
session._sessions[id]).  or, perhaps the item gets a reference back to
its parent so it can find the session via object_session(parent).  or
you could decouple it by using a weak-keyed dictionary somewhere so
that your pickle instances can be mapped back to parent and therefore
session.

this might be something you can set up within a MapperExtension using
populate_instance() when instances are loaded and before_insert() when
instances are about to be first saved.

parent_dict = weakref.WeakValueDictionary()

class MyExt(MapperExtension):
    def populate_instance(self, mapper, selectcontext, row, instance,
identitykey, isnew):
        if not isnew:
            return EXT_PASS
        mapper.populate_instance(context, instance, row, identitykey,
isnew)
        parent_dict[instance.my_pickled_thing] = instance
        return None

class MyPickleType(MapperExtension):
    def convert_bind_param(self, value, dialect):
        return MyPickler(session =
object_session(parent_dict[value])).dumps(value)
    ...


--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to