Package qm :: Module extension
[hide private]
[frames] | no frames]

Module extension

source code

Classes [hide private]
  Extension
A class derived from 'Extension' is a QM extension.
Functions [hide private]
 
get_class_arguments(extension_class)
Return the arguments associated with 'extension_class'.
source code
 
get_class_arguments_as_dictionary(extension_class)
Return the arguments associated with 'extension_class'.
source code
 
get_class_description(extension_class, brief=0)
Return a brief description of the extension class 'extension_class'.
source code
 
get_extension_class_name(extension_class)
Return the name of 'extension_class'.
source code
 
validate_arguments(extension_class, arguments)
Validate the 'arguments' to the 'extension_class'.
source code
 
make_dom_element(extension_class, arguments, document, element=None)
Create a DOM node for an instance of 'extension_class'.
source code
 
make_dom_document(extension_class, arguments)
Create a DOM document for an instance of 'extension_class'.
source code
 
write_extension_file(extension_class, arguments, file)
Write an XML description of an extension to 'file'.
source code
 
parse_dom_element(element, class_loader, attachment_store=None)
Parse a DOM node representing an instance of 'Extension'.
source code
 
read_extension_file(file, class_loader, attachment_store=None)
Parse a file describing an extension instance.
source code
 
parse_descriptor(descriptor, class_loader, extension_loader=None)
Parse a descriptor representing an instance of 'Extension'.
source code
Variables [hide private]
  __package__ = 'qm'
Function Details [hide private]

get_class_arguments(extension_class)

source code 

Return the arguments associated with 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

returns -- A list of 'Field' objects containing all of the arguments in the class hierarchy.

get_class_arguments_as_dictionary(extension_class)

source code 

Return the arguments associated with 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

returns -- A dictionary mapping argument names to 'Field' objects. The dictionary contains all of the arguments in the class hierarchy.

get_class_description(extension_class, brief=0)

source code 

Return a brief description of the extension class 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

'brief' -- If true, return a brief (one-line) description of the extension class.

returns -- A structured text description of 'extension_class'.

get_extension_class_name(extension_class)

source code 

Return the name of 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

returns -- The name of 'extension_class'. This is the name that is used when users refer to the class.

validate_arguments(extension_class, arguments)

source code 

Validate the 'arguments' to the 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

'arguments' -- A dictionary mapping argument names (strings) to values (strings).

returns -- A dictionary mapping 'Field's to values.

Check that each of the 'arguments' is a valid argument to 'extension_class'. If so, the argumets are converted as required by the 'Field', and the dictionary returned contains the converted values. Otherwise, an exception is raised.

make_dom_element(extension_class, arguments, document, element=None)

source code 

Create a DOM node for an instance of 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

'arguments' -- The arguments to the extension class.

'document' -- The DOM document that will contain the new element.

'element' -- If not 'None' the extension element to which items will be added. Otherwise, a new element will be created by this function.

returns -- A new DOM element corresponding to an instance of the extension class. The caller is responsible for attaching it to the 'document'.

make_dom_document(extension_class, arguments)

source code 

Create a DOM document for an instance of 'extension_class'.

'extension_class' -- A class derived from 'Extension'.

'arguments' -- The arguments to the extension class.

returns -- A new DOM document corresponding to an instance of the extension class.

write_extension_file(extension_class, arguments, file)

source code 

Write an XML description of an extension to 'file'.

'extension_class' -- A class derived from 'Extension'.

'arguments' -- A dictionary mapping argument names to values.

'file' -- A file object to which the data should be written.

parse_dom_element(element, class_loader, attachment_store=None)

source code 

Parse a DOM node representing an instance of 'Extension'.

'element' -- A DOM node, of the format created by 'make_dom_element'.

'class_loader' -- A callable. The callable will be passed the name of the extension class and must return the actual class object.

'attachment_store' -- The 'AttachmentStore' in which attachments can be found.

returns -- A pair ('extension_class', 'arguments') containing the extension class (a class derived from 'Extension') and the arguments (a dictionary mapping names to values) stored in the 'element'.

read_extension_file(file, class_loader, attachment_store=None)

source code 

Parse a file describing an extension instance.

'file' -- A file-like object from which the extension instance will be read.

'class_loader' -- A callable. The callable will be passed the name of the extension class and must return the actual class object.

'attachment_store' -- The 'AttachmentStore' in which attachments can be found.

returns -- A pair ('extension_class', 'arguments') containing the extension class (a class derived from 'Extension') and the arguments (a dictionary mapping names to values) stored in the 'element'.

parse_descriptor(descriptor, class_loader, extension_loader=None)

source code 

Parse a descriptor representing an instance of 'Extension'.

'descriptor' -- A string representing an instance of 'Extension'. The 'descriptor' has the form 'class(arg1 = "val1", arg2 = "val2", ...)'. The arguments and the parentheses are optional.

'class_loader' -- A callable that, when passed the name of the extension class, will return the actual Python class object.

'extension_loader' -- A callable that loads an existing extension given the name of that extension and returns a tuple '(class, arguments)' where 'class' is a class derived from 'Extension'. If 'extension_loader' is 'None', or if the 'class' returned is 'None', then if a file exists named 'class', the extension is read from 'class' as XML. Any arguments returned by the extension loader or read from the file system are overridden by the arguments explicitly provided in the descriptor.

returns -- A pair ('extension_class', 'arguments') containing the extension class (a class derived from 'Extension') and the arguments (a dictionary mapping names to values) stored in the 'element'. The 'arguments' will have already been processed by 'validate_arguments' by the time they are returned.