コード例 #1
0
ファイル: augmentdb.py プロジェクト: rubencabrera/Pyrseas
        def __init__(self, config):
            """Initialize the various DbAugmentDict-derived dictionaries

            :param config: configuration dictionary
            """
            self.schemas = AugSchemaDict()
            self.tables = AugClassDict()
            self.columns = CfgColumnDict(cfg_section(config, 'columns'))
            self.funcsrcs = CfgFunctionSourceDict(
                cfg_section(config, 'function_templates'))
            self.functions = CfgFunctionDict(cfg_section(config, 'functions'))
            self.triggers = CfgTriggerDict(cfg_section(config, 'triggers'))
            self.auditcols = CfgAuditColumnDict(
                cfg_section(config, 'audit_columns'))
コード例 #2
0
ファイル: augmentdb.py プロジェクト: rubencabrera/Pyrseas
    class AugDicts(object):
        """A holder for dictionaries (maps) describing augmentations"""

        def __init__(self, config):
            """Initialize the various DbAugmentDict-derived dictionaries

            :param config: configuration dictionary
            """
            self.schemas = AugSchemaDict()
            self.tables = AugClassDict()
            self.columns = CfgColumnDict(cfg_section(config, 'columns'))
            self.funcsrcs = CfgFunctionSourceDict(
                cfg_section(config, 'function_templates'))
            self.functions = CfgFunctionDict(cfg_section(config, 'functions'))
            self.triggers = CfgTriggerDict(cfg_section(config, 'triggers'))
            self.auditcols = CfgAuditColumnDict(
                cfg_section(config, 'audit_columns'))

        def _link_refs(self):
            """Link related objects"""
            self.schemas.link_refs(self.tables)

        def _link_current(self, db):
            """Link augment objects to current catalog objects"""
            self.current = db
            self.schemas.link_current(db.schemas)
            self.tables.link_current(db.tables)

        def add_func(self, schema, function):
            """Add a function to a schema if not already present

            :param schema: schema name
            :param function: the possibly new function
            """
            if schema in self.schemas:
                self.schemas[schema].add_func(function)
            elif schema in self.current.schemas:
                sch = self.current.schemas[schema]
                if not hasattr(sch, 'functions'):
                    sch.functions = {}
                if function.name not in sch.functions:
                    sch.functions.update({function.name: function})

        def add_lang(self, lang):
            """Add a language if not already present

            :param lang: the possibly new language
            """
            if lang not in self.current.languages:
                self.current.languages[lang] = Language(name=lang)