Submodules module

The DBClassTree module


Bases: object

DBClassTree forms the interface to the database for HtmlClassTree class

awoper = 'AWOPER'
class_attributes = {}
columns_attributes = {}
classmethod determine_inline_property_classes()

method that return a dictionary containing info about inline(_list)_property classes

classmethod get_all_classes()

return all class names

classmethod get_attribute_name(table_name, column)

given the table and column name return attribute in python class

classmethod get_attributes(table_name, class_str, include_hidden=False, include_object_id=False)

Get all the persistent attributes include_hidden switch for including hidden (start with +) attributes include_object_id switch for including object ids

classmethod get_class_attributes()
classmethod get_class_name(table_name)

get the class name from the table name

classmethod get_column_name(table_name, attr_name)

get the table name from the class string

classmethod get_persistent_attributes(table_name, include_hidden=False, include_object_id=False)

get the persistent attributes for class_str

classmethod get_persistent_linked_attributes(class_str)

get the persistent inline and linked lists

classmethod get_table_name(class_str)

get the table name from the class string

classmethod init_class_attributes()

initialize the class-attributes dictionary

classmethod init_columns_attributes()

initialize the column-attribute dictionary

classmethod init_tables_classes()

initialize the table-class dictionary

classmethod set_description_units(prop)

Try to get the units from the description; description [units] and set description and units in prop dict

classmethod split_attributes(attributes)

Split the list of attributes in links (which have attributes of their own) and properties

tables_classes = {} module

Module with Error handling functionality for the DbView web service



Error class that is raised when input argument(s) are not correct


Bases: Exception

Base error class for DbView module

Class generates html for showing overview of class

class, parent)



(override) return extra attribute(s)


(override) return extra headers


generate the html

classmethod get_url(class_str, project='', server='', full_url=False)

generate an url

headers = ['Attribute name', 'Attribute type', 'Docstring', 'Unit']

make a link for the given class name, return name when table_name is not in the column cache module

Class generates html for showing the tree of a class

WJ Vriend

class, parent)


classmethod arg_handler(args, parent)

from the args return the filled in variables

attr_type_operator = {'int': ['=', '!=', '<', '>', 'between', 'not between'], 'long': ['=', '!=', '<', '>', 'between', 'not between'], 'float': ['=', '!=', '<', '>', 'between', 'not between'], 'str': ['=', '!=', 'like', 'not like'], 'oidtype': ['=', '!='], 'unicode': ['=', '!=', 'like', 'not like'], 'datetime': ['=', '!=', '<', '>', 'between', 'not between']}
classmethod correct_open_closed(tree_dict, expanded_leafs, maxlevel, level=0)

method that corrects any open leaves while one of its parents is closed

default_derived_class = {}
default_recursion_depth = 1
do_desc_property(column, element_id, tooltip_attr)

get html input element(s) for the desc attribute

get the html for a link property

classmethod empty_result()

return an empty result dict

export_options = {'XML': 'Tree structure in XML', 'NoDownload': 'HTML', 'CSV': 'Comma Separated Values', 'FITS': 'Links to download all files', 'Querytext': 'SQL statement', 'py list': 'cPickle-d lists'}
classmethod extra_export_options(export_options)

(override) derived class can add extra export options to export_options dictionary

classmethod extra_tooltip(column)

(override) get extra name,value pairs for the tooltip table


get a heading with title, sort options and max rows


generate the html

classmethod get_attributes(class_str, expanded_leafs)

(override) Given the class_str return for special classes all attributes. For normal classes the attributes can be determined by the class definition.

classmethod get_class_str(class_str)

(override) derived classes can encode information (IDs) in the class_str, this method should give back the clean class_str

get_derived_classes(parent_class_str, column, tree_elem_id, onchange=False)

get the derived classes from class_str


(override) Given the class_str return the class tree.

get_html_operator(element_id, selected_op, operators)

get the html selection box for the given operators

classmethod get_url(class_str, server='', project=None, full_url=False)

return an url to class query page for the given class string


(override) place holder for derived classes to initialize


initialize the instrument name this method is in common because the instrument is coupled to a project, and projects are common to all implementations


