示例#1
0
文件: schema.py 项目: geertj/draco2
    def drop(self, execute=True):
        """Return a set of SQL statements that drop the model

        If `execute' is true, the statement are executed.
        """
        from draco2.model.gensql import SQLChecker, SQLDestroyer

        model = self.model()
        dialect = model.database().dialect()
        checker = SQLChecker(dialect)
        checker.visit(model)
        destroyer = SQLDestroyer(dialect)
        destroyer.visit(model)
        statements = destroyer.result()
        if execute:
            self._execute(statements, ignore_errors=True)
        return statements
示例#2
0
文件: schema.py 项目: geertj/draco2
    def create(self, execute=True, init=True):
        """Return a set of SQL statements that create the model.

        If `execute' is true, the statement are executed.
        """
        from draco2.model.gensql import SQLChecker, SQLBuilder

        model = self.model()
        dialect = model.database().dialect()
        checker = SQLChecker(dialect)
        checker.visit(model)
        builder = SQLBuilder(dialect, init)
        builder.visit(model)
        statements = builder.result()
        if execute:
            self._execute(statements)
        return statements
示例#3
0
文件: schema.py 项目: geertj/draco2
    def revoke(self, principal, group=False, execute=True):
        """Return a set of SQL statements that revoke access from a
        particular user access from the model.

        If `group' is true, `principal' refers to a group. If `execute'
        is specified, the statements are executed.
        """
        from draco2.model.gensql import SQLChecker, SQLRevoker

        model = self.model()
        dialect = model.database().dialect()
        checker = SQLChecker(dialect)
        checker.visit(model)
        revoker = SQLRevoker(dialect, principal, group)
        revoker.visit(model)
        statements = revoker.result()
        if execute:
            self._execute(statements, ignore_errors=True)
        return statements