Re: [sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 5:45 PM, Alessandro Dentella wrote: > On Mon, Feb 07, 2011 at 01:32:52PM -0500, Michael Bayer wrote: Otherwise you can append your AttributeExtension into the listeners collection on the attribute, I'd have to check the source of attributes.py to recall the exact

Re: [sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread Alessandro Dentella
On Mon, Feb 07, 2011 at 01:32:52PM -0500, Michael Bayer wrote: > >> Otherwise you can append your AttributeExtension into the listeners > >> collection on the attribute, I'd have to check the source of attributes.py > >> to recall the exact name of the collection. > > > > a hint here would be appr

Re: [sqlalchemy] Re: Strange ObjectDeletedError

2011-02-07 Thread Michael Bayer
I actually just did a little bit of reverse course on this in 0.7. I've moved all the accounting into the try/except block so that the flush completes fully before the autocommit expires everything. This is a change to a pattern that's been the same way since 0.4 so hoping nothing bad happen

Re: [sqlalchemy] Selects after an update ?

2011-02-07 Thread Romy
Thanks Michael. I think this has everything to do with the fact that I'm running autocommit=True and the default expire_on_commit=True ! According to ticket 2041 , all my flushes reload objects ! Does this explain why, if I wrap the above code in my

Re: [sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 1:29 PM, Alessandro Dentella wrote: > On Mon, Feb 07, 2011 at 10:26:18AM -0500, Michael Bayer wrote: >> Its easier to do in 0.7 where you just say >> event.listen(MyObject.attribute, "append", fn), >> any time you want.Though we haven't implemented "remove" yet. >> I'd

Re: [sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread Alessandro Dentella
On Mon, Feb 07, 2011 at 10:26:18AM -0500, Michael Bayer wrote: > Its easier to do in 0.7 where you just say > event.listen(MyObject.attribute, "append", fn), > any time you want.Though we haven't implemented "remove" yet. > I'd wait for the 0.7 betas if possible. nice!, but it's not an op

[sqlalchemy] Re: FOR UPDATE OF

2011-02-07 Thread Kent
I'd like to find (or make) the time for a patch. Having said that, I made what will work for my use case, and I think it is severely lacking for what would be proper for the sqla project: * I've only studied Oracle/Postgres for "FOR UPDATE OF", so it would only work for oracle/postgresql * My so

Re: [sqlalchemy] MapperExtension.append_result ....

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 11:42 AM, Martijn Moeling wrote: > I think, I might be helped with the create_instance "event" Assuming you're talking about when the ORM establishes an instance from a newly fetched row, you can use the @reconstructor hook for that. 0.7 publishes this event additionally a

Re: [sqlalchemy] MapperExtension.append_result ....

2011-02-07 Thread Martijn Moeling
I think, I might be helped with the create_instance "event" I will never ever stop a class from being saved/persistent, it is the other way around. I thought I was able to use joins and or relations to limit for "allowed" results from a query. With all the polymorphic and self references I have

Re: [sqlalchemy] Re: FOR UPDATE OF

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 11:26 AM, Kent wrote: > For whatever reason I couldn't use compiler.is_subquery(): > return len(self.stack) > 1 > > I guess from this context I need: len(self.stack) > 0 > > Not sure why, except that I'm "one stack level" off when the @compiles > function is invoked to be abl

[sqlalchemy] Re: FOR UPDATE OF

2011-02-07 Thread Kent
For whatever reason I couldn't use compiler.is_subquery(): return len(self.stack) > 1 I guess from this context I need: len(self.stack) > 0 Not sure why, except that I'm "one stack level" off when the @compiles function is invoked to be able to use compiler.is_subquery(). @compiles(Select) def

Re: [sqlalchemy] Re: FOR UPDATE OF

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 11:16 AM, Kent wrote: > On Feb 4, 12:04 pm, Kent wrote: >> Excellent, it is working for the simpler case, but for oracle 8 (who >> isn't as smart when indexing) I also need it to work for >> subqueryload(). >> >> So the problem is that my FOR UPDATE OF is also being added for

Re: [sqlalchemy] MapperExtension.append_result ....

2011-02-07 Thread Michael Bayer
On Feb 7, 2011, at 10:55 AM, Martijn Moeling wrote: > Hi, > > It is me again with an interesting thing, I've searched the net, this group > etc. Not a lot of people seem interested in append_result, I AM!! > > I am looking for a way to implement the following: > > > I have many tables, a lot

[sqlalchemy] Re: FOR UPDATE OF

2011-02-07 Thread Kent
On Feb 4, 12:04 pm, Kent wrote: > Excellent, it is working for the simpler case, but for oracle 8 (who > isn't as smart when indexing) I also need it to work for > subqueryload(). > > So the problem is that my FOR UPDATE OF is also being added for > subqueryload selects. > > * Can I tell within th

[sqlalchemy] MapperExtension.append_result ....

2011-02-07 Thread Martijn Moeling
Hi, It is me again with an interesting thing, I've searched the net, this group etc. Not a lot of people seem interested in append_result, I AM!! I am looking for a way to implement the following: I have many tables, a lot with polymorphic inheritance and self and cross references. In order

Re: [sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread Michael Bayer
Its easier to do in 0.7 where you just say event.listen(MyObject.attribute, "append", fn), any time you want.Though we haven't implemented "remove" yet. I'd wait for the 0.7 betas if possible. Otherwise you can append your AttributeExtension into the listeners collection on the attribute,

Re: [sqlalchemy] SQLAlchemy + Elixir + Tornado overall setup

2011-02-07 Thread Michael Bayer
I've added the /05/ docs to "disallow" in our robots.txt, since Google insists upon putting 05 hits above all else, and those documents are not as well written as the current ones. That paragraph is now rewritten in a simpler format at http://www.sqlalchemy.org/docs/orm/session.html#lifespan-

[sqlalchemy] SQLAlchemy + Elixir + Tornado overall setup

2011-02-07 Thread Romy
So I haven't really given too much thought to the setup until recently. Thus, some of this could well be silly. Up until now it's been a global scopedsession per each Tornado process, with autocommit=True, pool_recycle=14400, pool_size=20. IIRC, the autocommit=True was a quick solution to the "

[sqlalchemy] attaching an AttributeExt to an existing mapper

2011-02-07 Thread sandro dentella
Hi, is there a way to attach an attribute extension of an existing property of an (existing) mapper? I made some tests [1] and it seems that attaching the AttrExt to a mapper does not work: mapper.get_property('name').extension = MyAttrExt() Is there a way apart from setting it while creating