Gda.ServerOperation

g GObject.Object GObject.Object Gda.ServerOperation Gda.ServerOperation GObject.Object->Gda.ServerOperation

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

error_quark ()

class

new (op_type, xml_file)

class

op_type_to_string (type)

class

prepare_create_database (provider, db_name)

class

prepare_drop_database (provider, db_name)

class

prepare_drop_table (cnc, table_name)

class

string_to_op_type (str)

add_item_to_sequence (seq_path)

del_item_from_sequence (item_path)

get_node_parent (path)

get_node_path_portion (path)

get_node_type (path, status)

get_op_type ()

get_root_nodes ()

get_sequence_item_names (path)

get_sequence_max_size (path)

get_sequence_min_size (path)

get_sequence_name (path)

get_sequence_size (path)

get_sql_identifier_at (cnc, prov, path)

get_value_at (path)

is_valid (xml_file)

load_data_from_xml (node)

perform_create_database (provider)

perform_create_table ()

perform_drop_database (provider)

perform_drop_table ()

set_value_at (value, path)

Virtual Methods

Inherited:

GObject.Object (7)

do_seq_item_added (seq_path, item_index)

do_seq_item_remove (seq_path, item_index)

Properties

Name

Type

Flags

Short Description

connection

Gda.Connection

r/w/co

Connection to use

op-type

int

r/w/co

Type of operation to be done

provider

Gda.ServerProvider

r/w/co

Database provider which created the object

spec-filename

str

w/co

XML file which contains the object’s data structure

Signals

Inherited:

GObject.Object (1)

Name

Short Description

sequence-item-added

Gets emitted whenever a new sequence item (from a sequence template) has been added

sequence-item-remove

Gets emitted whenever a sequence item is about to be removed

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

object

GObject.Object

r

Class Details

