[redland] Redland Contexts and Iterator support for Python API

Dave Beckett dave.beckett at bristol.ac.uk
Wed Aug 7 20:24:00 BST 2002


Edd tried to reply direct but YahooGroups refused, I've copied his
reply below.

I should note what I've been working on support for contexts more
deeply in Redland; this allows you to give statements a URIref.

Read a little more here:
http://www.redland.opensource.ac.uk/notes/contexts.html

I've already got the iterators changed to the new model, so now
they work like this in pseudo code:

OLD (0.9.11 and earlier):
  while !iterator.is_end
    { x=iterator.get_next(); do stuff with x }

NEW (0.9.12 in development):
  while !iterator.is_end
    { x=iterator.get(); do stuff with x; iterator.next() }

(streams will work similarly)

When contexts are done you will be able do iterator.get_context() or
stream.get_context() and possibly other methods off a redland
iterator/stream.

I wonder how that affects things?

In python you could change this to return pairs of (object, context object).
However I'd prefer not to always do that, since you might not want
the context and it might mean more work (but if I've planned it
right, it should be pretty cheap).

Dave

---------------------------------------------------------------------------

>From: Edd Dumbill <edd at usefulinc.com>
>To: redland at yahoogroups.com
>Subject: Re: [redland] Iterator support for Python API
>Date: 07 Aug 2002 18:35:49 +0100

On Wed, 2002-08-07 at 17:05, Andrew Kuchling wrote:
> On Wed, Aug 07, 2002 at 04:41:09PM +0100, Dave Beckett wrote:
> >You mean python generators, not iterators?
> 
> Iterators are objects that support a .next() method, and raise the
> StopIteration exception when they're done.  Generators make it easier
> to write certain iterators, but you don't need to use the 'yield'
> keyword to write an iterator, and in fact the patch doesn't use it.
> 
> Edd, I've got a patch ready if you want to see it.

Sure, why not send it along.  I'm about to head out for vacation for
most of this month, so I won't personally be doing anything with it
until September (I had meant to finish off various other changes and
tidyings to the Python API too, but I seem to be lacking in time.)  I
think the addition of contexts to the API might have some bearing too on
changes to iterators

-- Edd

-- 
Edd Dumbill ----| phone: +44 1904 427740 fax: +44 8709 909625 |-----
 | Managing Editor, XML.com, XMLhack.com  --  Chair, XML Europe 2002
 | I PGP sign my email; more info at http://heddley.com/edd/pgp.html

-----------------------------------------------------------------------------







More information about the redland-dev mailing list