On Apr 4, 2008, at 8:06 PM, Mike Bernson wrote:

>
>     user = Table('users', metadata,
>         Column('id', Integer, primary_key=True),
>         Column('account_name', String(64)))
>
>     address = Table('mail', metadata,
>         Column('id', Integer, primary_key=True),
>         Column('user_id', Integer, ForeignKey('users.id')),
>         Column('email', String(64)))
>
>     metadata.create_all()
>
>     class User(object):
>         __sa_instrument_class__ = SetListener
>
>     class Address(object):
>         __sa_instrument_class__ = SetListener
>
>     add_map = mapper(Address, address)
>     user_map = mapper(User, user, properties={
>         'emails': relation(add_map, lazy=True, uselist=True)
>     })
>
> Is there any way to find out what is already loaded 'emails' ?
>
> I get events with appending to emails. Is there any way to get
> events when sqlalchemy load data into sqlalchemy ?
>
> What I am trying to do is cause some initialization to happen on  
> data that
> get loaded into relation without causing the lazy relations to be  
> loaded. I
> am using append event to known when a relation is added. I need to  
> do the
> initialization after the object is created.

would using your own collection class work ?  The blank collection is  
initialized before anything is loaded into it so you could pick up on  
__init__().   im not sure at which point you want to get at the  
collection.  if its right before a lazy load starts, i think that  
would do it.

Also the event API changed in the branch recently, you're getting an  
InstanceState and not an instance for the first argument now (get the  
instance using state.obj()).







--~--~---------~--~----~------------~-------~--~----~
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