Re: [sqlalchemy] strange error with dynamic_loader

2010-08-04 Thread Michael Bayer

On Aug 4, 2010, at 5:31 PM, Jon Nelson wrote:

> It seems as though attributes which are dynamic_loaders cannot be told
> to eagerly load subattributes which are themselves dynamic_loaders.

that is correct.  dynamic loaders are not backed by in-memory collections, and 
no alternate loader strategies can be applied to them (last line of 
http://www.sqlalchemy.org/docs/mappers.html#dynamic-relationship-loaders ).


> 
> query = a_instance.b  # gimme instances of B, query-like
> query = query.options(sa_orm.eagerload('c'))
> 
> Then the following is broken:
> 
> for b_instance in query:
> 
> with this error:
> 
>for b_instance in query:
>  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/query.py",
> line 1676, in instances
>rows = [process[0](row, None) for row in fetch]
>  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py",
> line 2234, in _instance
>populate_state(state, dict_, row, isnew, only_load_props)
>  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py",
> line 2113, in populate_state
>populator(state, dict_, row)
>  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/strategies.py",
> line 1109, in new_execute
>'append_without_event')
>  File "/usr/lib64/python2.6/site-packages/sqlalchemy/util.py", line
> 1206, in __init__
>self._data_appender = getattr(data, via)
> AttributeError: 'list' object has no attribute 'append_without_event'

its broken in that there's a nasty exception.  There should be a nice clean 
exception saying you can't do that.ticket #1864 is added.



> 
> 
> This is with sqlalchemy 0.6.3
> 
> -- 
> See, when the GOVERNMENT spends money, it creates jobs; whereas when
> the money is left in the hands of TAXPAYERS, God only knows what they
> do with it. Bake it into pies, probably. Anything to avoid creating
> jobs. - Dave Barry?
> 
> Jon
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.



[sqlalchemy] strange error with dynamic_loader

2010-08-04 Thread Jon Nelson
It seems as though attributes which are dynamic_loaders cannot be told
to eagerly load subattributes which are themselves dynamic_loaders.
IE, A has dynamic_loader for instances of B, which has dynamic_loader
for instances of C.

Assuming we have an instance of A, this works fine:

query = a_instance.b  # gimme instances of B, query-like
for b_instance in query:
  # do stuff, possibly accessing b_instance.c

However, if I do this:

query = a_instance.b  # gimme instances of B, query-like
query = query.options(sa_orm.eagerload('c'))

Then the following is broken:

for b_instance in query:

with this error:

for b_instance in query:
  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/query.py",
line 1676, in instances
rows = [process[0](row, None) for row in fetch]
  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py",
line 2234, in _instance
populate_state(state, dict_, row, isnew, only_load_props)
  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py",
line 2113, in populate_state
populator(state, dict_, row)
  File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/strategies.py",
line 1109, in new_execute
'append_without_event')
  File "/usr/lib64/python2.6/site-packages/sqlalchemy/util.py", line
1206, in __init__
self._data_appender = getattr(data, via)
AttributeError: 'list' object has no attribute 'append_without_event'


This is with sqlalchemy 0.6.3

-- 
See, when the GOVERNMENT spends money, it creates jobs; whereas when
the money is left in the hands of TAXPAYERS, God only knows what they
do with it. Bake it into pies, probably. Anything to avoid creating
jobs. - Dave Barry?

Jon

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.