common.services.dbview package

Submodules

common.services.dbview.DBClassTree module

The DBClassTree module

class common.services.dbview.DBClassTree.DBClassTree

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 = {}

common.services.dbview.DbViewErrors module

Module with Error handling functionality for the DbView web service

exception common.services.dbview.DbViewErrors.HtmlDbViewArgumentError

Bases: common.services.dbview.DbViewErrors.HtmlDbViewError

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

exception common.services.dbview.DbViewErrors.HtmlDbViewError

Bases: Exception

Base error class for DbView

common.services.dbview.HtmlClassOverview module

Class generates html for showing overview of class

class common.services.dbview.HtmlClassOverview.HtmlClassOverview(args, parent)

Bases: common.services.general.HtmlBase.HtmlBase

extra_attributes(column)

(override) return extra attribute(s)

extra_headers()

(override) return extra headers

getHtml()

generate the html

classmethod get_url(class_str, project='', server='dbview.astro-wise.org', 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

common.services.dbview.HtmlClassTree module

Class generates html for showing the tree of a class

WJ Vriend

class common.services.dbview.HtmlClassTree.HtmlClassTree(args, parent)

Bases: common.services.general.HtmlBase.HtmlBase

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

getHeading()

get a heading with title, sort options and max rows

getHtml()

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

get_html(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='dbview.astro-wise.org', project=None, full_url=False)

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

init_derived()

(override) place holder for derived classes to initialize

init_instrument()

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

make_tooltip_attr_table(column)

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 = {}
python_dict_for_template()

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

common.services.dbview.HtmlClassTree.indent(depth)

given a depth indent string

common.services.dbview.HtmlClassTree.str2datetime(arg)

from the given string make a datetime object

common.services.dbview.HtmlDbView module

common.services.dbview.HtmlHelp module

Class generates html to show the help on DbView

class common.services.dbview.HtmlHelp.HtmlHelp(args, parent)

Bases: object

external_help()

(override) get help for non-common

classmethod extra_parameters_help(dbhelp)

(override) get help for non-common parameters

general_help()

method that constructs the general help text

getHtml()

main method that returns the complete html help page

get_menu()

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

query_help()

method that returns the help for querying

common.services.dbview.HtmlObjectTree module

common.services.dbview.HtmlObjectUplinkTree module

common.services.dbview.HtmlPreferences module

Class generates html to show the Preferences

class common.services.dbview.HtmlPreferences.HtmlPreferenceCheckboxes

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = 'no'
getHtml(selected='')

classmethod that returns html when using checkboxes

name = 'use_checkboxes'
class common.services.dbview.HtmlPreferences.HtmlPreferenceHideColumns

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = 'yes'
getHtml(selected='')

method that returns html option for hiding columns

name = 'hide_columns'
class common.services.dbview.HtmlPreferences.HtmlPreferenceNumrows

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = '100'
getHtml(selected='')

method that returns html for constructing the numrows preference

name = 'numrows'
numrows = ['10', '100', '500', '1000', '10000']
class common.services.dbview.HtmlPreferences.HtmlPreferenceOption

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 = ''
class common.services.dbview.HtmlPreferences.HtmlPreferenceProjectOnly

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = 'yes'
getHtml(selected='')

method that returns html for constructing the show project preference

name = 'fcontext_project_only'
class common.services.dbview.HtmlPreferences.HtmlPreferenceShowComments

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = 'no'
getHtml(selected='')

classmethod that returns html to show radio button for showing comments

name = 'show_comments'
class common.services.dbview.HtmlPreferences.HtmlPreferenceShowExpanded

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

default = 'no'
getHtml(selected='')

method that returns html for constructing the show expanded preference

name = 'show_expanded'
class common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxHeight

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

cookie_name = 'SQLbox_height'
default = '10'
getHtml(selected='')

method that returns html for constructing the sql box preference

name = 'SQLbox_height'
class common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxWidth

Bases: common.services.dbview.HtmlPreferences.HtmlPreferenceOption

cookie_name = 'SQLbox_width'
default = '90'
getHtml(selected='')

method that returns html for constructing the sql box preference

name = 'SQLbox_width'
class common.services.dbview.HtmlPreferences.HtmlPreferences(args, parent)

Bases: common.services.general.HtmlBase.HtmlBase

Class for HTML rendering the DbView preferences form

getHtml()

show the preferences screen

preferences = [<class 'common.services.dbview.HtmlPreferences.HtmlPreferenceNumrows'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceProjectOnly'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceShowExpanded'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceHideColumns'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxWidth'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxHeight'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceCheckboxes'>, <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceShowComments'>]
preferences_dict = {'numrows': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceNumrows'>, 'SQLbox_height': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxHeight'>, 'fcontext_project_only': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceProjectOnly'>, 'show_expanded': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceShowExpanded'>, 'SQLbox_width': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceSqlBoxWidth'>, 'use_checkboxes': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceCheckboxes'>, 'show_comments': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceShowComments'>, 'hide_columns': <class 'common.services.dbview.HtmlPreferences.HtmlPreferenceHideColumns'>}

common.services.dbview.HtmlQueryResult module

Module with class for generating html query result page

could be extended, derived in specific checkout

class common.services.dbview.HtmlQueryResult.HtmlQueryResult(args, parent)

Bases: common.services.general.HtmlBase.HtmlBase

add_export_options()

method that inserts the export options

add_mandatory_attributes()

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

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

generate html

get_export(wfile)

method that returns data for several export possibilities

get_header()

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

revise_request_dict()

(override) Change anything in the request_dict if necessary

common.services.dbview.HtmlTableRender module

common.services.dbview.ObjectTree module

Module with ObjectTree class

class common.services.dbview.ObjectTree.ObjectTree(class_str, 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()

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
exception common.services.dbview.ObjectTree.ObjectTreeError

Bases: Exception

common.services.dbview.QueryGenerator 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 common.services.dbview.QueryGenerator.QueryGenerator(args, 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

check_column_dict(level)

method to initialize a self.column_dict key

check_mandatory()

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

make()

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

make_datetime(req)

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_sql(sqlDict)
make_subquery(SQid, viewname, attributes, KEYs, where, subqueries, inline='no')

constructs subqueries

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

constructs tree for sqldict

prepare_sqldict(order_list=[])

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

process_args(args)

initialize parameters derived from args

common.services.dbview.TableConfig module

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

common version

class common.services.dbview.TableConfig.TableConfig

Bases: object

class for html table configuration

hidden_columns(table)

for the given table return column names to hide

Module contents