# Redland RDF Application Framework - Python API Reference

RDF (version 0.9, $Date: 2005/07/06 09:38:37 $) | index

Modules
`` |  |
Redland | string | sys |

Classes
`` |  | exceptions.Exception RedlandError NodeTypeError RedlandWarning StreamIter __builtin__.object Iterator IteratorIter IteratorWithContextIter Model NS Node Parser Serializer Statement Storage FileStorage HashStorage MemoryStorage Stream StreamWithContextIter Uri World
class FileStorage(Storage)
`` | `Redland file Storage class import RDF s=RDF.FileStorage("abc") Class of file Storage with required name, additional options.`
| Method resolution order: FileStorage Storage __builtin__.object Methods defined here: __init__(self, mem_name, options_string='') Data and non-method functions defined here: __doc__ = 'Redland file Storage class\n\n import RDF\n ...torage with required name, additional options.\n ' __module__ = 'RDF' Methods inherited from Storage: __del__(self) Data and non-method functions inherited from Storage: __dict__ = <dict-proxy object> __weakref__ = <member '__weakref__' of 'Storage' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class HashStorage(Storage)
`` | `Redland Hashed Storage class import RDF h1=RDF.HashStorage("abc", options="hash-type='memory'") Class of hashed Storage for a particular type of hash (typically hash-type is "memory" or "bdb") and any other options.`
| Method resolution order: HashStorage Storage __builtin__.object Methods defined here: __init__(self, hash_name, options) Data and non-method functions defined here: __doc__ = 'Redland Hashed Storage class\n\n import RDF\n ...e is "memory" or "bdb") and any other options.\n ' __module__ = 'RDF' Methods inherited from Storage: __del__(self) Data and non-method functions inherited from Storage: __dict__ = <dict-proxy object> __weakref__ = <member '__weakref__' of 'Storage' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Iterator(__builtin__.object)
`` | `Redland Node Iterator class A class for iterating over a sequence of Node s such as those returned from a Model query. Some methods return Iterator s or Python sequences. If this is used, it works as follows: iterator=model.get_targets_iterator(source, arc) while not iterator.end(): # get the current Node node=iterator.current() # do something with it # (it is shared; you must copy it you want to keep it) ... iterator.next() iterator=None`
| Methods defined here: __del__(self) __init__(self, object, creator1=None, creator2=None, creator3=None) `Create an RDF Iterator (constructor).` __iter__(self) context(self) `Return the context Node of the current object on the Iterator` current(self) `Return the current object on the Iterator` end(self) `Return true if the iterator is exhausted` have_elements(self) next(self) `Move to the next object on the Iterator` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Node Iterator class\n\n A class for it... iterator.next()\n iterator=None\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Iterator' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class IteratorIter(__builtin__.object)
`` |
| Methods defined here: __init__(self, iterator) __iter__(self) next(self) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = None __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'IteratorIter' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class IteratorWithContextIter(__builtin__.object)
`` |
| Methods defined here: __init__(self, iterator) __iter__(self) next(self) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = None __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'IteratorWithContextIter' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class MemoryStorage(Storage)
`` | `Redland memory Storage class import RDF h1=RDF.MemoryStorage() h1=RDF.MemoryStorage("abc") h2=RDF.MemoryStorage("abc", "write='no'") Class of memory Storage with optional name, additional options.`
| Method resolution order: MemoryStorage Storage __builtin__.object Methods defined here: __init__(self, mem_name='', options_string='') Data and non-method functions defined here: __doc__ = 'Redland memory Storage class\n\n import RDF\n ...torage with optional name, additional options.\n ' __module__ = 'RDF' Methods inherited from Storage: __del__(self) Data and non-method functions inherited from Storage: __dict__ = <dict-proxy object> __weakref__ = <member '__weakref__' of 'Storage' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Model(__builtin__.object)
`` | `Redland Graph class import RDF model = RDF.Model(storage) The main interface to the Redland RDF graph (formed from triples, or RDF statements). There are many methods for adding, removing, querying statements and serializing them to/from syntaxes using the Serializer or Parser classes. Models can also be used as Python sequences to give every triple in the model: for statement in model: print statement Models have other aspects of sequence types. The following also works: if statement in model: # do whatever if (statement, context) in model: # do whatever del model[statement] # remove statement from model del model[statement, context] # ditto for context-aware model model.append(statement) # append a statement model.append(statement, context) # append statement with context num_items = len(model) # get number of statements in the model # works only with countable storages`
| Methods defined here: __contains__(self, arg) __del__(self) __delitem__(self, arg) __init__(self, storage=None, **args) `Create an RDF Model (constructor). Create a Model from an existing Storage (most common use). Optional parameters: options_string - A string of options for the Model options_hash - A Hash of options for the Model m1 = RDF.Model(s1) m1 = RDF.Model(storage = s1) Copy an existing model m1, copying the underlying Storage of m1 m2 = RDF.Model(model = m1) Create a model using an in-memory storage. m3 = RDF.Model()` __iter__(self) __len__(self) add(self, subject, predicate, object) `Add the statement (subject,predicate,object) to the model. DEPRECATED. Use Model.append(Statement(s,p,o)) instead.` add_statement(self, statement, context=None) `Add the Statement to the Model with optional context Node. For Python idiom you should use Model.append() instead, which does the same thing.` add_statements(self, statement_stream, context=None) `Add the Stream of Statements to the Model with the optional context Node` add_typed_literal_statement(self, subject, predicate, string, xml_language=None, datatype=None) `Add the Statement (subject,predicate, typed literal) to the Model where the typed literal is constructed from the literal string, optional XML language and optional datatype URI. DEPRECATED. Use Model.append(Statement(s,p,o)) instead.` append(self, statement, context=None) `Append a Statement to the Model, with optional context Node. model.append(Statement(s, p, o)` arcs = get_predicates(self, source, target) as_stream(self, context=None) `Return the Model as a Stream of Statements. No need to use this explicitly, instead do: for statement in model: # process statement` as_stream_context(self, context=None) `Return the Model as a Stream of (statement, context) tuples. for (s, c) in model.as_stream_context(): # do whatever Specify the optional argument context if you want to hardwire the stream's context.` contains_statement(self, statement) `Return true if the Statement is in the Model` contains_statement_context(self, statement, context) `Return true if the Statement is in the Model with the specified context. Note that the implementation is pretty inefficient.` context_remove_statements = remove_statements_with_context(self, context) find_statements(self, statement, context=None) `Return a Stream of Statements matching the given Statement -- any nodes with value None of the statement match any Node in the Model. Specify the optional argument context if you want to search only in one context. qs = RDF.Statement(subject = None, predicate = RDF.Node(uri_string = "http://example.com/pred"), object = None) for statement in model.find_statements(qs): # do whatever` find_statements_context(self, statement) `Return a Stream of Statements with context, matching the given Statement -- any nodes with value None of the statement match any Node in the Model. qs = RDF.Statement(subject = None, predicate = RDF.Node(uri_string = "http://example.com/pred"), object = None) for (statement, context) in model.find_statements_context(qs): # do whatever` get_arc = get_predicate(self, source, target) get_arcs = get_predicates(self, source, target) get_contexts(self) `Return a sequence of context Nodes in the Model.` get_feature(self, uri) `Return the Node value of Model feature URI uri` get_predicate(self, source, target) `Return one Node in the Model matching (source, ?, target). The source can be a Node or Uri, the target a Node, Uri or string.` get_predicates(self, source, target) `Return a sequence of Nodes that are the predicates of Statements in the Model matching (source, ?, target). Instead of specifying a Node for source, you can shortcut with a Uri, and with a Uri or string for target. e.g. model.get_predicates(Uri("http://example.com/me"), "Fred")` get_predicates_context(self, source, target) `As for Model.get_predicates but returns a list of (statement, context) tuples.` get_source(self, predicate, target) `Return one Node in the Model matching (?, predicate, target). The predicate can be a Node or Uri, the target a Node, Uri or string.` get_sources(self, predicate, target) `Return a sequence of Node s that are the source of Statements in the Model matching (?, predicate, target). Instead of specifying a Node for predicate, you can shortcut with a Uri, and with a Uri or string for target. e.g. model.get_sources(Uri("http://example.com/name"), "Fred")` get_sources_context(self, predicate, target) `As for Model.get_sources but returns a list of (statement, context) tuples.` get_target(self, source, predicate) `Return one Node in the Model matching (source, predicate, ?). The source and predicate can be a Node or Uri.` get_targets(self, source, predicate) `Return a sequence of Nodes that are the targets of Statements in the Model matching (source, predicate, ?). Instead of specifying a Node for source or predicate, you can shortcut with a Uri. e.g. model.get_targets(Uri("http://example.com/me"), prednode)` get_targets_context(self, source, predicate) `As for Model.get_targets but returns a list of (statement, context) tuples.` predicates = get_predicates(self, source, target) remove_statement(self, statement, context=None) `Remove the Statement from the Model with the optional context Node. This is used by the __delitem__ method. Preferred way of removing a Statement is: del model[statement] del model[statement, context]` remove_statements_with_context(self, context) `Remove all Statements from the Model with the given context Node` serialise = as_stream(self, context=None) set_feature(self, uri, value) `Set the Node value of Model feature URI uri.` size(self) `Return the size of the Model in number of statements. Returns a value < 0 if number of statements not countable.` sources = get_sources(self, predicate, target) sync(self) `Synchronise the Model with the underlying Storage.` targets = get_targets(self, source, predicate) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Graph class\n\n import RDF\n model = ... # works only with countable storages\n \n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Model' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class NS(__builtin__.object)
`` | `Redland Namespace Utility Class import RDF nspace = RDF.NS("http://example.com/foo#") # creates an RDF Node for http://example.com/foo#blah node1 = nspace.blah # creates an RDF Node for http://example.com/foo#blah node2 = nspace['blah'] A class for generating RDF Nodes with URIs from the same vocabulary (such as XML Namespace) varying only in the appended name in the vocabulary. Each node returned is a pointer to a shared copy.`
| Methods defined here: __getattr__(self, localName) __getitem__(self, localName) __init__(self, prefix) node(self, localName) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = ' Redland Namespace Utility Class\n\n import RDF\n ... node returned is a pointer to a shared copy.\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'NS' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Node(__builtin__.object)
`` | `Redland Node (RDF Resource, Property, Literal) Class import RDF node1=RDF.Node() node2=RDF.Node(RDF.Uri("http://example.com/")) node3=RDF.Node("Hello, World!") node4=RDF.Node(uri_string="http://example.com/") node5=RDF.Node(literal="<tag>content</tag>", is_wf_xml=1) node6=RDF.Node(blank="abc") node7=RDF.Node(node5) ... print node2 if node7.is_resource(): print "Resource with URI", node7.uri if node5.is_blank(): print "Resource with blank node name ", node5.blank_identifier`
| Methods defined here: __del__(self) `Free an RDF Node (destructor).` __eq__(self, other) `Equality of an RDF Node compared to another RDF Node.` __hash__(self) __init__(self, arg=None, **args) `Create an RDF Node (constructor). Resource or Property node creation: n1 = Node(Uri("http://example.com/foo")) String literal node creation (see below for more complex ways of building literals.) n2 = Node("foo") Node copying: n3 = Node(n1) Or create a new RDF Node using the following named parameters: uri_string - create a resource node from a string URI uri - create a resource node from a URI object literal - create a literal node from a literal string datatype - the datatype URI is_wf_xml - the literal is XML (alternative to datatype) xml_language - the literal XML language blank - create a resource node from with a blank node identiifer node - copy a node` __ne__(self, other) `Inequality of an RDF Node compared to another RDF Node.` __str__(self) `Get a string representation of an RDF Node.` _get_blank_identifier(self) _get_literal_value(self) _get_type(self) _get_uri(self) is_blank(self) `Return true if node is a blank node` is_literal(self) `Return true if node is a literal` is_resource(self) `Return true if node is a resource with a URI` Properties defined here: blank_identifier `The node identifier of a blank node` blank_identifier getter = _get_blank_identifier(self) literal_value `A dictionary containing the value of the node literal` literal_value getter = _get_literal_value(self) type `The node type, an integer` type getter = _get_type(self) uri `The URI of a resource node` uri getter = _get_uri(self) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Node (RDF Resource, Property, Literal) C...ith blank node name ", node5.blank_identifier\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Node' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class NodeTypeError(RedlandError)
`` |
| Method resolution order: NodeTypeError RedlandError exceptions.Exception Data and non-method functions defined here: __doc__ = None __module__ = 'RDF' Methods inherited from RedlandError: __init__(self, value) __str__(self) Methods inherited from exceptions.Exception: __getitem__(...)
class Parser(__builtin__.object)
`` | `Redland Syntax Parser Class import RDF parser1=RDF.Parser() parser2=RDF.Parser(name="rdfxml") parser3=RDF.Parser(mime_type="application/rdf+xml") stream=parser2.parse_as_stream("file://dir/file.rdf") parser3.parse_into_model(model, "file://dir/file.rdf", "http://example.org/") The default parser type if not given explicitly is raptor, for the RDF/XML syntax.`
| Methods defined here: __del__(self) __init__(self, name='raptor', mime_type='application/rdf+xml', uri=None) `Create an RDF Parser (constructor). Create a new RDF Parser for a particular syntax. The parser is chosen by the fields given to the constructor, all of which are optional. When any are given, they must all match. name - parser name (currently "raptor" and "ntriples") mime_type - currently "application/rdf+xml" (default) or "text/plain" (ntriples) uri - URI identifying the syntax currently only "http://www.w3.org/TR/rdf-testcases/#ntriples"` get_feature(self, uri) `Return the Node value of Parser feature URI uri` parse_as_stream(self, uri, base_uri=None) `"Return a Stream of Statements from parsing the content at (file: only at present) URI, for the optional base URI or None if the parsing fails. for statement in parser.parse_as_stream(""): print statement` parse_into_model(self, model, uri, base_uri=None) `"Parse into the Model model from the content at (file: only at present) URI, for the optional base URI. parser.parse_into_model(model, "file:./foo.rdf", "http://example.com/foo.rdf")` parse_string_as_stream(self, string, base_uri) `"Return a Stream of Statements from parsing the content in string with the required base URI or None if the parsing fails. for statement in parser.parse_string_as_stream(rdfstring): print statement` parse_string_into_model(self, model, string, base_uri) `"Parse into the Model model from the content ain string with the required base URI` set_feature(self, uri, value) `Set the Node value of Parser feature URI uri.` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Syntax Parser Class\n\n import RDF\n pars...xplicitly is raptor,\n for the RDF/XML syntax.\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Parser' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class RedlandError(exceptions.Exception)
`` | `Redland Runtime errors`
| Methods defined here: __init__(self, value) __str__(self) Data and non-method functions defined here: __doc__ = 'Redland Runtime errors' __module__ = 'RDF' Methods inherited from exceptions.Exception: __getitem__(...)
class RedlandWarning(RedlandError)
`` |
| Method resolution order: RedlandWarning RedlandError exceptions.Exception Data and non-method functions defined here: __doc__ = None __module__ = 'RDF' Methods inherited from RedlandError: __init__(self, value) __str__(self) Methods inherited from exceptions.Exception: __getitem__(...)
class Serializer(__builtin__.object)
`` | `Redland Syntax Serializer Class import RDF ser1=RDF.Serializer(mime_type="application/rdf+xml") A class for turning a Model into a syntax serialization (at present only to local files).`
| Methods defined here: __del__(self) __init__(self, name='', mime_type='application/rdf+xml', uri=None) `Create an RDF Serializer (constructor).` get_feature(self, uri) `Return the value of Serializer feature URI uri` serialize_model_to_file(self, name, model, base_uri=None) `Serialize to filename name the Model model using the optional base URI.` set_feature(self, uri, value) `Set the value of Serializer feature URI uri.` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = ' Redland Syntax Serializer Class\n\n import RDF\n ...ialization (at present\n only to local files).\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Serializer' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Statement(__builtin__.object)
`` | `Redland Statement (triple) class. The main means of manipulating statements is by the subject, predicate and object properties. import RDF statement1 = RDF.Statement(node1, node2, node3) statement2 = RDF.Statement(statement = statement1) if statement2.subject.is_resource(): print "statement2 subject is URI ",statement2.subject.uri statement.object = Node("hello, world")`
| Methods defined here: __del__(self) __init__(self, subject=None, predicate=None, object=None, **args) `Constructor for Statement. Create a Statement from three Node objects. s1 = RDF.Statement(subjnode, prednode, objnode) A Node argument can be replaced with Uri or string to shortcut Node creation. s2 = RDF.Statement(Uri(""), Uri(""), "baz") Copy an existing Statement s1. s3 = RDF.Statement(statement=s1)` __str__(self) _get_object(self) _get_predicate(self) _get_subject(self) _set_object(self, value) _set_predicate(self, value) _set_subject(self, value) _wrap_node(self, rednode) Properties defined here: object `The object node of the statement.` object getter = _get_object(self) object setter = _set_object(self, value) predicate `The predicate node of the statement.` predicate getter = _get_predicate(self) predicate setter = _set_predicate(self, value) subject `The subject node of the statement.` subject getter = _get_subject(self) subject setter = _set_subject(self, value) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Statement (triple) class. The main mean...i\n\n statement.object = Node("hello, world")\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Statement' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Storage(__builtin__.object)
`` | `Redland Statement Storage class import RDF storage=RDF.Storage(storage_name="memory") The Redland abstraction for storing RDF graphs as Statements. There are no user methods (can only be constructed). You should normally use a specialized class such as MemoryStorage or HashStorage in preference to this class.`
| Methods defined here: __del__(self) __init__(self, **args) `Create an RDF Storage (constructor). Create a new RDF Storage using any of these forms s1=RDF.Storage(storage_name="name") Create a Storage with the given name. Currently the built in storages are "memory" and "hashes". "hashes" takes extra arguments passed in the field options_string, some of which are required: options_string="hash-type='memory',new='yes',write='yes'" hash-type - required and can be the name of any Hash type supported. 'memory' is always present, and 'bdb' is available when BerkeleyDB is compiled in. new - optional and takes a boolean value (default false) If true, it allows updating of an existing Storage write - optional and takes a boolean value (default true) If false, the Storage is opened read-only and for file-based Storages or those with locks, may be shared-read. The other form is: s2=RDF.Storage(storage=s1) Copy an existing Storage s1.` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Statement Storage class\n\n import RDF...or\n HashStorage in preference to this class.\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Storage' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Stream(__builtin__.object)
`` | `Redland Statement Stream class A class encapsulating a sequence of Statements, such as those returned from a Model query. Can be used as a Python sequence. stream = model.find_statements(query_statement) for statement in stream: # do whatever with 'statement' # note it is shared and will go out of scope, so you must # copy it if you want it to stay around You should not normally find yourself needing to use this class explicitly.`
| Methods defined here: __del__(self) __init__(self, object, creator) `Create an RDF Stream (constructor).` __iter__(self) context(self) `Return the context Node of the current object on the Stream` context_iter(self) `Return an iterator over this stream that returns (stream, context) tuples each time it is iterated. DEPRECATED. Instead use the context-aware method appropriate, e.g. Model.find_statements_context() or Model.as_stream_context()` current(self) `Return the current Statement on the Stream` end(self) `Return true if the stream is exhausted` next(self) `Move to the next Statement on the Stream` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Statement Stream class\n\n A class enc...lf needing to use this\n class explicitly.\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Stream' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class StreamIter
`` |
| Methods defined here: __init__(self, stream) __iter__(self) next(self) Data and non-method functions defined here: __doc__ = None __module__ = 'RDF'
class StreamWithContextIter(__builtin__.object)
`` |
| Methods defined here: __init__(self, stream) __iter__(self) next(self) Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = None __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'StreamWithContextIter' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class Uri(__builtin__.object)
`` | `Redland URI Class import RDF uri1 = RDF.Uri("http://example.com/") uri2 = RDF.Uri(uri1)`
| Methods defined here: __del__(self) __eq__(self, other) `Equality of RDF URI to another RDF URI.` __hash__(self) __init__(self, arg=None, **args) `Create an RDF URI (constructor). Creates a new RDF URI from either of the following forms: uri1 = RDF.Uri("http://example.com/") Create a URI from the given string. uri2 = RDF.Uri(uri1) Copy an existing URI uri1.` __ne__(self, other) `Inequality of RDF URI to another RDF URI.` __str__(self) `Get a string representation of an RDF URI.` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland URI Class\n\n import RDF\n uri1 = RDF.Uri("http://example.com/")\n uri2 = RDF.Uri(uri1)\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'Uri' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`
class World(__builtin__.object)
`` | `Redland Initialisation class. There are no user methods (can only be constructed).`
| Methods defined here: __del__(self) `Destroy RDF World object (destructor).` __init__(self, digest_name='', uri_hash=None) `Create new RDF World object (constructor)` Data and non-method functions defined here: __dict__ = <dict-proxy object> __doc__ = 'Redland Initialisation class.\n\n There are no user methods (can only be constructed).\n\n ' __module__ = 'RDF' __weakref__ = <member '__weakref__' of 'World' objects> Methods inherited from __builtin__.object: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __hash__(...) `x.__hash__() <==> hash(x)` __reduce__(...) `helper for pickle` __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __str__(...) `x.__str__() <==> str(x)` Data and non-method functions inherited from __builtin__.object: __class__ = <type 'type'> __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T`

