To all Zopist, (I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.) I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes) I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does: select * from whowhat And I also have one that does: ... select * from whatwhat where classcode = <dtml-sqlvar class_name type=nb> I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory) I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can. Any help to this tormented soul would be greatly appreciated. virtually, Joseph A. Archer IT Coordinator Facilities Management James Madison University archerja@jmu.edu
"Joseph A. Archer" wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... select * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Let's say in Zope you have SQLMethod whowhat and SQLMethod whatwhat. In your external method you should simply be able to do: def countWhoWhat(self): return len(self.whowhat()) def countWhatWhat(self, class): return len(self.whatwhat(class=class)) These should return the result count for each SQLMethod. -- Nick Garcia | ngarcia@codeit.com CodeIt Computing | http://codeit.com
Nick, That worked beautifully! Thank you for you help. virtually, Joseph A. Archer IT Coordinator Facilities Management James Madison University archerja@jmu.edu
"Joseph A. Archer" wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user
id
from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... select * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Let's say in Zope you have SQLMethod whowhat and SQLMethod whatwhat. In your external method you should simply be able to do:
def countWhoWhat(self): return len(self.whowhat())
def countWhatWhat(self, class): return len(self.whatwhat(class=class))
These should return the result count for each SQLMethod.
-- Nick Garcia | ngarcia@codeit.com CodeIt Computing | http://codeit.com
On Fri, 10 Mar 2000, Joseph A. Archer wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... sselect * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Greetings, In my experience, to count the size of an array in ZOPE does not require an external method, simply "_.len(sqlQuery())". I use this myself in a few places. I won't try to guess your reasons for not getting sql to count, but surely it would be by far the simplest way? -- Have a better one, Curtis. <dtml-var standard_work_disclaimer>
Curtis Maloney wrote:
On Fri, 10 Mar 2000, Joseph A. Archer wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... sselect * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Greetings,
In my experience, to count the size of an array in ZOPE does not require an external method, simply "_.len(sqlQuery())". I use this myself in a few places.
I won't try to guess your reasons for not getting sql to count, but surely it would be by far the simplest way?
How about <dtml-in sqlQuery> <dtml-var sequence-lenght> </dtml-in> ? There also some more statistics over the columns. Please refer to the manual for more. Best regards Tino Wildenhain
There is a really good Howto on the zope.org website that explains in detail how to call a ZSqlMethod from an external method, and how to parse out the results afterwards. Follow those instructions and you shouldn't have any problems. Your email spells Extensions as 'Extentions', so make sure that this is not your problem (probably just a typo, I know, but I thought I would check). --sam Tino Wildenhain wrote:
Curtis Maloney wrote:
On Fri, 10 Mar 2000, Joseph A. Archer wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... sselect * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Greetings,
In my experience, to count the size of an array in ZOPE does not require an external method, simply "_.len(sqlQuery())". I use this myself in a few places.
I won't try to guess your reasons for not getting sql to count, but surely it would be by far the simplest way?
How about <dtml-in sqlQuery> <dtml-var sequence-lenght> </dtml-in>
? There also some more statistics over the columns. Please refer to the manual for more.
Best regards Tino Wildenhain
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Sam Gendler Chief Technology Officer - Impossible, Inc. 1222 State St. Suite 250 Santa Barbara CA. 93101 w: 805-560-0508 f: 805-560-0608 c: 805-689-1191 e: sgendler@impossible.com
select count(*) as classcount form whowhat where whatever=whatever ----- Original Message ----- From: Tino Wildenhain <tino@wildenhain.de> To: <zope@zope.org> Sent: Saturday, March 11, 2000 12:08 PM Subject: Re: [Zope] Simple Count Method (even simpler ;) Curtis Maloney wrote:
On Fri, 10 Mar 2000, Joseph A. Archer wrote:
To all Zopist,
(I am new to the list, and yes I am going through the archives for the answer, but haven't found it yet.)
I have a simple two field table in MySQL, "whowhat", that pulls a user id from one table, and a class code from another. (It tells you "who" has "what" classes)
I , being somewhat new to python & Zope, am having the darndest time trying to do a simple external method to do a count of how many times the class "so-and-so" is in the table. (That way, I know how many people have signed-up, and how close I am to the class max.) I have tried different searches. I have an SQL Method that does:
select * from whowhat
And I also have one that does:
... sselect * from whatwhat where classcode = <dtml-sqlvar class_name type=nb>
I've been trying to create an External Method, but I just can't seem to get it to work. (yes, in the Extentions directory)
I need to try to stay away from doing a "select count(classcode)..." in an SQL Method if I can.
Any help to this tormented soul would be greatly appreciated.
Greetings,
In my experience, to count the size of an array in ZOPE does not require an external method, simply "_.len(sqlQuery())". I use this myself in a few places.
I won't try to guess your reasons for not getting sql to count, but surely it would be by far the simplest way?
How about <dtml-in sqlQuery> <dtml-var sequence-lenght> </dtml-in> ? There also some more statistics over the columns. Please refer to the manual for more. Best regards Tino Wildenhain _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (6)
-
Curtis Maloney -
Jim Sanford -
Joseph A. Archer -
Nick Garcia -
Sam Gendler -
Tino Wildenhain