Re: Namespaces/introspection: collecting sql strings for validation

2007-04-25 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Aahz <[EMAIL PROTECTED]> wrote: >>Alex: >>> >>>But don't put such black magic in production. The completely different >>>way is: just don't. >> >> Could you expand on that? After all, that's exactly what we do to >> implem

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-23 Thread Alex Martelli
Martin Drautzburg <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > > Yes, there is: use an ORM to do the SQL generation for you. Check out > > SQLAlchemy, it will buy you much more than what you asked for. > > Might look, though in general I don't like OR mappers much. Having SQL > generate

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-23 Thread Alex Martelli
Aahz <[EMAIL PROTECTED]> wrote: > >But don't put such black magic in production. The completely different > >way is: just don't. > > Could you expand on that? After all, that's exactly what we do to > implement a super() that works with classic classes -- and it's certainly > production code.

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-23 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Martin Drautzburg <[EMAIL PROTECTED]> wrote: >> >> The problem is the first part: how can I lookup the callers module and >> the classobjs defined in there? Or finding any constant strings in the >> caller's module would also

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-23 Thread Martin Drautzburg
Peter Otten wrote: def SQL(sql): > ...     print sql > ... a = SQL("module") > module # that one was obvious class A: > ...     b = SQL("class") > ...     def method(self, c=SQL("default arg")): > ...             d = SQL("method") > ... You are my hero. Indeed very cool! -- http:/

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Martin Drautzburg
George Sakkis wrote: > Yes, there is: use an ORM to do the SQL generation for you. Check out > SQLAlchemy, it will buy you much more than what you asked for. Might look, though in general I don't like OR mappers much. Having SQL generated feels as strange as having python code generated. Too much

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Peter Otten
Martin Drautzburg wrote: > > def SQL(sql, checked=set()): > > if sql in checked: > > return True > > if not valid_sql(sql): raise ValueError > > checked.add(sql) > > return sql > > No this does not do the trick. I will not be able to validate an sql > statement bofore I ru

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Alex Martelli
Martin Drautzburg <[EMAIL PROTECTED]> wrote: ... > The problem is the first part: how can I lookup the callers module and > the classobjs defined in there? Or finding any constant strings in the > caller's module would also be just fine. Or is there a completely > different way to do such a thin

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread George Sakkis
On Apr 21, 4:16 pm, Martin Drautzburg <[EMAIL PROTECTED]> wrote: > I would like to validate sql strings, which are spread all over the > code, i.e. I run ("prepare") them against a database to see if it happy > with the statements. Spelling errors in sql have been a major pain for > me. > > The sta

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Scott David Daniels
Martin Drautzburg wrote: > I would like to validate sql strings, which are spread all over the > code, The statements will not be assembled from smaller pieces, > but they will not neccessarily be defined at module level. I could > live with class level, > parse the source file, but I am

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Martin Drautzburg
Peter Otten wrote: > Martin Drautzburg wrote: > >> I would like to validate sql strings, which are spread all over the >> code, i.e. I run ("prepare") them against a database to see if it >> happy with the statements. Spelling errors in sql have been a major >> pain for me. > > def validateSQL(

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Peter Otten
Martin Drautzburg wrote: > I would like to validate sql strings, which are spread all over the > code, i.e. I run ("prepare") them against a database to see if it happy > with the statements. Spelling errors in sql have been a major pain for > me. > > The statements will not be assembled from sma

Namespaces/introspection: collecting sql strings for validation

2007-04-21 Thread Martin Drautzburg
I would like to validate sql strings, which are spread all over the code, i.e. I run ("prepare") them against a database to see if it happy with the statements. Spelling errors in sql have been a major pain for me. The statements will not be assembled from smaller pieces, but they will not neccess