[sqlalchemy] need 0.6_beta2-compat declarative meta

2010-03-27 Thread Daniel Robbins
Hi All, In 0.6_beta2, the following code is not properly adding a primary key Column via DeclarativeMeta which calls my PrimaryKey() function: def PrimaryKey(seqprefix): return Column(Integer, Sequence(seqprefix, optional=True), primary_key=True) class ClassDefaults(DeclarativeMeta):

Re: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-27 Thread Daniel Robbins
On Mar 23, 2010, at 9:29 AM, King Simon-NFHD78 wrote: object_session does indeed return the session that the instance is already bound to (so you shouldn't close it). I didn't know what object_session would return if the original session had been closed, so I tried it: Thanks for looking into

[sqlalchemy] Re: need 0.6_beta2-compat declarative meta

2010-03-27 Thread avdd
In a metaclass's __init__, the attributes have already been placed on the class, so mutating the attributes dict has no effect. Try setting the id attribute directly: self.id = PrimaryKey(...) On Mar 27, 6:04 pm, Daniel Robbins drobb...@funtoo.org wrote: Hi All, In 0.6_beta2, the following

Re: [sqlalchemy] Re: need 0.6_beta2-compat declarative meta

2010-03-27 Thread Chris Withers
avdd wrote: In a metaclass's __init__, the attributes have already been placed on the class, so mutating the attributes dict has no effect. Spot on. SA fudged this prior to 0.6beta so you could get away with shoving stuff in dict_, you now can't... def PrimaryKey(seqprefix): return

[sqlalchemy] re: tightening contraints on whats allowed in mixins

2010-03-27 Thread Chris Withers
Hi Michael, I read http://www.sqlalchemy.org/trac/ticket/1751 with some curiousity. My take on declarative mixins was that _as_declarative should basically accumulate everything from the bases as if it were in the class itself and then let _as_declarative behave exactly as it usually did on

[sqlalchemy] use of dict_ versus getting attributes from cls

2010-03-27 Thread Chris Withers
Hi Again, I'm also curious about use of dict_ versus getting from cls in _as_declarative. IIRC, at pycon, you changed it so that DeclarativeMeta passes the class's __dict__ as dict_ and then made it so that only dict_ is consulted for attributes. However, _as_declarative intrinsically needs

[sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Fernando Takai
Hi all! I'm running SQLAlchemy 0.6b2 for a while and i've seem some strange exception (AttributeError: 'NoneType' object has no attribute '_sa_iterator') happening one in a while. This is my stacktrace: Traceback (most recent call last): File /usr/lib/python2.5/threading.py, line 486, in

Re: [sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Sebastian Elsner
Well seems like the project you want to access is just None. SA can't do anything with it. I had a similar problem recently, it was bacause the objects got garbage collected before being accessed. A testcase would be really helpful. On Sat, 27 Mar 2010 17:42:20 +0100, Fernando Takai

[sqlalchemy] Re: tightening contraints on whats allowed in mixins

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 12:31 PM, Chris Withers wrote: Hi Michael, I read http://www.sqlalchemy.org/trac/ticket/1751 with some curiousity. My take on declarative mixins was that _as_declarative should basically accumulate everything from the bases as if it were in the class itself and

[sqlalchemy] Re: use of dict_ versus getting attributes from cls

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 12:35 PM, Chris Withers wrote: Hi Again, I'm also curious about use of dict_ versus getting from cls in _as_declarative. IIRC, at pycon, you changed it so that DeclarativeMeta passes the class's __dict__ as dict_ and then made it so that only dict_ is consulted for

[sqlalchemy] Re: use of dict_ versus getting attributes from cls

2010-03-27 Thread Chris Withers
Michael Bayer wrote: I'm also curious about use of dict_ versus getting from cls in _as_declarative. IIRC, at pycon, you changed it so that DeclarativeMeta passes the class's __dict__ as dict_ and then made it so that only dict_ is consulted for attributes. I did that, I thought, because

[sqlalchemy] Re: tightening contraints on whats allowed in mixins

2010-03-27 Thread Chris Withers
Michael Bayer wrote: We can fine tune the restriction to be more about specifically what was in that ticket, i.e. BaseClass(Base) some column Mixin some column with foreign key to BaseClass.some column ActualClass(BaseClass) some column that overrides BaseClass.some column

Re: [sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 12:42 PM, Fernando Takai wrote: Hi all! I'm running SQLAlchemy 0.6b2 for a while and i've seem some strange exception (AttributeError: 'NoneType' object has no attribute '_sa_iterator') happening one in a while. This is my stacktrace: Traceback (most recent call

Re: [sqlalchemy] Re: need 0.6_beta2-compat declarative meta

2010-03-27 Thread Daniel Robbins
On Mar 27, 2010, at 5:58 AM, Chris Withers wrote: avdd wrote: In a metaclass's __init__, the attributes have already been placed on the class, so mutating the attributes dict has no effect. Spot on. SA fudged this prior to 0.6beta so you could get away with shoving stuff in dict_, you now

Re: [sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Fernando Takai
is it possible your object is present in a session that is, in a different thread, being expired as this operation runs ? I don't know, but i can verify that. If that is happening, what can i do to prevent? Well seems like the project you want to access is just None. SA can't do anything

[sqlalchemy] reflecting (autoload=True) MySQL tinyint(1) fields

2010-03-27 Thread Lloyd Kvam
I've just discovered that some tinyint (8-bit) fields have had their values limited to 0 and 1 regardless of actual value supplied. Digging through the documentation, I've learned that when MySQL tables are reflected, tinyint(1) fields are processed as booleans. I did not find emails from others

Re: [sqlalchemy] 'NoneType' object has no attribute '_sa_iterator' exception

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 3:28 PM, Fernando Takai wrote: is it possible your object is present in a session that is, in a different thread, being expired as this operation runs ? I don't know, but i can verify that. If that is happening, what can i do to prevent? an object associated with a

Re: [sqlalchemy] reflecting (autoload=True) MySQL tinyint(1) fields

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 4:16 PM, Lloyd Kvam wrote: I've just discovered that some tinyint (8-bit) fields have had their values limited to 0 and 1 regardless of actual value supplied. Digging through the documentation, I've learned that when MySQL tables are reflected, tinyint(1) fields are

Re: [sqlalchemy] reflecting (autoload=True) MySQL tinyint(1) fields

2010-03-27 Thread Michael Bayer
On Mar 27, 2010, at 5:17 PM, Michael Bayer wrote: On Mar 27, 2010, at 4:16 PM, Lloyd Kvam wrote: I've just discovered that some tinyint (8-bit) fields have had their values limited to 0 and 1 regardless of actual value supplied. Digging through the documentation, I've learned that when