Upgraded to 0.5 trunk and all works fine now.
Thank you again for your help.


Martin


On Jun 3, 5:23 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> merge() makes a copy of the object in a similar manner as which it
> would be loaded from the DB for the first time, using __new__ instead
> of __init__ and assigning state according to the available
> MapperPropertys.  Since your state relies upon extra steps in
> populate_instance, theres no corresponding hook within merge().
>
> 0.5 has a better hook than populate_instance for post-load activities
> which is consistently called whenever an instance is reconsituted.
>
> On Jun 3, 2008, at 11:08 AM, Martin Pengelly-Phillips wrote:
>
>
>
> > Thanks as always for the quick response and fix.
>
> > As a slight aside; I am using a MapperExtension to create an attribute
> > on an object. When the object is stored, reloaded and then merged back
> > into a session this attribute is no longer available.
>
> > Any thoughts on why this might be?
>
> > ta
>
> > Martin
>
> > Pseudo code:
> > ==========
> > class EntityMapperExtension(MapperExtension):
> >    def populate_instance(self, mapper, selectcontext, row, instance,
> > **flags):
> >        if not hasattr(instance, 'property'):
> >            instance.property = PropertyDict(instance)
> >        return EXT_CONTINUE
>
> > obj = Entity()
> > obj.property['group'] > [prop1, prop2]
> > store[id] = obj
> > Session.remove()
> > ...
> > session = Session()
> > obj = session.merge(store[id])
> > obj.property['group'] > AttributeError: 'Entity' object has no
> > attribute 'property'
--~--~---------~--~----~------------~-------~--~----~
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