htsql-firebird / src / htsql / tweak / view /

# Copyright (c) 2006-2012, Prometheus Research, LLC
# See `LICENSE` for license information, `AUTHORS` for the list of authors.

from ...core.addon import Addon, addon_registry

class TweakViewAddon(Addon):

    name = 'tweak.view'
    hint = """add constraints for views"""
    help = """
    This addon attempts to infer foreign keys and other constraints
    from a view definition.

    Currently, only PostgreSQL backend is supported.

    def get_extension(cls, app, attributes):
        if app.htsql.db is not None:
            name = '%s.%s' % (, app.htsql.db.engine)
            if name not in addon_registry:
                raise ImportError("%s is not implemented for %s"
                                  % (, app.htsql.db.engine))
            return name