[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
On further investigation I see that this is actually per-instance lazy, so no app-level hook will solve it. So somehow __setstate__ needs to re-initialise the attribute. I do actually merge() the object back into the new session, and that is where the error first occurs. My web handling

[sqlalchemy] base classes that have nothing to do with table inheritence

2009-12-17 Thread Chris Withers
Hi All, So, say you have some common methods and field definitions that you want to share across a bunch of mapper classes. My python head says that these should all go in a base class, say, for example: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.schema import

[sqlalchemy] Re: base classes that have nothing to do with table inheritence

2009-12-17 Thread avdd
You could inject the attributes in a metaclass: def common_columns(): return dict(id = Column(Integer, primary_key=True), foo = Column(String)) Base = None class mymeta(DeclarativeMeta): def __init__(self, name, bases, attrs): if Base is not None: #

Re: [sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread Michael Bayer
avdd wrote: On further investigation I see that this is actually per-instance lazy, so no app-level hook will solve it. So somehow __setstate__ needs to re-initialise the attribute. in addition to the compile_mappers() step, all of your mapper() calls (or declarative classes) need to have

Re: [sqlalchemy] base classes that have nothing to do with table inheritence

2009-12-17 Thread Michael Bayer
Chris Withers wrote: How should I create a class like this? This isn't about table inheritance or the like and I'm *sure* I was told an easy solution for this specific use case before, but I can't find it for the life of me now... Just gave a current status on this feature three days ago:

Re: [sqlalchemy] base classes that have nothing to do with table inheritence

2009-12-17 Thread Antoine Pitrou
Le jeudi 17 décembre 2009 à 11:05 -0500, Michael Bayer a écrit : Chris Withers wrote: How should I create a class like this? This isn't about table inheritance or the like and I'm *sure* I was told an easy solution for this specific use case before, but I can't find it for the life of me

[sqlalchemy] Sybase T-SQL join Dialect

2009-12-17 Thread Shuaib Osman
Hi Guys, I'm busy with Sybase ASE and things are somewhat unpleasant. I've had to modify the default Sybase.py driver as it was not targeted specifically for ASE. I've got a barely working version (the reflect code returns all tables and columns but not foreign keys or other constaints). The big

Re: [sqlalchemy] base classes that have nothing to do with table inheritence

2009-12-17 Thread Chris Withers
Antoine Pitrou wrote: http://groups.google.com/group/sqlalchemy/browse_thread/thread/99812e0ca1f8cc7c# Another, not pretty, solution would be to use `exec` with a predefined string containing the declarations... Er, NO! Yet another solution is something like: locals.update((k, v)

Re: [sqlalchemy] DeclarativeBase and multiple inheritance

2009-12-17 Thread Chris Withers
(sorry, missed this earlier) Michael Bayer wrote: The Column objects you declare within declarative become members of the underlying Table object, so its not as simple as just having those members present on a mixin - what would really be needed would be some sort of copying of each column

[sqlalchemy] Re: DeclarativeBase and multiple inheritance

2009-12-17 Thread Daishy
Hi again, I took the approach with creating a Mixin with 4 staticmethods and call them in each of my models, which works quite good. But now i face another, i think related, problem. i get the following columns produced: created_by_id = Column(Integer, ForeignKey('worker.id', onupdate=cascade,

Re: [sqlalchemy] DeclarativeBase and multiple inheritance

2009-12-17 Thread Michael Bayer
On Dec 17, 2009, at 1:59 PM, Chris Withers wrote: (sorry, missed this earlier) Michael Bayer wrote: The Column objects you declare within declarative become members of the underlying Table object, so its not as simple as just having those members present on a mixin - what would really be

Re: [sqlalchemy] Re: DeclarativeBase and multiple inheritance

2009-12-17 Thread Michael Bayer
On Dec 17, 2009, at 2:35 PM, Daishy wrote: Hi again, I took the approach with creating a Mixin with 4 staticmethods and call them in each of my models, which works quite good. But now i face another, i think related, problem. i get the following columns produced: created_by_id =

Re: [sqlalchemy] Sybase T-SQL join Dialect

2009-12-17 Thread Michael Bayer
On Dec 17, 2009, at 1:13 PM, Shuaib Osman wrote: Hi Guys, I'm busy with Sybase ASE and things are somewhat unpleasant. I've had to modify the default Sybase.py driver as it was not targeted specifically for ASE. I've got a barely working version (the reflect code returns all tables and

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
I On Dec 18, 3:04 am, Michael Bayer mike...@zzzcomputing.com wrote: in addition to the compile_mappers() step, all of your mapper() calls (or declarative classes) need to have been imported into the application before any unpickling occurs.   The error you see below is still symptomatic of

[sqlalchemy] How do you handle threading issues?

2009-12-17 Thread Kevin Ar18
Basic question: I have 1 app with multiple processes and threads. Each thread and/or process may end up trying to do something to the database at the same time. What is the solution to threading? How do web frameworks solve it? Is there some inherent design in databases and/or SQLAlchemy

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
On Dec 18, 12:58 pm, avdd adr...@gmail.com wrote: # testlazy.py No, I'm wrong. Investigating further... -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this

[sqlalchemy] Re: lazy instrumented attributes and pickle

2009-12-17 Thread avdd
Thanks, Mike. I was calling compile_mappers before importing the modules. Whoops! On Dec 18, 1:10 pm, avdd adr...@gmail.com wrote: On Dec 18, 12:58 pm, avdd adr...@gmail.com wrote: # testlazy.py No, I'm wrong.  Investigating further... -- You received this message because you are

Re: [sqlalchemy] How do you handle threading issues?

2009-12-17 Thread Michael Bayer
On Dec 17, 2009, at 8:56 PM, Kevin Ar18 wrote: * If I setup 2 sessions, that means I will have 2 connections to the database, meaning the database is the one that will handle threading conflicts per what is described here: http://www.postgresql.org/docs/8.4/static/mvcc.html So, I have 1

[sqlalchemy] Announcing progress_sa

2009-12-17 Thread Daniel Holth
A SQLAlchemy dialect that can be used to read OpenEdge 10 (aka Progress) databases over ODBC. I only use it to read from the database so although it is useful it is certainly incomplete. There is enough there to make queries against reflected tables. It was remarkably easy to implement against