Dee.SharedModel

g Dee.Model Dee.Model Dee.SerializableModel Dee.SerializableModel Dee.Model->Dee.SerializableModel Dee.ProxyModel Dee.ProxyModel Dee.SharedModel Dee.SharedModel Dee.ProxyModel->Dee.SharedModel Dee.Serializable Dee.Serializable Dee.Serializable->Dee.SerializableModel Dee.SerializableModel->Dee.ProxyModel GObject.GInterface GObject.GInterface GObject.GInterface->Dee.Model GObject.GInterface->Dee.Serializable GObject.Object GObject.Object GObject.Object->Dee.SerializableModel

Subclasses:

None

Methods

Inherited:

Dee.SerializableModel (3), GObject.Object (37), Dee.Model (48), Dee.Serializable (4)

Structs:

GObject.ObjectClass (5)

class

new (name)

class

new_for_peer (peer)

class

new_with_back_end (name, back_end)

flush_revision_queue ()

flush_revision_queue_sync ()

get_flush_mode ()

get_peer ()

get_swarm_name ()

is_leader ()

is_synchronized ()

set_flush_mode (mode)

Virtual Methods

Inherited:

GObject.Object (7), Dee.Model (50), Dee.Serializable (1)

Properties

Inherited:

Dee.ProxyModel (3)

Name

Type

Flags

Short Description

access-mode

Dee.SharedModelAccessMode

r/w/co

Access mode used by this shared model

flush-mode

Dee.SharedModelFlushMode

r/w

Determines whether flushes occur automatically

peer

Dee.Peer

r/w/co

The peer object that monitors the swarm

synchronized

bool

r

Whether the model is synchronized with its peers

Signals

Inherited:

GObject.Object (1), Dee.Model (5)

Name

Short Description

begin-transaction

Emitted right before a remote transaction will be committed to the model.

end-transaction

Emitted right after a remote transaction has been committed to the model.

Fields

Inherited:

GObject.Object (1), Dee.Model (5)

Name

Type

Access

Description

parent

Dee.ProxyModel

r

priv

Dee.SharedModelPrivate

r

Class Details

class Dee.SharedModel(**kwargs)
Bases:

Dee.ProxyModel

Abstract:

No

Structure:

Dee.SharedModelClass

All fields in the Dee.SharedModel structure are private and should never be accessed directly

classmethod new(name)
Parameters:

name (str) – A well known name to publish this model under. Models sharing this name will synchronize with each other

Returns:

a new Dee.SharedModel

Return type:

Dee.SharedModel

Create a new empty shared model without any column schema associated. The column schema will be set in one of two ways: firstly you may set it manually with dee_model_set_schema() or secondly it will be set once the first rows are exchanged with a peer model.

A Dee.SharedModel with a schema manually set has to be created before creating more Dee.SharedModel with the same name.

A shared model created with this constructor will store row data in a suitably picked memory backed model.

classmethod new_for_peer(peer)
Parameters:

peer (Dee.Peer) – A Dee.Peer instance.

Returns:

a new Dee.SharedModel

Return type:

Dee.SharedModel

Create a new empty shared model without any column schema associated. The column schema will be set in one of two ways: firstly you may set it manually with dee_model_set_schema() or secondly it will be set once the first rows are exchanged with a peer model.

A Dee.SharedModel with a schema manually set has to be created before creating more Dee.SharedModel with the same name.

A shared model created with this constructor will store row data in a suitably picked memory backed model.

classmethod new_with_back_end(name, back_end)
Parameters:
  • name (str) – A well known name to publish this model under. Models sharing this name will synchronize with each other

  • back_end (Dee.Model) – The Dee.Model that will actually store the model data. Ownership of the ref to back_end is transfered to the shared model.

Returns:

a new Dee.SharedModel

Return type:

Dee.SharedModel

Create a new shared model storing all data in back_end.

The model will start synchronizing with peer models as soon as possible and the Dee.SharedModel :synchronized property will be set once finished.

flush_revision_queue()
Returns:

The number of revisions flushed.

Return type:

int

Expert: All changes to self that has not yet been propagated to the peer models are send. If you also want to block the mainloop until all the underlying transport streams have been flushed use Dee.SharedModel.flush_revision_queue_sync().

