Thanks for not only explaining the problem, but also suggesting a
solution.  I'll give it a shot.

-------------------------


On Dec 10, 10:58 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> this is because RowProxy is using __slots__ now.  which ironically is
> also for efficiency reasons :) .    there are ways to build mutable
> wrapper objects which are pretty efficient in a case like this, such
> as a named tuple.   my own minimal version of that looks like:
>
> def named_tuple(names):
>      class NamedTuple(tuple):
>          pass
>      for i, name in enumerate(names):
>          setattr(NamedTuple, name, property(itemgetter(i)))
>      return NamedTuple
>
> Post = named_tuple('id' 'post_body', 'excerpt')
> for post in posts:
>         post = Post([post.id, post.post_body, post.post_body[0:100]])
>
> On Dec 10, 2008, at 11:20 AM, GregF wrote:
>
>
>
> > Hi,
>
> > I dusted off a project that had been dormant for a few months.
> > Upgrading to sqlalchemy .5 broke some code where I was inserting
> > computed values directly into  a rowproxy object, before I passed the
> > rows to a template.
>
> > I'm getting 'RowProxy' object has no attribute 'excerpt'
>
> > Here is a very much simplified version of what I'm doing that used to
> > work before the .5 upgrade:
> > --------------------------------------------------------------------------------------
> >    posts_table = Table('posts', metadata, autoload=True)
> >    q = posts_table.select()
> >    ... some q.where stuff here
>
> >    r = q.execute()
>
> >    posts = r.fetchall()
>
> >    for post in posts:
> >        post.excerpt = post.post_body[0:100]
>
> >    return posts
> > ---------------------------------------------------------
>
> > The code bombs on any computed value, whether slicing is used or not.
> > I was trying to avoid building a new object like "posts" as an array
> > of dict, for simplicity and efficiency reasons.
>
> > Is there any way to fix this, or will I just have to build my own
> > object?
>
> > Thank, Greg
--~--~---------~--~----~------------~-------~--~----~
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