[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Denis S. Otkidach
On 26 май, 20:50, Michael Bayer mike...@zzzcomputing.com wrote: However, its quite easy to achieve.  Just use this. class LimitingQuery(Query):     def get(self, ident):         return Query.get(self.populate_existing(), ident)     def __iter__(self):         return

[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Denis S. Otkidach
On 27 май, 18:22, Michael Bayer mike...@zzzcomputing.com wrote: On May 27, 2009, at 4:25 AM, Denis S. Otkidach wrote: class LimitingQuery(Query):     def get(self, ident):         return Query.get(self.populate_existing(), ident)     def __iter__(self):         return Query.__iter__

[sqlalchemy] Re: Automatically filtering all queries

2009-05-26 Thread Denis S. Otkidach
On 26 май, 18:24, Michael Bayer mike...@zzzcomputing.com wrote: Denis S. Otkidach wrote: such ability in SQLAlchemy. There is a suggestion ( http://groups.google.com/group/sqlalchemy/browse_thread/thread/bcd10e... ) to provide custom query_cls. This probably worked a year ago

[sqlalchemy] Inheritance and binds to several engines

2009-03-10 Thread Denis S. Otkidach
I use declarative to define database scheme, and binds parameter to session constructed from several metadata tables lists. And I have a problem with inherited models, where table is represented as Join object: get_bind() method doesn't find an engine. A quick-n-dirty solution I use is: class

[sqlalchemy] Re: Python 2.6 hash behavior change

2008-03-04 Thread Denis S. Otkidach
On Mon, Mar 3, 2008 at 8:23 PM, Michael Bayer [EMAIL PROTECTED] wrote: We define __eq__() all over the place so that would be a lot of __hash__() methods to add, all of which return id(self). I wonder if we shouldn't just make a util.Mixin called Hashable so that we can centralize the

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-16 Thread Denis S. Otkidach
On Jan 15, 2008 6:54 PM, Michael Bayer [EMAIL PROTECTED] wrote: The last commit fails with: sqlalchemy.exceptions.IntegrityError: (IntegrityError) Referers.objectId may not be NULL u'UPDATE Referers SET objectId=? WHERE Referers.id = ?' [None, 1] right thats because the instance doesnt

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-15 Thread Denis S. Otkidach
On Jan 11, 2008 8:41 PM, Michael Bayer [EMAIL PROTECTED] wrote: what that looks like to me is that you're attempting to query the database for object ID #1 using merge(). when you merge(), its going to treat the object similarly to how it does using session.save_or_update(). that is, it

[sqlalchemy] Re: doubly-linked list

2008-01-11 Thread Denis S. Otkidach
On Jan 11, 2008 7:57 PM, Jonathan LaCour [EMAIL PROTECTED] wrote: Jonathan LaCour wrote: I am attempting to model a doubly-linked list, as follows: ... seems to do the trick. I had tried using backref's earlier, but it was failing because I was specifying a remote_side keyword

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-11 Thread Denis S. Otkidach
On Dec 28, 2007 6:25 PM, Michael Bayer [EMAIL PROTECTED] wrote: On Dec 28, 2007, at 5:50 AM, Denis S. Otkidach wrote: Sure, I can get an object from DB and copy data from new one. But there is a lot of object types, so have to invent yet another meta description for it (while it already

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-28 Thread Denis S. Otkidach
On Dec 28, 2007 1:00 AM, Rick Morrison [EMAIL PROTECTED] wrote: Here's the idiom that should work: def ensure_object(sess, id): o = sess.Query(ModelObject).get(id)# if found, o is now loaded into session if not o: o = ModelObject(1, u'title') sess.save(o)

[sqlalchemy] Re: Is there a way to replace object in DB?

2007-12-27 Thread Denis S. Otkidach
On Dec 26, 2007 10:38 PM, Michael Bayer [EMAIL PROTECTED] wrote: if you have an instance which you are unsure if it already exists, you can add it to a session using session.save_or_update(instance). The decision between INSERT and UPDATE is ultimately decided by the presence of an attribute

[sqlalchemy] Objects are stored in DB when nobody asks to do so

2007-12-26 Thread Denis S. Otkidach
The following code fails on the last assert statement (SQLAlchemy 0.4.1): ---8--- from __future__ import with_statement import sqlalchemy as sa, logging from sqlalchemy.orm import mapper, sessionmaker logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) logging.basicConfig() class

[sqlalchemy] Re: Objects are stored in DB when nobody asks to do so

2007-12-26 Thread Denis S. Otkidach
On Dec 26, 2007 6:29 PM, Michael Bayer [EMAIL PROTECTED] wrote: yet another scenario, you want to use transactions that are independent of session flushes. To accomplish this, use engine- or connection-level transactions, as described in the second half of