Normally Dee.SharedModel collects changes to self into batches and sends them automatically to all peers. You can use this call to provide fine grained control of exactly when changes to self are synchronized to its peers. This may for example be useful to improve the interactivity of your application if you have a model-process which intermix small and light changes with big and expensive changes. Using this call you can make sure the model-process dispatches small changes more aggresively to the view-process, while holding on to the expensive changes a bit longer.

flush_revision_queue_sync()
Returns:

The number of revisions flushed.

Return type:

int

Similar to Dee.SharedModel.flush_revision_queue(), but also blocks the mainloop until all the underlying transport streams have been flushed.

Important: This method may flush your internal queue of DBus messages forcing them to be send before this call returns.

get_flush_mode()
Returns:

The Dee.SharedModelFlushMode used by the model

Return type:

Dee.SharedModelFlushMode

Convenience function for accessing the Dee.SharedModel :flush-mode property.

get_peer()
Returns:

The Dee.Peer used to interact with the peer models

Return type:

Dee.Peer

Convenience function for accessing the Dee.SharedModel :peer property

get_swarm_name()
Returns:

The name of the swarm this model synchrnonizes with

Return type:

str

Convenience function for accessing the Dee.Peer :swarm-name property of the Dee.Peer defined in the Dee.SharedModel :peer property.

is_leader()
Returns:

The value of Dee.Peer.is_swarm_leader() for the Dee.Peer used by this shared model

Return type:

bool

Check if the model is the swarm leader. This is a convenience function for accessing the Dee.SharedModel :peer property and checking if it’s the swarm leader.

is_synchronized()
Returns:

The value of the :synchronized property

Return type:

bool

Check if the model is synchronized with its peers. Before modifying a shared model in any way (except dee_model_set_schema()) you should wait for it to become synchronized. This is normally done by waiting for the “notify::synchronized” signal.

This method is purely a convenience function for accessing the Dee.SharedModel :synchronized property.

set_flush_mode(mode)
Parameters:

mode (Dee.SharedModelFlushMode) – Flush mode to use

Convenience function for setting the Dee.SharedModel :flush-mode property.

Signal Details

Dee.SharedModel.signals.begin_transaction(shared_model, begin_seqnum, end_seqnum)
Signal Name:

begin-transaction

Flags:

RUN_LAST

Parameters:
  • shared_model (Dee.SharedModel) – The object which received the signal

  • begin_seqnum (int) – The seqnum the model has now

  • end_seqnum (int) – The seqnum the model will have after the transaction is applied

Emitted right before a remote transaction will be committed to the model.

Dee.SharedModel.signals.end_transaction(shared_model, begin_seqnum, end_seqnum)
Signal Name:

end-transaction

Flags:

RUN_LAST

Parameters:
  • shared_model (Dee.SharedModel) – The object which received the signal

  • begin_seqnum (int) – The seqnum the model had before the transaction was applied

  • end_seqnum (int) – The seqnum the model has now

Emitted right after a remote transaction has been committed to the model.

Property Details

Dee.SharedModel.props.access_mode
Name:

access-mode

Type:

Dee.SharedModelAccessMode

Default Value:

Dee.SharedModelAccessMode.WORLD_WRITABLE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Enumeration defining behavior of this model when trying to write to it.

Setting this to Dee.SharedModelAccessMode.LEADER_WRITABLE is useful when one process is considered an “owner” of a model and all the other peers are supposed to only synchronize it for reading.

See also Dee.Peer :swarm-owner property to ensure ownership of a swarm.

Dee.SharedModel.props.flush_mode
Name:

flush-mode

Type:

Dee.SharedModelFlushMode

Default Value:

Dee.SharedModelFlushMode.AUTOMATIC

Flags:

READABLE, WRITABLE

Enumeration defining the flushing behavior.

Setting this to Dee.SharedModelFlushMode.MANUAL will disable automatic flushing that usually happens when the application’s main event loop is idle. Automatic flushing should be primarily disabled when a shared model is used from multiple threads, or when not using GLib.MainLoop. When disabled, Dee.SharedModel.flush_revision_queue() needs to be called explicitely.

Dee.SharedModel.props.peer
Name:

peer

Type:

Dee.Peer

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The Dee.Peer that this model uses to connect to the swarm

Dee.SharedModel.props.synchronized
Name:

synchronized

Type:

bool

Default Value:

False

Flags:

READABLE

Boolean property defining whether or not the model has synchronized with its peers (if any) yet.

You should not modify a Dee.SharedModel that is not synchronized. Before modifying the model in any way (except calling dee_model_set_schema()) you should wait for it to become synchronized.