Sorry to steal the "hard fun" by figuring putting a solution myself: :-)
Try:
http://www.oscomak.net/wiki/test_query_example
For reference:
=====================================================================
print "Content-Type: text/plain\n\n"
from pointrel20030812 import *
electrolytes = Pointrel_allMatches("test", "electrolytes", "types", WILD)
print "Which types of electrolytes have the formula CeO?"
for electrolyte in electrolytes:
print electrolyte, Pointrel_lastMatch("test", electrolyte,
"chemical_formula", WILD) == "CeO"
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/159974
"""
Sometimes it is needed to do set-like operations on database query results,
or simple lists, without the burden of implementing a class for sets, or
importing a separate module. List comprehensions are quick way to do this,
here is a collection of them. Although most of them are banal, let us just
collect them in one place. Also, they are not the fastest, nor the most
elegant, but the quickest to drop into your code if you need a proof of concept.
"""
shortList = [electrolyte for electrolyte in electrolytes if
Pointrel_lastMatch("test", electrolyte, "chemical_formula", WILD) == "CeO"]
print "shortList", shortList
print "======== Funky self-referential stuff to print the code follows :-)
=============="
theCode = Pointrel_lastMatch("test", "test_query_example", "code", WILD)
print "the code for this page is:"
print theCode
======================================================================
More on the downsides of this approach later.
--Paul Fernhout
From: http://www.imdb.com/title/tt0076759/quotes :-)
"Governor Tarkin (to Princess Leia): You're far too trusting. Dantooine is
too remote to make an effective demonstration - but don't worry; we will
deal with your rebel friends soon enough."
The big problem with the current Pointrel/oscomak approach on that server on
the wild internet in the long term is that anyone who can add Python code
(like what I added for Mike's query) can also probably misuse the server in
various ways (send SPAM or worse) via loading arbitrary Python libraries.
That's why I have not made the way to add stuff public yet. A more
restricted domain specific language like SPARQL for data lookup probably
can't be misused as badly, especially if *anybody* could edit the semantic wiki.
There are various other tradeoffs. If the server was running in Java/Jython
instead of plain Python I might be able to sandbox that access to library
functions more easily. But that requires a dedicated server instead of
simple cgi given JVM startup time. And that is a big ongoing commitment
(about $4000 a year at Pair Networks for the minimal dedicated machine,
versus about $300 a year for the shared-server account I just signed up for.)
But nothing will ever 100% make security issues go away. Remember also, good
security is never an "add on". It must be woven throughout the entire
system. Even (or especially) the people side.
I know someone who runs a computer network for schools and it seems at least
once every few years the Secret Service shows up over some stupid
threatening email some kid sends you can guess where. So, there are all
sorts of ways people can make trouble. This is one reason I keep Java
applets off by default, because applets can send email.
By the way -- here is a sci-fi novel that includes a computer that takes
over the universe just by sending letters and checks (today it would be
email and paypal. :-)
http://en.wikipedia.org/wiki/The_Great_Time_Machine_Hoax
So, computers don't need robot slaves when they operate in a capitalist
economy. There are other sci-fi stories with similar themes, but they are
not funny like that one. :-)
I don't need to worry quite as much about server misuse if the Python query
code is run on the client side. That's one reason I ultimately prefer a
distributed solution.
Plus you can assume anything you put through Google (or eventually maybe
OSCOMAK) is monitored by the CIA and NSA etc. See:
"Google = NSA 2.0?"
http://uneasysilence.com/archive/2006/10/8041/
"Spooks on board at Google"
http://www.google-watch.org/jobad.html
And as is likely with with Wikipedia, either directly or by deep packet
analysis, you can expect the government would be looking over your shoulder
when you use a web version of OSCOMAK (privacy in search and use is always a
good reason to download data in big chunks :-).
--Paul Fernhout
I don't understand at all what you're saying here -- are you really
running all of the code on the server side? Have you considered that
you could dump code to the user to run? That's what the skdb is
intended to do, so that users can work with whatever libraries they
think are useful. There'd be a project wide pgp key to use with this as
well, and an approval process. Code would be dumped on a wiki + git +
repo.
http://fennetic.net/autogenix/ in particular. (still working on it)
- Bryan
________________________________________
http://heybryan.org/
I'm trying to accommodate those with interests in web systems (and also the
casual user who would not download anything).
Maybe I am (as usual) trying to do too much at once, and I am being too
ambitious in the short term. :-(
--Paul Fernhout
But not everybody has to rerun the simulations on the server side. If
anything, KISS -- run nightly cron jobs or something to redo the
simulations if you worry that fundamental physics has changed or
something.