Package gnue :: Package appserver :: Package gcd :: Module readgcd :: Class gcdReader
[show private | hide private]

Class gcdReader


Method Summary
  __init__(self, connections, database, files, dump, fonly)
Create a new instance of a gcd reader
  doUpdate(self, resultSet, data)
This function sets all fields in the current record of the resultset based on the key/values given by the data dictionary.
  executeAndGenerateCode(self)
This function logs into the given connection and calls it for an update of it's schema according to the loaded table definitions.
  run(self)
This is the main function of the whole process.
  updateRepository(self)
This function updates all parts of the class repository.
  __addClassToRepository(self, item)
This function adds a class to the class dictionary used for repository update later on.
  __addClassToSchema(self, item)
This function adds a class to the schema definition used for backend schema generation later on.
  __addIndexToSchema(self, item)
This function adds an index to the schema definition
  __addModuleToRepository(self, item)
This function adds a given module to the dictionary used for repository update later.
  __addParameterToRepository(self, item)
This function adds a parameter to the dictionary used for repository update later on.
  __addProcedureToRepository(self, item)
This function adds a procedure to the dictionary used for repository update later on.
  __addPropertyToRepository(self, item)
This function adds a property to the property dictionary used for repository update later on.
  __addPropertyToSchema(self, item)
This function adds another property to the schema definition used for backend schema generation.
  __fetchTags(self, sObject, tags)
This function creates a dictionary with all attributes from sObject listed in tags, where the keys are constructed by 'gnue_%s' % attributename.
  __generateId(self)
This function generates a new gnue_id like it is done by appserver.
  __getClassLookup(self)
This function creates a lookup dictionary for classes and filters.
  __getKey(self, record, fields)
This function creates a tuple of fields from a record.
  __getModuleLookup(self)
This function creates a lookup dictionary for modules, where it maps names to ids and vice versa
  __getProcedureLookup(self)
This function creates a procedure lookup dictionary where the key is built from "classname.modulename_procedurename".
  __getPropertyLookup(self)
This function creates a lookup dictionary for properties where the key is constructed from "classid.moduleid_propertyname".
  __integrityCheck(self)
This function does some integrity checking on the dictionaries built from all the gcd files.
  __iterateObjects(self, sObject)
This function iterates over all objects of a GCD tree and processes the instances.
  __openSource(self, classname, fieldList)
This function creates a new datasource for the given classname with the given fieldlist.
  __processResultSet(self, resultSet, items, condition)
This function iterates over the given resultset and updates all records listed in the given dictionary.
  __replaceReferences(self, dictionary, lookup, dname)
This function replaces all references in the 'dictionary' using a lookup dictionary.
  __updateClasses(self)
This function updates all classes listed in the table 'gnue_class' and it updates the lookup dictionary for all classes available.
  __updateModules(self)
This function updates all modules listed in 'gnue_modules' and populates a lookup-dictionary for *all* modules available.
  __updateParameter(self)
This function updates all parameters listed in 'gnue_parameter'.
  __updateProcedures(self)
This function updates all procedures listed in 'gnue_procedure' and updates the lookup dictionary for them.
  __updateProperties(self)
This function updates all properties listed in 'gnue_property'.

Method Details

__init__(self, connections, database, files, dump=None, fonly=False)
(Constructor)

Create a new instance of a gcd reader
Parameters:
connections - GConnections instance to be used
database - name of the connection to use (in connection.conf)
files - sequence of filenames to integerate
dump - If not None, the SQL-code of the schema-update will be stored into a file with this name
fonly - If True, only the SQL-dump will be done, no change of the backend will happen.

doUpdate(self, resultSet, data)

This function sets all fields in the current record of the resultset based on the key/values given by the data dictionary. It returns True, if a field value has been changed, otherwise False.
Parameters:
resultSet - resultset with the current record to be updated
data - dictionary with keys and values used for updates
Returns:
True if a field has been changed, False if no field has been changed.

executeAndGenerateCode(self)

This function logs into the given connection and calls it for an update of it's schema according to the loaded table definitions. Additionally the schema creation code is generated by this call, which will be stored in the given output file (if requested by options).

run(self)

This is the main function of the whole process. It loads all schema definitions and then logs into the connection to perform all actions requested.

updateRepository(self)

This function updates all parts of the class repository.

__addClassToRepository(self, item)

This function adds a class to the class dictionary used for repository update later on.
Parameters:
item - GCClass instance of the class to add

