Rope part 5 (and first pre pre prerelease)ΒΆ

Tags: rdf, plone

So, I've put in an evening's worth of work and got everything working! This doesn't mean a lot is working, it's very, very basic. You can download rope from sourceforge, but beware of the truthful anouncement:

First pre-pre-pre-release of rope. You get a mutilated rdflib instance in zope with a little bit of management screen around it. Nothing useful really. Now on with the log of what I did to get it working. (See the rest of the stories for the rest of the narrative).

Removing new-style classes, part 2

Properties

Reading the documentation made it clear that the special property mechanism only works with new-style classes. Those have to go, too. A "grep" showed that there are five properties in three files:

    AbstractInformationStore.py:    context = property(__get_context,
       __set_context)
    XMLRDFHandler.py:    current = property(get_current)
    XMLRDFHandler.py:    next = property(get_next)
    XMLRDFHandler.py:    parent = property(get_parent)
    ZBacked.py:    indices = property(__get_indices)

As an aside: how would I search for information like this when not using linux? Just using "grep" like this isn't something I can remember doing in my dos/windows days. Now, I haven't ever installed anything older than windows 3.1 on my primary partition, but then again. I cannot imagine doing work like this in one GUI. Give me the commandline and emacs all the time.

Ok, back to work. I re-did all properties by just calling their getter/setter directly instead of having the property mechanism deal with it automatically.

Merging ZInformationStore and RopeProduct

Now, as ExtensionClass isn't longer any problem (at least not on first sight), nothing prevents me from removing store = ZInformationStore() from RopeProduct and subclassing RopeProduct directly from ZInformationstore instead. Done. Removing the few occurences of self.store. Testing it from the commandline (python2.3 rope.py): everything still seems to work. Now back to the browser and trying to add a triple in there...:

    Error Type: UnpickleableError
    Error Value: Cannot pickle  objects

Ok, this means there is still work to do. Treads are used by loadsave.py for auto-reloading rdf files. Perhaps some more new-style classes to clean up, perhaps that tread-stuff needs cleaning out. Check: no new-style classes in there.

Checking loadsave.py and grepping a bit made things obvious. Locking was only used in save(), which didn't actually do anything and wasn't used anywhere. So commenting out this part (and the offending line in __init__() that registered a lock object) solved the problem.

Succes!!!!

Reloading the existing RopeProduct instance in zope didn't work out. index_html complained about a missing index. The problem here is that, when reloading from a pickle or a ZODB database, a class's __init__() isn't called upon re-building the object. And that's just the place where the index is generated... So I created a new instance.

  1. Storing a namespace.
  2. Storing a triple.
  3. Closing down zope.
  4. Starting zope again.
  5. Visit the object.
  6. The triple is still there.
  7. The triple is still there.
  8. Yes! The triple is actually still there!
  9. Hurrying downstairs to get a good glass of well-deserved whiskey.

The first real succes is there. But, to be honest, it's all still a big hack. No unit tests (and that feels really dirty to me). But then, rdflib hasn't got them either. The unit tests that would make me trust this rope product would for the most part be rdflib unit tests. There is a body of tests for rdf itself (which rdflib apparently passes), so they could perhaps be auto-converted to rdflib unit tests. I don't feel a real urge to write all those unit tests for rdflib right now, but in the end it's a job that needs doing before I really trust it.

It's also still a big mess. When you add the product in zope's management interface it doesn't jump automatically to the index_html screen, but doesn't return a thing, effectively letting the user wait forever for a response... The layout of the screens is rotten. A lot is missing. And you cannot load an existing rdf file yet.

An open source maxim is release quick, release often. So I have to buckle down and get a first version out. So: cleaning up the worst of it all.

Cleaning up

Redirecting to index_html upon product creation turned out to be simple by including REQUEST=None in the product add method:

    def addRope(dispatcher, id, REQUEST=None):
 """
 Create a new Rope and add it to myself.
 """
 rope = RopeProduct(id)
 dispatcher.Destination()._setObject(id,rope)
 REQUEST.response.redirect('../../%s/index_html'%id)
 # The last bit (../..) is a bit of a hack, but I couldn't find
 # the real solution that quick.

Further I splitted the namespace add form from the namespace view template. And I added links to "add/view namespace(s) and add triples" to index_html. This way the product is at least remotely useable. Not that it does anything useful yet, but ok.

Most important things to add now:

  • Load file from URL or from a form.
  • Add a simple query interface.
  • Add queries you can store (whether it is a local list of queries or actual query objects doesn't really matter now).

Now I'm packaging it all in a .tgz and I'll upload it as the 0.01 version :-)

 
vanrees.org logo

Reinout van Rees

My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):