[sqlalchemy] Outer join question

2011-12-01 Thread Thierry Florac
Hi, I have a little problem with outer joins (I use QSLAlchemy 0.5.6). I have two tables, managing tasks and activities : class Task(Base): __tablename__ = 'tache' id = Column(Integer, Sequence('seq_tache_id'), primary_key=True) libelle = Column(Unicode(50)) description =

[sqlalchemy] Column parameters: default=callable is working, but onupdate=callable is not.

2011-12-01 Thread Wubin
Hi, I created two classes Resource and BaseMedia, and BaseMedia is a subclass of Resource. The table mapping is implemented as below: class Resource(Database.Base): __tablename__ = resources createUserId = Column(create_user_id, Integer, ForeignKey(users.id), nullable=True,

[sqlalchemy] Re: Outer join question

2011-12-01 Thread Thierry Florac
Hi, Problem is solved with last SQLAlchemy 0.7.6 !! I was a little affrayed to change but only had minor incompatibilities :-) For anybody interested, the good syntax is : session.query(Activity, TaskAM.libelle, TaskPM.libelle) \ .outerjoin(TaskAM, Activity.task_am) \

Re: [sqlalchemy] Re: Outer join question

2011-12-01 Thread Michael Bayer
you can probably do it in all versions including 0.5 just using two separate outerjoin calls: outerjoin(Activity.task_am).\ outerjoin(Activity.task_pm) each new call to outerjoin() starts back from the parent Activity. the TaskAM/TaskPM targets can be implicit there. On Dec 1, 2011, at 11:12

Re: [sqlalchemy] SqlAlchemy 0.6.8 Initiatior in AttributeExtension

2011-12-01 Thread Michael Bayer
On Nov 30, 2011, at 7:48 PM, Hector Blanco wrote: Hello everyone! I am using (yeah, still) SqlAlchemy 0.6.8 and I'm using an AttributeExtension to build permissions of users. class UserGroupExtension(AttributeExtension): def set(self, state, value, oldvalue, initiator):