__addClassToSchema(self, item)

This function adds a class to the schema definition used for backend schema generation later on. If the same class should be added twice a 'DuplicateClassError' will be raised.
Parameters:
item - GCClass instance to be added to schema definition

__addIndexToSchema(self, item)

This function adds an index to the schema definition
Parameters:
item - GCIndex instance with the index to be added

__addModuleToRepository(self, item)

This function adds a given module to the dictionary used for repository update later.
Parameters:
item - GCModule instance of the module to be added

__addParameterToRepository(self, item)

This function adds a parameter to the dictionary used for repository update later on.
Parameters:
item - GCParameter instance to add

__addProcedureToRepository(self, item)

This function adds a procedure to the dictionary used for repository update later on.
Parameters:
item - GCProcedure instance to add

__addPropertyToRepository(self, item)

This function adds a property to the property dictionary used for repository update later on.
Parameters:
item - GCProperty instance to add

__addPropertyToSchema(self, item)

This function adds another property to the schema definition used for backend schema generation.
Parameters:
item - GCProperty instance to add

__fetchTags(self, sObject, tags)

This function creates a dictionary with all attributes from sObject listed in tags, where the keys are constructed by 'gnue_%s' % attributename.
Parameters:
sObject - Schema object to retriev attributes from
tags - list of all attributes to retrieve
Returns:
dictionary with the attribute names as keys and their values

__generateId(self)

This function generates a new gnue_id like it is done by appserver. Once this algorithm should be replace by a better one.

__getClassLookup(self)

This function creates a lookup dictionary for classes and filters. The class lookup maps names to ids and vice versa. If a class has a filter defined it will be set into the filter dictionary.

__getKey(self, record, fields)

This function creates a tuple of fields from a record. If a field value has a 'lower' function the value will be lowered. This ensures to get a case-insensitive key.
Parameters:
record - dict-like record to retrieve values from
fields - sequence of fieldnames to retrieve
Returns:
n-tuple with the (lowered) values of all fields

__getModuleLookup(self)

This function creates a lookup dictionary for modules, where it maps names to ids and vice versa

__getProcedureLookup(self)

This function creates a procedure lookup dictionary where the key is built from "classname.modulename_procedurename".

__getPropertyLookup(self)

This function creates a lookup dictionary for properties where the key is constructed from "classid.moduleid_propertyname".

__integrityCheck(self)

This function does some integrity checking on the dictionaries built from all the gcd files.

__iterateObjects(self, sObject)

This function iterates over all objects of a GCD tree and processes the instances.
Parameters:
sObject - current GCD object to be processed

__openSource(self, classname, fieldList)

This function creates a new datasource for the given classname with the given fieldlist. The primary key is always 'gnue_id'
Parameters:
classname - name of the table to create a datasource for
fieldList - sequence of fieldnames to use
Returns:
datasource instance

__processResultSet(self, resultSet, items, condition)

This function iterates over the given resultset and updates all records listed in the given dictionary. All items of the dictionary not listed in the resultset will be inserted as new records.
Parameters:
resultSet - the resultset to update
items - dictionary of records to update the resultset with
condition - sequence of key-fields used for comparison.
Returns:
triple with number of (inserted, modified, unchanged) records

__replaceReferences(self, dictionary, lookup, dname)

This function replaces all references in the 'dictionary' using a lookup dictionary. If an item is not available in the lookup dictionary a 'ReferenceLookupError' will be raised (this would point us to a bug).
Parameters:
dictionary - the dictionary to update references in
lookup - the dictionary to search for the replacement values
dname - the key to use in 'dictionary' and 'lookup'

__updateClasses(self)

This function updates all classes listed in the table 'gnue_class' and it updates the lookup dictionary for all classes available.
Returns:
True if a commit is needed, False otherwise

__updateModules(self)

This function updates all modules listed in 'gnue_modules' and populates a lookup-dictionary for *all* modules available.
Returns:
True if a commit is needed, False otherwise

__updateParameter(self)

This function updates all parameters listed in 'gnue_parameter'.
Returns:
True if a commit is needed, False otherwise

__updateProcedures(self)

This function updates all procedures listed in 'gnue_procedure' and updates the lookup dictionary for them.
Returns:
True if a commit is needed, False otherwise

__updateProperties(self)

This function updates all properties listed in 'gnue_property'.
Returns:
True if a commit is needed, False otherwise


GNUe Home

Private API

Developer's Corner