class Gda.ServerOperation(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gda.ServerOperationClass

classmethod error_quark()
Return type:

int

classmethod new(op_type, xml_file)
Parameters:
Returns:

a new Gda.ServerOperation object

Return type:

Gda.ServerOperation

IMPORTANT NOTE: Using this funtion is not the recommended way of creating a Gda.ServerOperation object, the correct way is to use Gda.ServerProvider.create_operation(); this method is reserved for the database provider’s implementation.

Creates a new Gda.ServerOperation object from the xml_file specifications

The xml_file must respect the DTD described in the “libgda-server-operation.dtd” file: its top node must be a <serv_op> tag.

classmethod op_type_to_string(type)
Parameters:

type (Gda.ServerOperationType) – a Gda.ServerOperationType value

Returns:

a non None string (do not free or modify)

Return type:

str

Get a string version of type

classmethod prepare_create_database(provider, db_name)
Parameters:
  • provider (str) – the database provider to use

  • db_name (str or None) – the name of the database to create, or None

Raises:

GLib.Error

Returns:

new Gda.ServerOperation object, or None if the provider does not support database creation

Return type:

Gda.ServerOperation or None

Creates a new Gda.ServerOperation object which contains the specifications required to create a database. Once these specifications provided, use Gda.ServerOperation.perform_create_database() to perform the database creation.

If db_name is left None, then the name of the database to create will have to be set in the returned Gda.ServerOperation using Gda.ServerOperation.set_value_at().

New in version 4.2.3.

classmethod prepare_drop_database(provider, db_name)
Parameters:
  • provider (str) – the database provider to use

  • db_name (str or None) – the name of the database to drop, or None

Raises:

GLib.Error

Returns:

new Gda.ServerOperation object, or None if the provider does not support database destruction

Return type:

Gda.ServerOperation or None

Creates a new Gda.ServerOperation object which contains the specifications required to drop a database. Once these specifications provided, use Gda.ServerOperation.perform_drop_database() to perform the database creation.

If db_name is left None, then the name of the database to drop will have to be set in the returned Gda.ServerOperation using Gda.ServerOperation.set_value_at().

New in version 4.2.3.

classmethod prepare_drop_table(cnc, table_name)
Parameters:
  • cnc (Gda.Connection) – an opened connection

  • table_name (str) – name of the table to drop

Raises:

GLib.Error

Returns:

a new Gda.ServerOperation or None if couldn’t create the opereration.

Return type:

Gda.ServerOperation or None

This is just a convenient function to create a Gda.ServerOperation to drop a table in an opened connection.

New in version 4.2.3.

classmethod string_to_op_type(str)
Parameters:

str (str) – a string

Returns:

the Gda.ServerOperationType represented by str, or GObject.G_MAXINT if str is not a valid representation of a Gda.ServerOperationType

Return type:

Gda.ServerOperationType

Performs the reverse of Gda.ServerOperation.op_type_to_string()

New in version 4.2.

add_item_to_sequence(seq_path)
Parameters:

seq_path (str) – the path to the sequence to which an item must be added (like “/SEQ_NAME” for instance)

Returns:

the index of the new entry in the sequence (like 5 for example if a 6th item has been added to the sequence.

Return type:

int

del_item_from_sequence(item_path)
Parameters:

item_path (str) – the path to the sequence’s item to remove (like “/SEQ_NAME/5” for instance)

Returns:

True if the specified node has been removed from the sequence

Return type:

bool

get_node_parent(path)
Parameters:

path (str) – a complete path to a node (starting with “/”)

Returns:

a new string or None if the node does not have any parent or does not exist.

Return type:

str

Get the complete path to the parent of the node defined by path

get_node_path_portion(path)
Parameters:

path (str) – a complete path to a node (starting with “/”)

Returns:

a new string, or None if an error occurred

Return type:

str

Get the last part of path

get_node_type(path, status)
Parameters:
Returns:

the type of node, or Gda.ServerOperationNodeType.UNKNOWN if the node was not found

Return type:

Gda.ServerOperationNodeType

Convenience function to get the type of a node.

get_op_type()
Returns:

a Gda.ServerOperationType enum

Return type:

Gda.ServerOperationType

Get the type of operation self is for

get_root_nodes()
Returns:

a new array, which must be freed with GLib.strfreev().

Return type:

[str]

Get an array of strings containing the paths of nodes situated at the root of self.

get_sequence_item_names(path)
Parameters:

path (str) – a complete path to a sequence node (starting with “/”)

Returns:

a array of strings containing the complete paths of the nodes contained at path (free with GLib.strfreev())

Return type:

[str]

Fetch the contents of a sequence. path can describe either a sequence (for example “/SEQNAME”) or an item in a sequence (for example “/SEQNAME/3”)

get_sequence_max_size(path)
Parameters:

path (str) – a complete path to a sequence node (starting with “/”)

Returns:

the maximum number of items in the sequence at path, or 0 if path is not a sequence node

Return type:

int

get_sequence_min_size(path)
Parameters:

path (str) – a complete path to a sequence node (starting with “/”)

Returns:

the minimum number of items in the sequence at path, or 0 if path is not a sequence node

Return type:

int

get_sequence_name(path)
Parameters:

path (str) – a complete path to a sequence node (starting with “/”)

Returns:

the name of the sequence at path

Return type:

str

get_sequence_size(path)
Parameters:

path (str) – a complete path to a sequence node (starting with “/”)

Returns:

the number of items in the sequence at path, or 0 if path is not a sequence node

Return type:

int

get_sql_identifier_at(cnc, prov, path)
Parameters:
Returns:

a new string, or None if the value is undefined or if the path is not defined or path does not hold any value, or if the value held is not a string (in that last case a warning is shown).

Return type:

str

This method is similar to Gda.ServerOperation.get_value_at(), but for SQL identifiers: a new string is returned instead of a GObject.Value. Also the returned string is assumed to represents an SQL identifier and will correctly be quoted to be used with cnc, or prov if cnc is None (a generic quoting rule will be applied if both are None).

New in version 4.2.6.

get_value_at(path)
Parameters:

path (str) – a complete path to a node (starting with “/”)

Returns:

a constant GObject.Value if a value has been defined, or None if the value is undefined or if the path is not defined or path does not hold any value.

Return type:

GObject.Value or None

Get the value for the node at the path path

New in version 4.2.6.

is_valid(xml_file)
Parameters:

xml_file (str or None) – an XML specification file (see Gda.ServerOperation.new()) or None

Raises:

GLib.Error

Returns:

True if self is valid

Return type:

bool

Tells if all the required values in self have been defined.

if xml_file is not None, the validity of self is tested against that specification, and not against the current self's specification.

load_data_from_xml(node)
Parameters:

node (libxml2.NodePtr) – a libxml2.NodePtr

Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Loads the contents of node into self. The XML tree passed through the node argument must correspond to an XML tree saved using gda_server_operation_save_data_to_xml().

perform_create_database(provider)
Parameters:

provider (str or None) – the database provider to use, or None if self has been created using Gda.ServerOperation.prepare_create_database()

Raises:

GLib.Error

Returns:

True if no error occurred and the database has been created, False otherwise

Return type:

bool

Creates a new database using the specifications in self. self can be obtained using Gda.ServerProvider.create_operation(), or Gda.ServerOperation.prepare_create_database().

New in version 4.2.3.

perform_create_table()
Raises:

GLib.Error

Returns:

True if the table was created; False and set error otherwise

Return type:

bool

Performs a prepared Gda.ServerOperation to create a table. This could perform an operation created by #gda_server_operation_prepare_create_table or any other using the the Gda.ServerOperation API.

New in version 4.2.3.

perform_drop_database(provider)
Parameters:

provider (str or None) – the database provider to use, or None if self has been created using Gda.ServerOperation.prepare_drop_database()

Raises:

GLib.Error

Returns:

True if no error occurred and the database has been destroyed

Return type:

bool

Destroys an existing database using the specifications in self. self can be obtained using Gda.ServerProvider.create_operation(), or Gda.ServerOperation.prepare_drop_database().

New in version 4.2.3.

perform_drop_table()
Raises:

GLib.Error

Returns:

True if the table was dropped

Return type:

bool

This is just a convenient function to perform a drop a table operation.

New in version 4.2.3.

set_value_at(value, path)
Parameters:
  • value (str or None) – a string

  • path (str) – a complete path to a node (starting with “/”)

Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Set the value for the node at the path formed using path_format and the … ellipse (the rules are the same as for g_strdup_printf()).

Note that trying to set a value for a path which is not used by the current provider, such as “/TABLE_OPTIONS_P/TABLE_ENGINE” for a PostgreSQL connection (this option is only supported for MySQL), will not generate any error; this allows one to give values to a superset of the parameters and thus use the same code for several providers.

Here are the possible formats of path_format:

  • If the path corresponds to a Gda.Holder, then the parameter is set to <![CDATA[”value"]]>

  • If the path corresponds to a sequence item like for example “/SEQUENCE_NAME/5/NAME” for the “NAME” value of the 6th item of the “SEQUENCE_NAME” sequence then:

    • if the sequence already has 6 or more items, then the value is just set to the corresponding value in the 6th item of the sequence

    • if the sequence has less then 6 items, then items are added up to the 6th one before setting the value to the corresponding in the 6th item of the sequence

  • If the path corresponds to a Gda.DataModel, like for example “/ARRAY/@COLUMN/5” for the value at the 6th row of the “COLUMN” column of the “ARRAY” data model, then:

    • if the data model already contains 6 or more rows, then the value is just set

    • if the data model has less than 6 rows, then rows are added up to the 6th one before setting the value

New in version 4.2.6.

do_seq_item_added(seq_path, item_index) virtual
Parameters:
  • seq_path (str) –

  • item_index (int) –

do_seq_item_remove(seq_path, item_index) virtual
Parameters:
  • seq_path (str) –

  • item_index (int) –

Signal Details

Gda.ServerOperation.signals.sequence_item_added(server_operation, seq_path, item_index)
Signal Name:

sequence-item-added

Flags:

RUN_FIRST

Parameters:
  • server_operation (Gda.ServerOperation) – The object which received the signal

  • seq_path (str) – the path to the new sequence item

  • item_index (int) – the index (starting from 0) of the new sequence item in the sequence

Gets emitted whenever a new sequence item (from a sequence template) has been added

Gda.ServerOperation.signals.sequence_item_remove(server_operation, seq_path, item_index)
Signal Name:

sequence-item-remove

Flags:

RUN_FIRST

Parameters:
  • server_operation (Gda.ServerOperation) – The object which received the signal

  • seq_path (str) – the path to the sequence item to be removed

  • item_index (int) – the index (starting from 0) of the sequence item in the sequence

Gets emitted whenever a sequence item is about to be removed

Property Details

Gda.ServerOperation.props.connection
Name:

connection

Type:

Gda.Connection

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Connection to use

Gda.ServerOperation.props.op_type
Name:

op-type

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Type of operation to be done

Gda.ServerOperation.props.provider
Name:

provider

Type:

Gda.ServerProvider

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Database provider which created the object

Gda.ServerOperation.props.spec_filename
Name:

spec-filename

Type:

str

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

XML file which contains the object’s data structure