Example #1
0
    def _Run(self, **values):

        result = 1
        importWf = 1
        importSecurity = 0
        showSystem = values.get("showSystem")
        modify = values.get("modify")
        request = values["original"]
        ignoreTables = self.app.configuration.get("skipUpdateTables", ())

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()
        # localizer.translate(term)

        text = _(
            u""" <div class="well">
This tool compares the physically existing database structure (tables, columns) with the current configuration settings.
The database structure is shown on the left, configuration settings on the right. <br><br>
Existing database columns will only be altered if manually selected in the 'Modify' column. Modifying a table may destroy the data
stored (e.g if converted from string to integer), so don't forget to create backups of the database before modifying anything.<br>
By default this tool will only create new tables and columns and never delete any column.
 </div>       """
        )
        self.stream.write(localizer.translate(_(text)))

        self.stream.write(
            u"""<form action="" method="post">
                     <input type="hidden" name="tag" value="dbStructureUpdater">
                     <input type="hidden" name="modify" value="1">"""
        )
        app = self.app
        try:
            conf = app.dbConfiguration
            connection = app.NewConnection()
            if not connection:
                self.stream.write(
                    localizer.translate(
                        _(u"""<div class="alert alert-error">No database connection configured</div>""")
                    )
                )
                return 0
        except OperationalError, e:
            self.stream.write(
                localizer.translate(_(u"""<div class="alert alert-error">No database connection configured</div>"""))
            )
            return 0
Example #2
0
    def _Run(self, **values):

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()

        app = self.app
        root = app.root()
        datapool = app.db
        conn = datapool.connection
        c = conn.cursor()

        # delete
        sql = u"delete from pool_fulltext"
        c.execute(sql)
        c.close()
        conn.commit()
        self.stream.write(
            localizer.translate(_(u"Deleted previous fulltext index.<br/>")))

        pages = root.Select(parameter={"pool_stag": 10, "pool_state": 1})
        cnt = len(pages)
        err = 0
        for page in pages:
            page = page[0]
            obj = root.LookupObj(page)
            if not obj:
                err += 1
                self.stream.write(
                    localizer.translate(
                        _(u"Error: Unable to open page (${id}).<br/>",
                          mapping={"id": page})))
            else:
                try:
                    obj.UpdateFulltext()
                except Exception, e:
                    err += 1
                    self.stream.write(
                        localizer.translate(
                            _(u"Error: Unable to update page (${id}).<br/>",
                              mapping={"id": page})))
                    self.stream.write(unicode(e))
                    self.stream.write(u"<br/><br/>")
Example #3
0
    def _Run(self, **values):

        result = 1
        importWf = 1
        importSecurity = 0
        showSystem = values.get("showSystem")
        modify = values.get("modify")
        request = values["original"]

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()
        #localizer.translate(term)

        text = _(u""" <div class="well">
This tool compares the physically existing database structure (tables, columns) with the current configuration settings.
The database structure is shown on the left, configuration settings on the right. <br><br>
Existing database columns will only be altered if manually selected in the 'Modify' column. Modifying a table may destroy the data
stored (e.g if converted from string to integer), so don't forget to create backups of the database before modifying anything.<br>
By default this tool will only create new tables and columns and never delete any column.
 </div>       """)
        self.stream.write(localizer.translate(_(text)))

        self.stream.write(u"""<form action="" method="post">
                     <input type="hidden" name="tag" value="dbStructureUpdater">
                     <input type="hidden" name="modify" value="1">""")
        app = self.app
        try:
            conf = app.dbConfiguration
            connection = app.NewConnection()
            if not connection:
                self.stream.write(
                    localizer.translate(
                        _(u"""<div class="alert alert-error">No database connection configured</div>"""
                          )))
                return 0
        except OperationalError, e:
            self.stream.write(
                localizer.translate(
                    _(u"""<div class="alert alert-error">No database connection configured</div>"""
                      )))
            return 0
Example #4
0
    def _Run(self, **values):

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()

        app = self.app
        datapool = app.db
        conn = datapool.connection
        c = conn.cursor()

        self.stream.write(u"<table>\n")

        sql = "select count(*) from pool_meta"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Elements in total</th><td>${value}</td></tr>\n", mapping={u"value": rec[0][0]})))

        sql = "select count(*) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Physical files</th><td>${value}</td></tr>\n", mapping={u"value": rec[0][0]})))

        sql = "select sum(size) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(localizer.translate(_(u"<tr><th>Physical files size</th><td>${value}</td></tr>\n", mapping={u"value": FormatBytesForDisplay(rec[0][0])})))

        for t in app.GetAllObjectConfs():
            sql = "select count(*) from pool_meta where pool_type='%s'" % t.id
            c.execute(sql)
            rec = c.fetchall()
            self.stream.write(localizer.translate(_(u"<tr><th>${name}</th><td>${value}</td></tr>\n", mapping={u"name": t.name, u"value": rec[0][0]})))
        
        self.stream.write(u"</table>\n")

        c.close()
        return 1
Example #5
0
    def _Run(self, **values):

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()

        app = self.app
        root = app.root()
        datapool = app.db
        conn = datapool.connection
        c = conn.cursor()

        # delete
        sql = u"delete from pool_fulltext"
        c.execute(sql)
        c.close()
        conn.commit()
        self.stream.write(localizer.translate(_(u"Deleted previous fulltext index.<br>")))
        
        pages = root.Select(parameter={"pool_stag":10,"pool_state":1})
        cnt = len(pages)
        err = 0
        for page in pages:
            page = page[0]
            obj = root.LookupObj(page)
            if not obj:
                err += 1
                self.stream.write(localizer.translate(_(u"Error: Unable to open page (${id}).<br>", mapping={"id":page})))
            else:
                try:
                    obj.UpdateFulltext()
                except Exception, e:
                    err += 1
                    self.stream.write(localizer.translate(_(u"Error: Unable to update page (${id}).<br>", mapping={"id":page})))
                    self.stream.write(unicode(e))
                    self.stream.write(u"<br><br>")
Example #6
0
    def _Run(self, **values):

        try:
            localizer = get_localizer(get_current_request())
        except:
            localizer = FakeLocalizer()

        app = self.app
        datapool = app.db
        conn = datapool.connection
        c = conn.cursor()

        self.stream.write(u"<table class='table table-bordered'>\n")

        sql = "select count(*) from pool_meta"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(
            localizer.translate(
                _(u"<tr><th>Elements in total</th><td>${value}</td></tr>\n",
                  mapping={u"value": rec[0][0]})))

        sql = "select count(*) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(
            localizer.translate(
                _(u"<tr><th>Physical files</th><td>${value}</td></tr>\n",
                  mapping={u"value": rec[0][0]})))

        sql = "select sum(size) from pool_files"
        c.execute(sql)
        rec = c.fetchall()
        self.stream.write(
            localizer.translate(
                _(u"<tr><th>Physical files size</th><td>${value}</td></tr>\n",
                  mapping={u"value": FormatBytesForDisplay(rec[0][0])})))

        for t in app.GetAllObjectConfs():
            sql = "select count(*) from pool_meta where pool_type='%s'" % t.id
            c.execute(sql)
            rec = c.fetchall()
            self.stream.write(
                localizer.translate(
                    _(u"<tr><th>${name}</th><td>${value}</td></tr>\n",
                      mapping={
                          u"name": t.name,
                          u"value": rec[0][0]
                      })))

        self.stream.write(u"</table>\n")

        c.close()
        return 1