[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Pavel Aborilov
scoped_session use threads only if you dont use scopefunc. On Saturday, February 15, 2014 2:05:33 AM UTC+4, Jonathan Vanasco wrote: > > I don't know if any of this will help - I'm too tired to read though all > your code: > > 1. Twisted isn't threadsafe, so anything happening in deferToThread nee

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Hipp
On 2/14/2014 3:36 PM, Michael Bayer wrote: the django ORM would write an autogenerated primary key value to a foreign key column at the same time in a single INSERT? What magic might they have discovered there? (hint: i am sure they don't do that) Naw. If you recall I was supplying the pkey A

[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Jonathan Vanasco
I don't know if any of this will help - I'm too tired to read though all your code: 1. Twisted isn't threadsafe, so anything happening in deferToThread needs to be entirely encapsulated. This has totally screwed me up many times. You should avoid a scoped_session , as it has to do with thread

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Bayer
On Feb 14, 2014, at 4:29 PM, Michael Hipp wrote: > On 2/14/2014 2:34 PM, Michael Bayer wrote: >> >> A basic fact of a self referential relationship is that you're building a >> tree. The root of the tree has to be NULL and I'd advise against trying to >> work around that. >> >> Now if you w

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Hipp
On 2/14/2014 2:34 PM, Michael Bayer wrote: A basic fact of a self referential relationship is that you're building a tree. The root of the tree has to be NULL and I'd advise against trying to work around that. Now if you wanted to in fact assign the object's own primary key to the foreign k

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Bayer
On Feb 14, 2014, at 3:16 PM, Michael Hipp wrote: > On 2/14/2014 1:51 PM, Michael Bayer wrote: >> right this is why reading the docs is better, those have been checked... >> remote side for m2o refers to the primary key, so: > > The docs says: '...directive is added known as remote_side, which

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Hipp
On 2/14/2014 1:51 PM, Michael Bayer wrote: right this is why reading the docs is better, those have been checked... remote side for m2o refers to the primary key, so: The docs says: '...directive is added known as remote_side, which is a Column or collection of Column objects that indicate t

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Bayer
right this is why reading the docs is better, those have been checked… remote side for m2o refers to the primary key, so: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Animal(Base): __tablename_

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Hipp
On 2/14/2014 11:50 AM, Michael Bayer wrote: On Feb 14, 2014, at 12:46 PM, Michael Hipp wrote: On 2/13/2014 11:45 AM, Michael Bayer wrote: So for "children" above you need to spell out primaryjoin completely which is primaryjoin="and_(Animal.sire_id == Animal.id_, Animal.dam_id == Animal.id)"

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Bayer
On Feb 14, 2014, at 12:46 PM, Michael Hipp wrote: > On 2/13/2014 11:45 AM, Michael Bayer wrote: >> So for "children" above you need to spell out primaryjoin completely which >> is primaryjoin="and_(Animal.sire_id == Animal.id_, Animal.dam_id == >> Animal.id)". > > Thought I was on the right

Re: [sqlalchemy] Parent child relationships

2014-02-14 Thread Michael Hipp
On 2/13/2014 11:45 AM, Michael Bayer wrote: So for "children" above you need to spell out primaryjoin completely which is primaryjoin="and_(Animal.sire_id == Animal.id_, Animal.dam_id == Animal.id)". Thought I was on the right track but now getting the exception below. Here's the model: cla

[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Pavel Aborilov
In Twisted there is a great thing known as `ContextTracker`: > provides a way to pass arbitrary key/value data up and down a call > stack without passing them as parameters to the functions on that call > stack. In my twisted web app in method `render_GET` I set a `uuid` parameter: call = co