PyOpenWorm.dataObject module

class PyOpenWorm.dataObject.BaseDataObject(**kwargs)[source]

Bases: PyOpenWorm.identifier_mixin._IdMixin, yarom.graphObject.GraphObject, PyOpenWorm.data.DataUser, PyOpenWorm.contextualize.Contextualizable

An object backed by the database

Attributes:
rdf_type : rdflib.term.URIRef

The RDF type URI for objects of this type

rdf_namespace : rdflib.namespace.Namespace

The rdflib namespace (prefix for URIs) for objects from this class

properties : list of Property

Properties belonging to this object

owner_properties : list of Property

Properties belonging to parents of this object

classmethod DatatypeProperty(*args, **kwargs)[source]

Attach a, possibly new, property to this class that has a simple type (string,number,etc) for its values

Parameters:
linkName : string

The name of this property.

owner : PyOpenWorm.dataObject.BaseDataObject

The name of this property.

classmethod ObjectProperty(*args, **kwargs)[source]

Attach a, possibly new, property to this class that has a complex BaseDataObject for its values

Parameters:
linkName : string

The name of this property.

owner : PyOpenWorm.dataObject.BaseDataObject

The name of this property.

value_type : type

The type of BaseDataObject for values of this property

classmethod UnionProperty(*args, **kwargs)[source]

Attach a, possibly new, property to this class that has a simple type (string,number,etc) or BaseDataObject for its values

Parameters:
linkName : string

The name of this property.

owner : PyOpenWorm.dataObject.BaseDataObject

The name of this property.

clear_po_cache()[source]

Clear the property-object cache for this object.

This cache is maintained by and shared by the properties of this object. It isn’t necessary to clear this cache manually unless you modify the RDFLib graph indirectly (e.g., through the store) at runtime.

decontextualize()[source]

Return the object with all contexts removed

get_owners(property_class_name)[source]

Return a generator of owners along a property pointing to this object

graph_pattern(shorten=False, show_namespaces=True, **kwargs)[source]

Get the graph pattern for this object.

It should be as simple as converting the result of triples() into a BGP

Parameters:
shorten : bool

Indicates whether to shorten the URLs with the namespace manager attached to the self

id_is_variable()[source]

Is the identifier a variable?

retract()[source]

Remove this object from the data store.

save()[source]

Write in-memory data to the database. Derived classes should call this to update the store.

variable()[source]

Must return a Variable object that identifies this GraphObject in queries.

The variable can be randomly generated when the object is created and stored in the object.

po_cache = None

A cache of property URIs and values. Used by RealSimpleProperty

properties_are_init_args = True

If true, then properties defined in the class body can be passed as keyword arguments to __init__. For example:

>>> class A(DataObject):
...     p = DatatypeProperty()

>>> A(p=5)

If the arguments are written explicitly into the __init__, then no special processing is done.

class PyOpenWorm.dataObject.ContextMappedClass(name, bases, dct)[source]

Bases: yarom.mappedClass.MappedClass, PyOpenWorm.contextualize.ContextualizableClass

after_mapper_module_load(mapper)[source]

Called after all classes in a module have been loaded

definition_context

Unlike self.context, definition_context isn’t meant to be overriden

class PyOpenWorm.dataObject.DataObject(**kwargs)[source]

Bases: PyOpenWorm.dataObject.BaseDataObject