PyOpenWorm.dataObject module¶
-
class
PyOpenWorm.dataObject.
BaseDataObject
(**kwargs)[source]¶ Bases:
PyOpenWorm.identifier_mixin._IdMixin
,yarom.graphObject.GraphObject
,PyOpenWorm.context.ContextualizableDataUserMixin
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
(self)[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.
-
get_owners
(self, property_class_name)[source]¶ Return a generator of owners along a property pointing to this object
-
graph_pattern
(self, 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
-
save
(self)[source]¶ Write in-memory data to the database. Derived classes should call this to update the store.
-
variable
(self)[source]¶ Must return a
Variable
object that identifies thisGraphObject
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__ method definition, 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
(self, mapper)[source]¶ Called after the module has been loaded. See
PyOpenWorm.mapper.Mapper
-
definition_context
¶ Unlike self.context, definition_context isn’t meant to be overriden
-
query
¶ Stub. Eventually, creates a proxy that changes how some things behave for purposes of querying
-