owmeta_core.dataobject_property module¶
- class owmeta_core.dataobject_property.ContextMappedPropertyClass(name, typ, dct)[source]¶
Bases:
MappedClass
,ContextualizableClass
Meta-class for
Property
.A few attributes can be specified in the class body which affect how the created type is set up: these are defined in the “Attributes” section.
One aspect in particular is important: a
Property
class can represent a single type of property where all instances have the same URI, or aProperty
can represent an a class of RDF properties where the instances have distinct URIs and correspond to instances of the RDF type. An instance of the latter is demonstrated withContainerMembershipProperty
.- Attributes
- rdf_type_class
type
A sub-class of
DataObject
to use as the type. If set, this will be used instead of whatinit_rdf_type_object
would create.- rdf_type
str
orURIRef
The RDF type for the
Property
. Must be defined forinit_rdf_type_object
to actually create the rdf type object- rdf_type_object_deferredbool
If
True
, defer callinginit_rdf_type_object
until it’s explicitly called rather than during normal class init. Useful for cases whereinit_rdf_type_object
uses types that aren’t defined at the point where theProperty
is defined.- rdf_object
RDFProperty
An instance of
RDFProperty
corresponding to this class. If set, this will be used instead of whatinit_rdf_object
would create.- rdf_object_deferredbool
If
True
, defer callinginit_rdf_object
until it is explicitly called rather than during normal class init. Useful for cases whereinit_rdf_object
uses types that aren’t defined at the point where theProperty
is defined.
- rdf_type_class
- contextualize_class_augment(context)[source]¶
For MappedClass, rdf_type and rdf_namespace have special behavior where they can be auto-generated based on the class name and base_namespace. We have to pass through these values to our “proxy” to avoid this behavior
- init_rdf_type_object()[source]¶
Initializes
rdf_type_class
and thereby initializes therdf_type_object
Sometimes, we actually use Property sub-classes as
rdf:Property
classes (e.g.,rdfs:ContainerMembershipProperty
). Therdf_type
attribute has to be defined on this class if we’re going to use it as anrdf:Property
class.
- class owmeta_core.dataobject_property.ExprResultObj(expr, ident)[source]¶
Bases:
object
Object returned by
PropertyExpr.to_objects
. Attributes for whichPropertyExpr.to_dict
has been called can be accessed on the object. For example we can print out theb
properties of instances of a classA
:class B(DataObject): v = DatatypeProperty() class A(DataObject): b = ObjectProperty(value_type=B) a = A().a.expr a.b.v() for anA in a.to_objects(): print(anA.identifier, anA.b)
anA
is anExprResultObj
in the example. The- property rdf_type¶
Allias to rdf_type_property
- class owmeta_core.dataobject_property.Property(*args, **kwargs)[source]¶
Bases:
DataUser
,Contextualizable
A property attached to a
DataObject
.- contextualize_augment(context)[source]¶
For MappedClass, rdf_type and rdf_namespace have special behavior where they can be auto-generated based on the class name and base_namespace. We have to pass through these values to our “proxy” to avoid this behavior
- has_defined_value()[source]¶
Returns
True
if this property has a value in the current context which is either aGraphObject
withdefined
set toTrue
or a literal value
- one()[source]¶
Query for a single value from this property.
For a multi-valued property, the returned value is chosen arbitrarily. If there’s no value returned from the query, then
None
is returned.
- onedef()[source]¶
Return a single defined value set on this property in the current context
This does not execute a query, but returns a value which was set on this property.
- unset(v)¶
Remove a from this property
- property defined_values¶
The “defined” values set on this property in the current context
- property expr¶
An query expression from this property
- property identifier¶
Alias to
link
- lazy = True¶
If
True
, then the property is not attached to an instance until the property is set or queried.
- multiple = False¶
If
True
, then the property will only maintain a single staged value at a time. No effort is made to check how many values are stored in the RDF graph.
- property values¶
Return all values set on this property in the current context
- class owmeta_core.dataobject_property.PropertyExpr(props, triples_provider=None, terms_provider=None, origin=None)[source]¶
Bases:
object
A property expression
- property(property_class)[source]¶
Create a sub-expression with the given property.
Allows for creating expressions with properties that are not necessarily declared for the
value_type
of this expression’s property
- to_dict(multiple=False)[source]¶
Return a
dict
mapping from identifiers for subjects of this expression’s property to the objects for that property.
- to_objects()[source]¶
Returns a list of
ExprResultObj
that allow for retrieving results in a convenient attribute traversal
- to_terms()[source]¶
Return a list of
rdflib.term.Node
terms produced by this expression.
- property rdf_type¶
Short-hand for
rdf_type_property