Re: [Fwd: Re: [sqlalchemy] Book]
Mark, Mark Ramm wrote: On Sat, Jan 16, 2010 at 11:29 AM, werner wbru...@free.fr wrote: Seeing that Mark Ramm is co-author of this book, will it cover TurboGears in any why when it comes out? It has been massively postponed, but it's not altogether stopped. I've been working some the last two weeks to try to get it unjammed and going again. Chances are that it will not partiularly cover TurboGears, but that it might use TG or Pylons in some examples, along with Django and some desktop GUI toolkit or other. Thanks for the feedback. That do cover some different web frameworks is even better, hope the examples are a bit more complex then e.g. the wiki or movie tutorial on TB 2. BTW, what is the best place for you authors to pre-order this book, on side side to show that there is interest for it and hopefully where you will get the most back on it. Best regards Werner -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Apply function to object(s) returned by association_proxy
Hi, is there an easy way to apply a function to the items returned by association_proxy? Currently, I have a setup like this: A-B-C, both one-to-many relations; A.C (association_proxy('B','C')) returns a list of lists but I would like to apply a function (list(chain.from_iterable (x))) that flattens it to a simple list. What what be the best way to implement this? Cheers, Adrian -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Apply function to object(s) returned by association_proxy
On Jan 17, 2010, at 9:20 AM, Adrian wrote: Hi, is there an easy way to apply a function to the items returned by association_proxy? Currently, I have a setup like this: A-B-C, both one-to-many relations; A.C (association_proxy('B','C')) returns a list of lists but I would like to apply a function (list(chain.from_iterable (x))) that flattens it to a simple list. What what be the best way to implement this? you should be able to pass proxy_factory to your association_proxy: foo = association_proxy(B, C, proxy_factory=lambda coll, creator, value: list(chain.from_iterable(coll))) that returned list though won't interact in the other direction, i.e. when you append or remove items from it no events will propagate up to the C or B since above we're not adding handlers for that (I'm assuming this isn't needed since you can't determine that from a flattened list anyway). In that case association_proxy here wouldn't even be needed, a read-only version is just: class A(object): @property def foo(self): reutrn list(chain.from_iterable(b.C for b in self.B)) Cheers, Adrian -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] tracking back from logged sql back to the python that caused it
Michael Bayer wrote: Michael Bayer wrote: it is quite simple to implement yourself, use a ConnectionProxy. Ah, ok, didn't know about them :-) Out of interest, is echo=True implemented as a ConnectionProxy? its not. CP is a little heavyhanded for just the built-in SQL logging. How/where is it implemented? All I'm ultimately looking for is to insert the following wherever that the SQL logging is currently done: s = StringIO() traceback.print_stack(file=s) logging.info('Called from:'+s.getvalue()) I've added hooks to intercept all transactional events at a high level in r6641. Cool, will that land in SA 0.6? There are many, and some such as BEGIN PREPARED result in further statement executions as well. Not sure what the latter half of this means... Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Apply function to object(s) returned by association_proxy
The read-only version was all I needed, thanks. On Jan 17, 3:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 17, 2010, at 9:20 AM, Adrian wrote: Hi, is there an easy way to apply a function to the items returned by association_proxy? Currently, I have a setup like this: A-B-C, both one-to-many relations; A.C (association_proxy('B','C')) returns a list of lists but I would like to apply a function (list(chain.from_iterable (x))) that flattens it to a simple list. What what be the best way to implement this? you should be able to pass proxy_factory to your association_proxy: foo = association_proxy(B, C, proxy_factory=lambda coll, creator, value: list(chain.from_iterable(coll))) that returned list though won't interact in the other direction, i.e. when you append or remove items from it no events will propagate up to the C or B since above we're not adding handlers for that (I'm assuming this isn't needed since you can't determine that from a flattened list anyway). In that case association_proxy here wouldn't even be needed, a read-only version is just: class A(object): @property def foo(self): reutrn list(chain.from_iterable(b.C for b in self.B)) Cheers, Adrian -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/sqlalchemy?hl=en. -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Oracle, ownership and unrecognized type warnings
On Jan 6, 2010, at 2:22 PM, Michael Bayer wrote: its true that there's no built in functionality to reflect views. Correction. The 0.6 release, currently in trunk, has the capacity to reflect views fully in the same way as tables. Although constraints such as primary and foreign keys aren't part of what it loads, since views technically don't have these, so those remain elements that need to be specified explicitly when reflecting a view. -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] tracking back from logged sql back to the python that caused it
On Jan 17, 2010, at 12:54 PM, Chris Withers wrote: Michael Bayer wrote: Michael Bayer wrote: it is quite simple to implement yourself, use a ConnectionProxy. Ah, ok, didn't know about them :-) Out of interest, is echo=True implemented as a ConnectionProxy? its not. CP is a little heavyhanded for just the built-in SQL logging. How/where is it implemented? All I'm ultimately looking for is to insert the following wherever that the SQL logging is currently done: s = StringIO() traceback.print_stack(file=s) logging.info('Called from:'+s.getvalue()) the ConnectionProxy execute_cursor() method is invoked at the same time the logging is done. There are similar log hooks around commit and rollback and such. A quick skim around sqlalchemy/engine/base.py should be pretty easy to follow. I've added hooks to intercept all transactional events at a high level in r6641. Cool, will that land in SA 0.6? that's part of 0.6 yes. There are many, and some such as BEGIN PREPARED result in further statement executions as well. Not sure what the latter half of this means... DBAPI has no inherent support for two phase transactions, so a COMMIT for example is emitted as SQL along the lines COMMIT PREPARED 'xid'.The proxy will receive a commit_prepared() event as well as the subsequent execute() events. -- 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 group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.