Re: [Tutor] get name of calling class at runtime

2009-08-23 Thread Serdar Tumgoren
>> I think it does makes sense to keep SQL confined to well-defined >> locations. This can be per class - each class holds its own SQL - or a >> single class that does all database access so all SQL and database >> dependencies are in one place. The above is precisely what I'm after, and I agree t

Re: [Tutor] get name of calling class at runtime

2009-08-22 Thread Alan Gauld
"Kent Johnson" wrote I think it does makes sense to keep SQL confined to well-defined locations. This can be per class - each class holds its own SQL - or a single class that does all database access so all SQL and database dependencies are in one place. My vote for the class every time. I h

Re: [Tutor] get name of calling class at runtime

2009-08-22 Thread Kent Johnson
On Sat, Aug 22, 2009 at 3:54 AM, Alan Gauld wrote: > "Kent Johnson" wrote > can group a bunch of SQL statements in one place; they're currently scattered all over the program and it's getting unwieldy). >>> >>> Normally in an OO program the SQL for each class is in the methods for >>> th

Re: [Tutor] get name of calling class at runtime

2009-08-22 Thread Alan Gauld
"Kent Johnson" wrote can group a bunch of SQL statements in one place; they're currently scattered all over the program and it's getting unwieldy). Normally in an OO program the SQL for each class is in the methods for that class. That way any changes to the class canbe easily reflected in

Re: [Tutor] get name of calling class at runtime

2009-08-21 Thread Kent Johnson
On Fri, Aug 21, 2009 at 6:58 PM, Alan Gauld wrote: > "Serdar Tumgoren" wrote > >> I'm trying to create a data-retriever class that executes certain SQL >> statements based on the name of a calling class > > This is a really bad "smell" from an OO design point of view. > >> can group a bunch of SQL

Re: [Tutor] get name of calling class at runtime

2009-08-21 Thread Alan Gauld
"Serdar Tumgoren" wrote Meantime, how do I pass "self" to DataSources? Do I literally just pass in the word "self" from inside the calling object? Apologies for the confusion -- I've never used that technique before and it's bending my brain a little:) self is just a reference to the curre

Re: [Tutor] get name of calling class at runtime

2009-08-21 Thread Alan Gauld
"Serdar Tumgoren" wrote I'm trying to create a data-retriever class that executes certain SQL statements based on the name of a calling class This is a really bad "smell" from an OO design point of view. can group a bunch of SQL statements in one place; they're currently scattered all over

Re: [Tutor] get name of calling class at runtime

2009-08-21 Thread Serdar Tumgoren
> You could simplify the code above by passing self to DataSources(). Or > make CallerX inherit from DataSources and use the class attribute > trick we talked about before. Or perhaps you should look into > SQLObject or SQLAlchemy? > The class attribute trick worked nicely. I'll think about how to

Re: [Tutor] get name of calling class at runtime

2009-08-21 Thread Kent Johnson
On Fri, Aug 21, 2009 at 1:53 PM, Serdar Tumgoren wrote: > Hi everyone, > I'm trying to create a data-retriever class that executes certain SQL > statements based on the name of a calling class (I'm doing this so I > can group a bunch of SQL statements in one place; they're currently > scattered all

[Tutor] get name of calling class at runtime

2009-08-21 Thread Serdar Tumgoren
Hi everyone, I'm trying to create a data-retriever class that executes certain SQL statements based on the name of a calling class (I'm doing this so I can group a bunch of SQL statements in one place; they're currently scattered all over the program and it's getting unwieldy). Currently, I'm forc