[sqlalchemy] @propert

2009-09-10 Thread Paulo Aquino
I add a python property to my class, can i make this query able? Anyone knows of a good sample on how to do this, I would really appreciate. rgds, Paulo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" gr

[sqlalchemy] Dynamic loader versus lazy=True

2009-09-10 Thread Wolodja Wentland
Hi all, I observed that if I define a relation (foo_query) as lazy='dynamic' and access all referenced entities with foo_query.all() that the query will be executed every time i access it. That is not a big surprise ;-) In a library I am writing i want to provide methods that allow pre-filtering

[sqlalchemy] Re: finding related objects

2009-09-10 Thread Michael Bayer
Martijn Faassen wrote: > > Hey, > > [finding related objects] > > One way I've come up with is this: > > > m = object_mapper(model) > for prop in m.iterate_properties: > if isinstance(prop, RelationProperty): > if prop.direction is ONETOMANY: > for related in getattr(mod

[sqlalchemy] Re: finding related objects

2009-09-10 Thread Martijn Faassen
Hey, [finding related objects] One way I've come up with is this: m = object_mapper(model) for prop in m.iterate_properties: if isinstance(prop, RelationProperty): if prop.direction is ONETOMANY: for related in getattr(model, prop.key): do_stuff(rela

[sqlalchemy] Re: Threading

2009-09-10 Thread Michael Bayer
Michael Mileusnich wrote: > I have a db file with a function called getsession() that returns my > Session > which has been established to = a scoped session. The odd thing is it > works > fine on my Windows XP machine, however on my ubuntu box it throws errors. > I > guess I'll reply later today

[sqlalchemy] Re: Threading

2009-09-10 Thread Michael Mileusnich
I have a db file with a function called getsession() that returns my Session which has been established to = a scoped session. The odd thing is it works fine on my Windows XP machine, however on my ubuntu box it throws errors. I guess I'll reply later today with the errors. Thanks Michael Mileusn

[sqlalchemy] Re: Threading

2009-09-10 Thread Michael Bayer
Michael Mileusnich wrote: > I have switched my application to use the Python multiprocessor threading > instead if the default python gil threading. I seem to be running into > issues. I am using scoped sessions and in my run() function, when I try > to > do sess = getsession() to grab the sessi

[sqlalchemy] finding related objects

2009-09-10 Thread Martijn Faassen
Hi there, I'm trying to figure out whether there's something in SQLAlchemy that lets me reliably get all the objects related to another: i.e. all children of a parent that (in the underlying record) have a foreign key relationship to the parent record. One way I've been trying to solve this i

[sqlalchemy] Threading

2009-09-10 Thread Michael Mileusnich
I have switched my application to use the Python multiprocessor threading instead if the default python gil threading. I seem to be running into issues. I am using scoped sessions and in my run() function, when I try to do sess = getsession() to grab the session sql alchemy throws a large number

[sqlalchemy] ORM and EXISTS?

2009-09-10 Thread Seppo11
Hi! I'm having trouble getting a query to work. The query looks rather simple but I can't manage to build it using sqlalchemy - especially I didn't find a way for the exists clause to build. The query (simplified): SELECT * from ATable WHERE EXISTS ( SELECT 1 FROM BTable join CTable on BTable

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Mike Conley
As expected, the simple test works. Something else is happening. In [7]: cpaste Pasting code; enter '--' alone on the line to stop. :Base=declarative_base() :Base.metadata.bind = create_engine('sqlite:///', echo=True) :class Foo(Base): :__tablename__ = 'foo' :id = Column(Integer, primary_k

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Mike Conley
Now we are getting into areas beyond my SA understanding. Here is my test with scoped_session that shows in version 0.5.5 that session.extension is available and modifiable, don't know if it gets called but that would be pretty easy to check. You might want to try the same test. >>> import sqlalch

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Laurent Rahuel
Hi, Thank you for your interest. Testing with this kind of declaration : session.extensions = [VersionedListener()] doesn't change anything and using this kind of declaration : session.extensions.append(MySessionExtension()) returns: AttributeError: 'ScopedSession' object has no attribute 'exte

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Mike Conley
Well, it looks like configure is a class method on Session, so when you do session.configure() you are configuring future sessions, not the current one. The extensions for a session instance are are a property named extensions. You could try setting that list yourself. session.extensions = [MySes

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Laurent Rahuel
Small type : print session.is_active On 10 sep, 14:07, Laurent Rahuel wrote: > Here is a sample code: > > print session.is_active() > > class MySessionExtension(SessionExtension): >     print "Entering MySessionExtension" >     def before_flush(self, session, flush_context, instances): >        

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread Laurent Rahuel
Here is a sample code: print session.is_active() class MySessionExtension(SessionExtension): print "Entering MySessionExtension" def before_flush(self, session, flush_context, instances): print "Entering method before_flush" session.configure(extension=MySessionExtension()) # s

[sqlalchemy] Re: Update session extension after creation

2009-09-10 Thread asrenzo
I also tried session.configure(extension=MySessionExtension()) with no success On 10 sep, 10:13, Laurent Rahuel wrote: > Hi, > > I'm currently using a webframework which uses sqlalchemy. Each time a > request hits the server, the framework creates a session object I can > use during the page cr

[sqlalchemy] Update session extension after creation

2009-09-10 Thread Laurent Rahuel
Hi, I'm currently using a webframework which uses sqlalchemy. Each time a request hits the server, the framework creates a session object I can use during the page creation. I wish you could update this session with one of my SessionExtension but I'm facing a small problem: I tested my code