Re: [sqlalchemy] Updates in after_flush_postexec

2015-11-09 Thread Patrick Lewis
On Monday, November 9, 2015 at 1:50:36 PM UTC-8, Michael Bayer wrote:
>
> On 11/09/2015 03:10 PM, Patrick Lewis wrote: 
>
> > Is this an issue, or am I misunderstanding the doc? 
>
> the documentation was ambiguous.  I have corrected the paragraph as 
> follows: 
>
> diff --git a/doc/build/orm/session_events.rst 
> b/doc/build/orm/session_events.rst 
> index 50c63e6..ecfc517 100644 
> --- a/doc/build/orm/session_events.rst 
> +++ b/doc/build/orm/session_events.rst 
> @@ -72,7 +72,10 @@ for finalized objects and possibly emit additional 
> SQL.   In this hook, 
>  there is the ability to make new changes on objects, which means the 
>  :class:`.Session` will again go into a "dirty" state; the mechanics of 
> the 
>  :class:`.Session` here will cause it to flush **again** if new changes 
> -are detected in this hook.  A counter ensures that an endless loop in 
> this 
> +are detected in this hook if the flush were invoked in the context of 
> +:meth:`.Session.commit`; otherwise, the pending changes will be bundled 
> +as part of the next normal flush.  When the hook detects new changes 
> within 
> +a :meth:`.Session.commit`, a counter ensures that an endless loop in this 
>  regard is stopped after 100 iterations, in the case that an 
>  :meth:`.SessionEvents.after_flush_postexec` 
>  hook continually adds new state to be flushed each time it is called. 
>

That makes sense. When I change my test to use session.commit(), it works 
as described.

Thanks for your help.

- Patrick

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Updates in after_flush_postexec

2015-11-09 Thread Patrick Lewis
I have a sample gist that makes a change to an object in the 
after_flush_postexec event.

https://gist.github.com/p-lewis/deb498bdfb6172bf0013

SQLAlchemy==1.0.9

As I read the documentation 
,
 
I expect that the event infrastructure should detect that the object is 
dirty again, and reprocess the flush. But that does not appear to happen.

My output (ex-schema creation):

2015-11-09 20:00:30,044 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)

2015-11-09 20:00:30,045 INFO sqlalchemy.engine.base.Engine INSERT INTO 
person (name) VALUES (?)

2015-11-09 20:00:30,045 INFO sqlalchemy.engine.base.Engine ('P Body',)

In handler, p: 

session.dirty: IdentitySet([])

session.info: {'RENAMED': True}


Is this an issue, or am I misunderstanding the doc?


Thanks,
Patrick


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Inspect and __init__ of a mapped class

2007-02-04 Thread Patrick Lewis

On Feb 4, 5:54 am, [EMAIL PROTECTED] wrote:
  I'm trying to create a  mapped object where I don't know what the
  exact constructor arguments of the object might be.  I was trying
  to use the inspect module to get the right arguments, but it looks
  like the mapper is redefining the original class __init__.  Any
  thoughts as to how I might ferret out what the original classes
  arguments may have been? I see that the original __init__ it is
  stored in a local variable 'oldinit' inside of
  Mapper._compile_class, but I can't think of any way to get to that.
  Any suggestions?

 maybe do it before compiling the mappers, e.g. before creating any
 instance? store/rename it somewhere under the class, then use that
 one...

Sorry, I don't think that's an option. This is for a library that
doesn't have any control over how the classes are declared or mapped.
By the time I get a reference to the class, it will have almost
certainly been mapped.


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



[sqlalchemy] Inspect and __init__ of a mapped class

2007-02-03 Thread Patrick Lewis

Hi,

I'm trying to create a  mapped object where I don't know what the
exact constructor arguments of the object might be.  I was trying to
use the inspect module to get the right arguments, but it looks like
the mapper is redefining the original class __init__.  Any thoughts as
to how I might ferret out what the original classes arguments may have
been? I see that the original __init__ it is stored in a local
variable 'oldinit' inside of Mapper._compile_class, but I can't think
of any way to get to that. Any suggestions?


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



[sqlalchemy] Re: Test data apparently not saving

2007-01-18 Thread Patrick Lewis


After upgrading sqlite to the most recent version (3.3.10), my problem
went away and everything works as expected.

Thanks for the help, and sorry for the noise.


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



[sqlalchemy] Re: Test data apparently not saving

2007-01-13 Thread Patrick Lewis

I reran the above with a postgres database, and it all worked as
expected.


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



[sqlalchemy] Re: Test data apparently not saving

2007-01-11 Thread Patrick Lewis

Ok, that works for me, too. But, if I rework it how I think the test
suite is running things, I get the same error.

http://paste.turbogears.org/paste/832


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



[sqlalchemy] Re: Test data apparently not saving

2007-01-11 Thread Patrick Lewis

A minor revision (made user1 global)

http://paste.turbogears.org/paste/833


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