[Zope] Simple Count Method (even simpler ;)

Sam Gendler sgendler@impossible.com
Sat, 11 Mar 2000 11:19:26 -0800


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