Functions
`` |  | debug(value=None) `Get/set Redland debugging output status. RDF.debug (1) # enable debugging if RDF.debug(): # test for debug mode` message_handler(type, message) `Internal message dispatcher from Redland to python` node_type(name) `Return the Redland node type of a node name` node_type_name(num) `Return the name of a Redland node type` set_message_handler(handler) `Set the Redland message handler for Python. It takes a single function that takes (integer, string) arguments.`

Data
`` |  | __all__ = ['Node', 'Statement', 'Model', 'Iterator', 'Serializer', 'Stream', 'Storage', 'MemoryStorage', 'HashStorage', 'Uri', 'Parser', 'NS', 'debug'] __author__ = 'Dave Beckett - http://purl.org/net/dajobe, Edd D...sefulinc.com> and Matt Biddulph <mb@picdiary.com>' __date__ = '$Date: 2005/07/06 09:38:37 $' __file__ = './RDF.pyc' __name__ = 'RDF' __version__ = '0.9' _debug = 0 _node_types = {'NODE_TYPE_BLANK': 4, 'NODE_TYPE_LITERAL': 2, 'NODE_TYPE_RESOURCE': 1, 'NODE_TYPE_UNKNOWN': 0} _world = <RDF.World object> generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)

Author
`` |  | Dave Beckett - http://purl.org/net/dajobe, Edd Dumbill <edd@usefulinc.com> and Matt Biddulph <mb@picdiary.com>

Copyright 2000-2004 Dave Beckett, Institute for Learning and Research Technology, University of Bristol