Skip to Content.
Sympa Menu

pcplantdb - [pcplantdb] .3 and other things.

pcplantdb@lists.ibiblio.org

Subject: pcplantdb

List archive

Chronological Thread  
  • From: Chad Knepp <pyg@galatea.org>
  • To: Bear Kaufmann <bear@ursine-design.com>, pcplantdb@lists.ibiblio.org
  • Subject: [pcplantdb] .3 and other things.
  • Date: Sun, 21 Aug 2005 13:11:43 -0500

Bear,

I'm putting this out to the list, because [as usual] much of this is
applicable to others as well.

Bear Kaufmann writes:
> Hi Chad,
>
> Congrats on getting .3 up on dev.
> I don't have a lot of time to work on the project right now or comment,
> and will be away.
> I've played around with a little faceted search system (in PHP).
> I've uploaded it to
> /test/facets.php
> Perhaps you can try it on you're own machine, or pull the db password
> info and include it in a dir accessible to php but not users, and put
> it on dev. It probably takes a bit of DB power to run it, but shows
> faceted search. SQL is GROUPing with varchar fields like pollinators,
> etc, which would probably speed up if these were related by integer id
> to their own table/tag. I may also be looking at the older database and
> schema.

First, notice how messed up pollinators is... bees, insects,
bees/insects, flies/bees. Should have really been its own table to be
fully normalized or constrained to specific values.

More to answer your question, what I'd really like you to do is use
xml-rpc methods.

Here is the php equivilant to my example python xml-rpc
snippet... also my first php ever! Get xmlrpc.inc from
<http://phpxmlrpc.sourceforge.net/>

include 'xmlrpc.inc';
$server = new xmlrpc_client('/cgi-bin/eden_xml-rpc.py',
'dev.permaculture.info');
$message = new xmlrpcmsg('GetComment', array(new xmlrpcval(8000, 'int')));
$result = $server->send($message);
$output = $result->value();
print $output->serialize();

Not sure how to really handle $output as it's supposed to be a
dictionary. Does php have dictionary obects (associative arrays)? If
so something like print $output['Title'] should give you 'Edible uses'.

Anyway, I looked at your facets.php and couldn't really get what sort
of query methods you would need, but if you just tell me what you need
(if it isn't already in the api <http://dev.permaculture.info/api/>)
they will appear to support this. I'm actually pretty sure that
simple methods to do what you want don't exist. You could use the
Search method with family=Blahblah and then GetPlantCulture for the
results, but like I said, I can implement specific methods easily.

There are a lot of good reasons for using the server API via xml-rpc
the most important being security. I am quite confident that the
server cannot be trivially exploited (at least by SQL insertion).
Clients [including the default web browser one] are not trusted and
must provide some form of authentication to any request that is not
read only. Additionally, methods I add now to support facets.php can
later be used by Rich's Java GBI client and so on... based on the idea
that if one client needs them then it will likely be useful to others.
Anyway, tell me what your input will look like, what happens, and what
you want the output to look like and I'll have at it.

The one caution I have is that the xml-rpc stuff is rather untested
and there are some known gotchas that I really need/want to work
through (one of my reasons for wanting to add usda.gov). Most notable
is that some methods return a python None type object which is not
supported by the xml-rpc standard. This could be changed to boolean
False but I'm also not sure how strictly typed languages (like
C/C++/Java and maybe PHP) handle different return values in
xml-rpc... expecting an array and get an int for example. I also
would like to add helpful/reasonable error messages to the server API
(False is not helpful) but probably need to do so in a way that
accommodates the capabilities of strictly typed languages xml-rpc
implementation.

> There's a demo of one result at
> /test/facets.html
> No fancy styling/UI, but you get the idea.
>
> Ciao,
> Bear

--
Chad Knepp
python -c 'import base64;print base64.decodestring("cHlnQGdhbGF0ZWEub3Jn")'



  • [pcplantdb] .3 and other things., Chad Knepp, 08/21/2005

Archive powered by MHonArc 2.6.24.

Top of Page