put the details of this attr/column in an tooltip structure

make_ul_element(class_str, tree_elem_id, column, ul, tooltip_attr, depth)

make a <li> element for the <ul> tree

not_supported = ['objectlist_property', 'self_link_property']
prefilled_attributes = {}

return the encoded python_dict for the html template if the python_dict is empty (default) return empty string

string_type = {'int': <class 'int'>, 'long': <class 'common.util.types.long'>, 'float': <class 'float'>, 'str': <class 'str'>, 'unicode': <class 'common.util.types.unicode'>, 'datetime': <function str2datetime at 0x7f61fccc6510>}
classmethod value_to_str(value)

convert the query value to a string, iterate lists

walk_class_tree(class_str, depth=0, tree_id='', parent_column=None)

walk the class tree

classmethod walk_class_tree_for_attributes(class_str, result, max_recursion_depth, parent, args, depth=0, tree_id='')

walk the class tree and get all attributes

given a depth indent string

from the given string make a datetime object module module

Class generates html to show the help on DbView

class, parent)

Bases: object


(override) get help for non-common

classmethod extra_parameters_help(dbhelp)

(override) get help for non-common parameters


method that constructs the general help text


main method that returns the complete html help page


method that constructs the help menu

classmethod parameters_help()

method that constructs the help for parameters

classmethod parameters_help_strings()

method that returns a dictionary describing the various preferences


method that returns the help for querying module module module

Class generates html to show the Preferences



default = 'no'

classmethod that returns html when using checkboxes

name = 'use_checkboxes'


default = 'yes'

method that returns html option for hiding columns

name = 'hide_columns'


default = '100'

method that returns html for constructing the numrows preference

name = 'numrows'
numrows = ['10', '100', '500', '1000', '10000']

Bases: object

cookie_prefix = 'mainpref'
default = ''
classmethod getTooltip()

return the tooltip for preference

classmethod getTooltipId()

return the tooltip identifier for this preference

return the cookie name

name = ''


default = 'yes'

method that returns html for constructing the show project preference

name = 'fcontext_project_only'


default = 'no'

classmethod that returns html to show radio button for showing comments

name = 'show_comments'


default = 'no'

method that returns html for constructing the show expanded preference

name = 'show_expanded'


cookie_name = 'SQLbox_height'
default = '10'

method that returns html for constructing the sql box preference

name = 'SQLbox_height'


cookie_name = 'SQLbox_width'
default = '90'

method that returns html for constructing the sql box preference

name = 'SQLbox_width'
class, parent)


Class for HTML rendering the DbView preferences form


show the preferences screen

preferences = [<class ''>, <class ''>, <class ''>, <class ''>, <class ''>, <class ''>, <class ''>, <class ''>]
preferences_dict = {'numrows': <class ''>, 'SQLbox_height': <class ''>, 'fcontext_project_only': <class ''>, 'show_expanded': <class ''>, 'SQLbox_width': <class ''>, 'use_checkboxes': <class ''>, 'show_comments': <class ''>, 'hide_columns': <class ''>} module

Module with class for generating html query result page

could be extended, derived in specific checkout

class, parent)



method that inserts the export options


(override) Return attributes that should always be visible in the dbview table.

classmethod check_error(e, sql='', error=False, query_type='')

generate html


method that returns data for several export possibilities


(override) If some thing has to be added to the header return it.


(override) Change anything in the request_dict if necessary module module

Module with ObjectTree class

class, object_id, max_depth=2, verbose=False, include_hidden=True, include_object_id=True, tree_expanded_leafs=None, node_state='closed')

Bases: object

Class for generating an object tree


generate the object tree

get_inline_list_objects(inline_table_name, class_str, oid)

get all inline objects and their attributes from the inline list object and return these in a list of lists: [[attr1 of obj1, attr2 of obj1], [attr1 of obj2, attr2 of obj2], ... ]

max_query_count = 1000
query_desc_list_property(oid, prop)

query the list property table and return the list of values

query the link list table for types and object_ids

query_object(class_str, oid, inline_attr='', inline_parent='')

get attributes from the given object

