Exemple #1
0
    def _add(self, operation, mapper, instance):
        """
        Add a new entry to the history table.
        """
        user = None
        from bauble import db
        try:
            if db.engine.name in ('postgres', 'postgresql'):
                import bauble.plugins.users as users
                user = users.current_user()
        except:
            if 'USER' in os.environ and os.environ['USER']:
                user = os.environ['USER']
            elif 'USERNAME' in os.environ and os.environ['USERNAME']:
                user = os.environ['USERNAME']

        row = {}
        for c in mapper.local_table.c:
            row[c.name] = utils.utf8(getattr(instance, c.name))
        table = History.__table__
        table.insert(
            dict(table_name=mapper.local_table.name,
                 table_id=instance.id,
                 values=str(row),
                 operation=operation,
                 user=user,
                 timestamp=datetime.datetime.today())).execute()
Exemple #2
0
    def _add(self, operation, mapper, instance):
        """
        Add a new entry to the history table.
        """
        user = None
        try:
            if engine.name.startswith('sqlite'):
                raise TypeError("this engine know nothing of users")
            import bauble.plugins.users as users
            user = users.current_user()
        except:
            if 'USER' in os.environ and os.environ['USER']:
                user = os.environ['USER']
            elif 'USERNAME' in os.environ and os.environ['USERNAME']:
                user = os.environ['USERNAME']

        row = {}
        for c in mapper.local_table.c:
            row[c.name] = utils.utf8(getattr(instance, c.name))
        table = History.__table__
        table.insert(
            dict(table_name=mapper.local_table.name,
                 table_id=instance.id,
                 values=str(row),
                 operation=operation,
                 user=user,
                 timestamp=datetime.datetime.today())).execute()
Exemple #3
0
    def _add(self, operation, mapper, instance):
        """
        Add a new entry to the history table.
        """
        user = None
        from bauble import db

        try:
            if db.engine.name in ("postgres", "postgresql"):
                import bauble.plugins.users as users

                user = users.current_user()
        except:
            if "USER" in os.environ and os.environ["USER"]:
                user = os.environ["USER"]
            elif "USERNAME" in os.environ and os.environ["USERNAME"]:
                user = os.environ["USERNAME"]

        row = {}
        for c in mapper.local_table.c:
            row[c.name] = utils.utf8(getattr(instance, c.name))
        table = History.__table__
        table.insert(
            dict(
                table_name=mapper.local_table.name,
                table_id=instance.id,
                values=str(row),
                operation=operation,
                user=user,
                timestamp=datetime.datetime.today(),
            )
        ).execute()
Exemple #4
0
    def _add(self, operation, mapper, instance):
        """
        Add a new entry to the history table.
        """
        user = None
        try:
            if engine.name.startswith('sqlite'):
                raise TypeError("this engine know nothing of users")
            import bauble.plugins.users as users
            user = users.current_user()
        except:
            if 'USER' in os.environ and os.environ['USER']:
                user = os.environ['USER']
            elif 'USERNAME' in os.environ and os.environ['USERNAME']:
                user = os.environ['USERNAME']

        row = {}
        for c in mapper.local_table.c:
            row[c.name] = utils.utf8(getattr(instance, c.name))
        table = History.__table__
        table.insert(dict(table_name=mapper.local_table.name,
                          table_id=instance.id, values=str(row),
                          operation=operation, user=user,
                          timestamp=datetime.datetime.today())).execute()