Library Reference

Note

This page is work in progress...

The storage module

For examples of using this module see Getting Started with ptypes.

class ptypes.storage.PStructure

Bases: ptypes.storage.AssignedByReference

A structure is like a mutable named tuple.

Structures are usable as hash keys (they are hashable), but prepare for surprises if you do so and change the contents of the structure after initialisation.

Structures lack the ‘greater than / less than’ relational operators, so they are not usable as keys in skip lists.

Structures can be compared for (non-)equality. They are compared field-by-field, accessing via getattr(). Extra fields on the compared-to-object are ignored.

Accessing the contents attribute of a structure instance will return a named tuple. Assigning to the attribute will set the contents of the structure to the assigned value, which must have at least the attributes the structure has fields.

class ptypes.storage.Persistent

Bases: object

Base class for all the proxy classes for persistent objects.

id

Read-only property giving a tuple uniquely identifies the object.

isSameAs()

Compare the identity of Persistent instances.

Note that the is operator compares the identity of the proxy objects, not that of the persistent objects they refer to.

isSameAs(self, other)
Parameters:
  • self (Persistent) – proxy for a persistent object
  • other (Persistent) – proxy for another persistent object
Returns:

True if self refers to the same persistent object as other, otherwise False.

class ptypes.storage.PersistentMeta

Bases: type

Abstract base meta class for all persistent types.

The query module

For examples of using this module see Declarative Queries.

class ptypes.query.Attribute

Bases: ptypes.query.BindingRule

Bind the value of an attribute of an object to the name of the rule.

class ptypes.query.Constant

Bases: ptypes.query.BindingRule

Bind an interned constant value to the name of the rule.

class ptypes.query.Contents

Bases: ptypes.query.BindingRule

Bind the contents of a node to the name of the rule.

class ptypes.query.Each

Bases: ptypes.query.BindingRule

Bind the next value in a hash index to the name of the rule.

class ptypes.query.Param

Bases: ptypes.query.BindingRule

Bind the interned value of a query parameter to the name of the rule.

class ptypes.query.Query

Bases: object

Selects combinations of persistent objects.

Each selected combination is sent to a generator.

Treat this as an abstract base class and define your queries in subclasses derived from this. Specify the binding rules in the body of the class and override the processOne() method.

processOne()

A generator to which the query context is repeatedly sent.

Whenever the query context reaches a state matching all the binding rules, it is sent to this generator.

This generator method can be overridden in derived classes. The default implementation prints a header and trailer and in between the context every time it receives it.

class ptypes.query.RichCompare

Bases: ptypes.query.BindingRule

Bind the result of a comparison to the name of the rule.

The pcollections module

For examples of using this module see Persistent Collections.

class ptypes.pcollections.Range

Bases: ptypes.query.BindingRule

Bind the next value in a skip-list to the name of the variable.

The graph module

For examples of using this module see Property Graphs.

class ptypes.graph.NodeAttribute

Bases: ptypes.query.BindingRule

Bind the value of an attribute of a node to the name of the variable.

class ptypes.graph.NodeContents

Bases: ptypes.query.BindingRule

Bind the contents of a node to the name of the variable.

The buffer module

For examples of using this module see Persistent Buffers.

Table Of Contents

Previous topic

Persistent Buffers

Next topic

Participating in the development of ptypes

This Page