walk_obj_tree(class_str, object_id, depth=0, tree_id='', inline_attr='', inline_parent='')
walk recurisively the object tree
class_str the class name of the requested object object_id the object_id of the requested object
in case of inline attribute:
inline_attr the name of the inline attribute inline_parent the name of the parent class

Bases: Exception module

general SQL generator: generates SQL string for DBViewer

Usage :

generator = QueryGenerator(http_args, request_dict) sql = generator.make()

Input: request_dict can contain an additional key called “mandatory”. This is meant for attributes (belonging to f.i. link_property objects) which should always be present in the final output (HTML) table.
request_dict can contain an additional key called “query_link_list”. This is only used for the explicit specific situation where, from an object view, the users clicks a link_list_property objects which should be shown in a table. This means that a hardwired SQL statement will be added to the query. This should always be valid ONLY at level 1, see method: def generate_uplink_list_property_dict(self)
The class makes a dictionary called sqlDict which contains all relevant information to construct the SQL string.

sqlDict is a dictionary of dictionaries of dictionaries and has the following structure: sqlDict[<level>][<tree>][<keys>]

<level>: these are integers, representing the level of the tree structure. The lowest number represents the highest level and is equal to 1.
This number is always present and represents the Table where the user is requesting data from. Lower levels (higher numbers!) represent levels which depend on the level on step higher. Higher levels are always filled in if the user queried on some higher level.
<tree>: the name of the tree belonging to <level>; for level 1 this is always just the Table where the user is requesting data from.
For higher levels these represent the treenames belonging to the particular level. These are only filled if the user queried somewhere higher in the particular tree.
<keys>: these contain SQL specific strings. There are several <keys>: KEYs, WHEREs, link_list_property, inline_property, inline_list_property, SQs, attributes and View.
-)KEYs and WHEREs are lists and are related to each other. KEYs represent the keys where the user did a query on. WHEREs subsequently gives the constraints. -)link_list_property/inline_property/inline_list_property: if filled, it provides the table name of the linklist, inline or inline_list_property type objects -)Mandatory: if filled, mandatory values which should be present in the output are present. -)SQs are the identifiers of the subquery used in the SQL statement -)attributes: the attributes which should be present in the output table. Mostly object_id for lower levels. For the highest level these are attributes which should be present in the output Table -)View: name of the View
class, request_dict, debug=0)

Bases: object

this class constructs general SQL queries, input : args the http server arguments request_dict the dict from HtmlClassTree debug debug or verbose flag

add_column_names(level, tree, index, attribute)

method that returns a tuple containing the original attribute and the renamed attribute


method to initialize a self.column_dict key


method to check whether mandatory values actually belong to the object with the highest level

determine_base_attributes(base_attributes, mandatory)

overrride: return a particular order for base atrributes to be visible in the output

example: part 1: ,SQ24 AS ( SELECT “COLUMN_VALUE” AS “regriddedframe.object_id” FROM AWOPER.”EGRIDDEDFRAME$REGRIDDED_FRAMES” WHERE “OBJECT_ID” = HEXTORAW(‘12C453338F706A59E053C016A9C36363’) ) part 2: JOIN SQ24 ON “object_id” = SQ24.”regriddedframe.object_id”

get_renamed(level, header)

method that returns a renamed column


main program to construct the SQL query

make_attributeList(level, tree, status='open')

generate requested list of attributes which should be present in the output table

make_between(constraint, req)

constructs sql BETWEEN string


constructs SQL TIME format

make_join(delimit, List)

makes string of a list (of strings) separated by delimit

constructs linklistsubquery

make_queryConstraint(CONSTRAINT, REQ, TYPE)

constructs SQL constraints after WHERE

make_subquery(SQid, viewname, attributes, KEYs, where, subqueries, inline='no')

constructs subqueries

make_tree(queryDict, level, tree, attributes=['"object_id"'])

constructs tree for sqldict


returns a dictionary which is used to construct the SQL query optional: order_list; this is specific and determines in which order parameters should be shown in the browser after a query


initialize parameters derived from args module

Module with python code for configuration of (html) tables in the dbview web service

common version


Bases: object

class for html table configuration


for the given table return column names to hide

Module contents