Re: [sqlalchemy] Column parameters: default=callable is working, but onupdate=callable is not.

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 1:32 AM, Wubin wrote: Hi, I created two classes Resource and BaseMedia, and BaseMedia is a subclass of Resource. The table mapping is implemented as below: class Resource(Database.Base): __tablename__ = resources createUserId = Column(create_user_id,

Re: [sqlalchemy] bug in reflection.py sqla 0.7.3

2011-12-01 Thread Michael Bayer
I'm not able to reproduce that, and also this code should likely be replaced by our existing topological sort code. Can you provide a succinct reproducing example ? On Dec 1, 2011, at 2:22 AM, Robert Forkel wrote: Hi, trying to use Inspector.get_table_names with order_by='foreign_key'

Re: [sqlalchemy] bug in reflection.py sqla 0.7.3

2011-12-01 Thread Michael Bayer
nevermind, I need to randomize that list in order to trigger it On Dec 1, 2011, at 1:42 PM, Michael Bayer wrote: I'm not able to reproduce that, and also this code should likely be replaced by our existing topological sort code. Can you provide a succinct reproducing example ? On Dec

Re: [sqlalchemy] Column parameters: default=callable is working, but onupdate=callable is not.

2011-12-01 Thread Wubin Chin
Hi Michael, Thank you for the reply, the logs I got from the sqlalchemy shown as below: 2011-12-01 13:53:49,062 INFO sqlalchemy.engine.base.Engine.0x...29cc UPDATE base_media SET name=%s WHERE base_media.id = %s 2011-12-01 13:53:49,062 INFO [sqlalchemy.engine.base.Engine.0x...29cc] UPDATE

Re: [sqlalchemy] bug in reflection.py sqla 0.7.3

2011-12-01 Thread Michael Bayer
thats fixed in r2b66b5abf755, will be in 0.7.4 or you can get the tip off the download page. On Dec 1, 2011, at 1:47 PM, Michael Bayer wrote: nevermind, I need to randomize that list in order to trigger it On Dec 1, 2011, at 1:42 PM, Michael Bayer wrote: I'm not able to reproduce

Re: [sqlalchemy] Column parameters: default=callable is working, but onupdate=callable is not.

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 1:32 AM, Wubin wrote: Hi, I created two classes Resource and BaseMedia, and BaseMedia is a subclass of Resource. The table mapping is implemented as below: class Resource(Database.Base): __tablename__ = resources createUserId = Column(create_user_id,

Re: [sqlalchemy] SqlAlchemy 0.6.8 Initiatior in AttributeExtension

2011-12-01 Thread Hector Blanco
@validates... Where have you been? Oh... In the documentation, all along. The day I learn to read, I'll conquer the world It works great. Thank you! 2011/12/1 Michael Bayer mike...@zzzcomputing.com: On Nov 30, 2011, at 7:48 PM, Hector Blanco wrote: Hello everyone! I am using (yeah, still)

Re: [sqlalchemy] Column parameters: default=callable is working, but onupdate=callable is not.

2011-12-01 Thread Wu-bin Zhen
Hi Michael, I really appreciate your quick reply, and that you made me clear for this issue. Actually my goal is to log when an object was last modified, and who did it. So I guess I need to use MapperExtension to implement this. Thank you very much, and have a nice day. On Thu, Dec 1, 2011 at

Re: [sqlalchemy] SA doesn't update table

2011-12-01 Thread Geo
Well, my case is a bit different. I'm writing a nightly running batch script. And this script is not running inside pyramid context, which means it is not the model that called from the framework. Instead, I arrange it to run by system cron. But, I'm trying to utilize the pyramid environment

[sqlalchemy] Strange update problem...

2011-12-01 Thread Thierry Florac
Hi, Another quite strange problem using SQLAlchemy... I've created two classes, with matching interfaces build with zope.interface and zope.schema packages ; a web form is build with z3c.form package ; everything is fine ! My problem is quite simple to describe : I have a main class which is a

Re: [sqlalchemy] SA doesn't update table

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 4:29 PM, Geo wrote: And I was suspecting it is the reason of the complex joins in usage, because I have other code that doing things in the same way, the structure of the Query/ SELECT statement that gets you back some data has no connection on how that data behaves

Re: [sqlalchemy] Strange update problem...

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 5:38 PM, Thierry Florac wrote: Hi, So it seems that when resources are in the form and NOT modified, the matching task is not flagged dirty and is not saved in database. I just don't understand why !!! Only a full usage example would make it clear in this case.Again

Re: [sqlalchemy] Strange update problem...

2011-12-01 Thread Thierry Florac
2011/12/2 Michael Bayer mike...@zzzcomputing.com: On Dec 1, 2011, at 5:38 PM, Thierry Florac wrote: Hi, So it seems that when resources are in the form and NOT modified, the matching task is not flagged dirty and is not saved in database. I just don't understand why !!! Only a full usage

Re: [sqlalchemy] Strange update problem...

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 7:09 PM, Thierry Florac wrote: 2011/12/2 Michael Bayer mike...@zzzcomputing.com: On Dec 1, 2011, at 5:38 PM, Thierry Florac wrote: Hi, So it seems that when resources are in the form and NOT modified, the matching task is not flagged dirty and is not saved in

[sqlalchemy] Passing additional arguments to event listeners ?

2011-12-01 Thread Łukasz Czuja
Hi, I do not see anywhere in the docs a way to pass custom attributes to event listeners: event.listen(cls, 'before_insert', before_insert_listener, arg1, arg2, kwarg1 = 'value', kwarg2 = 'value2') so that the before_insert_listener can have mixed signature: def before_insert_listener(mapper,

Re: [sqlalchemy] Passing additional arguments to event listeners ?

2011-12-01 Thread Michael Bayer
On Dec 1, 2011, at 7:24 PM, Łukasz Czuja wrote: Hi, I do not see anywhere in the docs a way to pass custom attributes to event listeners: event.listen(cls, 'before_insert', before_insert_listener, arg1, arg2, kwarg1 = 'value', kwarg2 = 'value2') so that the before_insert_listener can

Re: [sqlalchemy] Passing additional arguments to event listeners ?

2011-12-01 Thread Tate Kim
How about functools.partial ? As far as I know, functools.partial will simply do this. Usually, I import this when I need to make an argument-less function equip extra arguments. Best regards, Tate -Original Message- From: Michael Bayer mike...@zzzcomputing.com Sender:

RE: [sqlalchemy] Passing additional arguments to event listeners ?

2011-12-01 Thread Jackson, Cameron
Not sure if this helps or not, but how about using a lambda that that calls your function with the arguments you want? This is the solution I've been using for passing arguments to wxPython event handlers. This tutorial might help: http://wiki.wxpython.org/Passing%20Arguments%20to%20Callbacks

Re: [sqlalchemy] SA doesn't update table

2011-12-01 Thread Geo
Ok I found the solution, just move the first query into the transaction body: import transaction try: transaction.begin() x_members = session.query(Distributor)... for member in x_members: . except: transaction.abort() BTW, I'm using pyramid framework, which is using the

Re: [sqlalchemy] Passing additional arguments to event listeners ?

2011-12-01 Thread Tate Kim
Yes, I think also lambda can be good one. Though lambda reduces an effort to type a predefined function, functools.partial is a bit familiar to me. Best regards, Tate -Original Message- From: Jackson, Cameron cameron.jack...@thalesgroup.com.au Sender: sqlalchemy@googlegroups.com Date: